home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!wupost!waikato.ac.nz!comp.vuw.ac.nz!actrix!templar!jbickers
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Registers from C
- Message-ID: <jbickers.0c9q@templar.actrix.gen.nz>
- From: jbickers@templar.actrix.gen.nz (John Bickers)
- Date: 29 Jul 92 09:19:34 PST
- References: <14q2h5INNoee@darkstar.UCSC.EDU> <paulk.0xau@terapin.com>
- Organization: TAP, NZAmigaUG
- Lines: 67
-
- Quoted from <paulk.0xau@terapin.com> by paulk@terapin.com (Paul Kienitz):
- > > To quote the 2.0 RKM:Includes & Autodocs page 647 NP_Arguments entry:
-
- > > Ok. So, assuming the function is CreateNewProc()-ing correctly, how
- > > do I pull these arguments out of the registers from C. I realize this
- > > is a probably a very simple thing to do, but I would really appreciate
- > > help from anyone with some experience.
-
- [Aztec stuff deleted]
-
- > In SAS it's something vaguely like:
- >
- > long Sub_process_main(register __a0 char *argline,
- > register __d0 long arglen)
-
- long __saveds __asm sub(register __a0 char *argline,register __d0 long arglen);
-
- > As for DICE, I dunno.
-
- __regargs __geta4 long sub(char *argline,long arglen);
-
- One problem is that this calls the routine "@sub", but when you
- try and set pointers to the function, DICE uses "_sub", so you get
- a link error. Or it did when I tried to use it for XPR callbacks.
- There might be some compiler option to get around this.
-
- The most generic approach is to use assembler glue. For example:
-
- SECTION text,code
-
- XDEF _subglue
-
- XREF _LinkerDB
- XREF _sub
-
- _subglue: move.l a4,-(a7)
- lea _LinkerDB,a4 ; [1]
- move.l d0,-(a7)
- move.l a0,-(a7)
- jsr _sub(pc)
- addq.l #8,a7
- move.l (a7)+,a4
- rts
-
- END
-
- Or something like that. Note that this may horrify the assembler
- crowd, but that's ok. :)
-
- [1] _LinkerDB is for SAS C, and this kills residentability. For
- DICE, it's:
-
- lea __ABSOLUTE_BAS+$7ffe,a4
-
- (a) It would be nice if the various compilers all used an
- equivalent name for this.
-
- (b) It would be even nicer if some field in the task structure
- was used as a standard location for a4, that callback
- routines could pick up a4 from without stuffing around
- with compiler specifics or far variables.
-
- Like... tc_UserData! Except applications might want to use
- it for something else.
- --
- *** John Bickers, TAP, NZAmigaUG. jbickers@templar.actrix.gen.nz ***
- *** "Radioactivity - It's in the air, for you and me" - Kraftwerk ***
-