Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!oliveb!tymix!antares!jms From: jms@antares.UUCP (Joe Smith) Newsgroups: comp.sys.amiga Subject: Re: Mixing C with AmigaBASIC Summary: AmigaDOS exeuctables require special loader Message-ID: <444@antares.UUCP> Date: 26 Apr 89 01:46:32 GMT References: <13680@louie.udel.EDU> Reply-To: jms@antares.UUCP (Joe Smith) Organization: Tymnet QSATS, San Jose CA Lines: 28 In article <13680@louie.udel.EDU> LIZAK98%SNYBUFVA.BITNET@cornellc.cit.cornell.edu (WE DISENGAGE--WE TURN THE PAGE) writes: > I did rewrite the serial I/O into C, but an having a hell >of time getting it to load. I know I have to load the ML code >into an array and go from there... Your code assumes that programs that can be called from the CLI are: 1) position independent (so they can be loaded anywhere in memory and run) 2) consist on nothing but executable code (so CALL CODE%) works). Neither assumption is true. Executable commands are stored in files that have several hunks, including relocation information. You told it to jump into the middle of the header where it executed an illegal instruction. Unlike some 8-bit Operating System (such as C64, CP/M, etc), executable files are not loaded into memory verbatim and run. The loader has to do 16 and 32-bit relocations and link the segments together. To get information into memory properly, you will have to learn about FD files, you will have to open the Exec and DOS libraries, you will have to use the LoadSeg function, and you will have to convince BASIC to put the right stuff in the registers when it calls your code. You will need the AmigaDOS Reference Manual and the RKM/Exec (or the equivalant information from Rob Peck's books) for your project. -- Joe Smith (408)922-6220 | jms@antares.Tymnet.COM or jms@tymix.Tymnet.COM McDonnell Douglas FSCO | UUCP: ...!{ames,pyramid}!oliveb!tymix!antares!jms PO Box 49019, MS-D21 | PDP-10:JMS@F74.Tymnet.COM CA license plate:"POPJ P," San Jose, CA 95161-9019 | narrator.device: "I didn't say that, my Amiga did!"