a.out.h,adventure operating systems, JMP indirects, C for Apples, etc..
RAMD-SUM
kevvy at AMSAA.ARPA
Fri Jul 19 01:06:29 AEST 1985
Basically, I'm writing a unix-like operating system on a micro to base
an adventure-type game on. I'm doing preliminary work on the unix system
itself, and the operating system seems to intercept many of the things I
must do. The problem is as follows: To load in the desired procedure
(function) into the memory swapping space, call it, free the swap space,
and continue this indefinitely. I've written a small program segment,
which SHOULD work, but appears not to.
----------------------------------------------------------------------
#include <stdio.h>
static char *filename = "file.data";
main()
{
int call();
char s[2048],*s2;
FILE *fp;
if ( fp=fopen( filename,"r" ) )
{
s2 = s;
while ( ( *(s2++) = getc(fp) ) != EOF);
call( s );
}
else printf("Can't open %s\n",filename);
}
call(p)
/* calls function located at pointer given */
int (*p) ();
{
(*p) (); /* basically a JMP indirect op */
}
---------------------------------------------------------------------
It loads in an executable file (file.data), and calls the location it was
loaded into. The operating system responds with "illegal instruction",
meaning, as I see it, that unix pre-pends some junk at the beginning of
the file which cannot be executed. As I see it it's the junk from the
/usr/include/aout.h file. Is this common in most C environments?
Keeping info about a file SHOULD be kept in the directory, not in the file
itself. Would anyone know how to get around this problem in a "standard"
sort of way? Also, I'm looking for a good ( but cheap ) copy of C for
the Apple ][ computer and any help in that quest would be greatly ap-
preciated as well...
kevvy at amsaa.arpa
More information about the Comp.lang.c
mailing list