home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / amiga / programm / 11747 < prev    next >
Encoding:
Internet Message Format  |  1992-07-28  |  2.7 KB

  1. Path: sparky!uunet!usc!wupost!waikato.ac.nz!comp.vuw.ac.nz!actrix!templar!jbickers
  2. Newsgroups: comp.sys.amiga.programmer
  3. Subject: Re: Registers from C
  4. Message-ID: <jbickers.0c9q@templar.actrix.gen.nz>
  5. From: jbickers@templar.actrix.gen.nz (John Bickers)
  6. Date: 29 Jul 92 09:19:34 PST
  7. References: <14q2h5INNoee@darkstar.UCSC.EDU> <paulk.0xau@terapin.com>
  8. Organization: TAP, NZAmigaUG
  9. Lines: 67
  10.  
  11. Quoted from <paulk.0xau@terapin.com> by paulk@terapin.com (Paul Kienitz):
  12. > > To quote the 2.0 RKM:Includes & Autodocs page 647 NP_Arguments entry:
  13.  
  14. > > Ok.  So, assuming the function is CreateNewProc()-ing correctly, how
  15. > > do I pull these arguments out of the registers from C.  I realize this
  16. > > is a probably a very simple thing to do, but I would really appreciate
  17. > > help from anyone with some experience.
  18.  
  19.     [Aztec stuff deleted]
  20.  
  21. > In SAS it's something vaguely like:
  22. >  
  23. >    long Sub_process_main(register __a0 char *argline,
  24. >                            register __d0 long arglen)
  25.  
  26.     long __saveds __asm sub(register __a0 char *argline,register __d0 long arglen);
  27.  
  28. > As for DICE, I dunno.
  29.  
  30.     __regargs __geta4 long sub(char *argline,long arglen);
  31.  
  32.     One problem is that this calls the routine "@sub", but when you
  33.     try and set pointers to the function, DICE uses "_sub", so you get
  34.     a link error. Or it did when I tried to use it for XPR callbacks.
  35.     There might be some compiler option to get around this.
  36.  
  37.     The most generic approach is to use assembler glue. For example:
  38.  
  39.                 SECTION text,code
  40.  
  41.                 XDEF    _subglue
  42.  
  43.                 XREF    _LinkerDB
  44.                 XREF    _sub
  45.  
  46.     _subglue:   move.l  a4,-(a7)
  47.                 lea     _LinkerDB,a4            ; [1]
  48.                 move.l  d0,-(a7)
  49.                 move.l  a0,-(a7)
  50.                 jsr     _sub(pc)
  51.                 addq.l  #8,a7
  52.                 move.l  (a7)+,a4
  53.                 rts
  54.  
  55.                 END
  56.  
  57.     Or something like that. Note that this may horrify the assembler
  58.     crowd, but that's ok. :)
  59.  
  60.     [1] _LinkerDB is for SAS C, and this kills residentability. For
  61.         DICE, it's:
  62.  
  63.                 lea     __ABSOLUTE_BAS+$7ffe,a4
  64.  
  65.         (a) It would be nice if the various compilers all used an
  66.             equivalent name for this.
  67.  
  68.         (b) It would be even nicer if some field in the task structure
  69.             was used as a standard location for a4, that callback
  70.             routines could pick up a4 from without stuffing around
  71.             with compiler specifics or far variables.
  72.  
  73.             Like... tc_UserData! Except applications might want to use
  74.             it for something else.
  75. --
  76. *** John Bickers, TAP, NZAmigaUG.        jbickers@templar.actrix.gen.nz ***
  77. ***    "Radioactivity - It's in the air, for you and me" - Kraftwerk    ***
  78.