Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!brl-tgr!tgr!kevvy@AMSAA.ARPA From: kevvy@AMSAA.ARPA (RAMD-SUM) Newsgroups: net.lang.c Subject: a.out.h,adventure operating systems, JMP indirects, C for Apples, etc.. Message-ID: <11664@brl-tgr.ARPA> Date: Thu, 18-Jul-85 11:06:29 EDT Article-I.D.: brl-tgr.11664 Posted: Thu Jul 18 11:06:29 1985 Date-Received: Sat, 20-Jul-85 09:56:01 EDT Sender: news@brl-tgr.ARPA Lines: 52 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 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@amsaa.arpa