home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI05.ARJ / ictari.05 / C / CLINK_MC / C_CALLS.MC / CCALLMC1.S < prev   
Text File  |  1997-09-18  |  1KB  |  44 lines

  1. * Machine code 68k source to be linked with C code
  2. * WRITTEN BY MORF for Ictari user group.
  3.  
  4.     CSECT    name,code        * Needed by Lattice assembler
  5.     XDEF        _MC1            * XternalDefinition of subroutine
  6.                         * Use an underscore in the assembler
  7.                         * but DON'T in the C source !!
  8.     
  9. * The machine code subroutine for CCALLA.C.
  10. * This routine is called BY the C code
  11.  
  12. _MC1
  13.     move.l    4(sp),value1    * get the passed parameters off the stack
  14.     move.l    8(sp),value2    * they are stored 32bits each in order. 
  15.     move.l    12(sp),value3    * the 1st 32bits is the return address (i think)
  16.                         * NB: V.IMPORTANT the stack must be in its
  17.                         * original state before returning !!
  18.                         * ie. as it is now including SP
  19.                         
  20.     movem.l    d2-d7/a2-a6,-(sp)        * store old registers
  21.                                 * NB: only d0-d1/a0-a1 can be
  22.                                 * trashed. C uses the others
  23.  
  24.     move.l    value1,d0        *add the numbers together in d0
  25.     move.l    value2,d1
  26.     add.l    d1,d0
  27.     move.l    value3,d1
  28.     add.l    d1,d0
  29.  
  30.     movem.l    (sp)+,d2-d7/a2-a6        * restore old registers
  31.                                 * I know i didn't use them !
  32.                                 * But I'm just saying you have
  33.                                 * to store them if you DID want
  34.                                 * to. <smile>
  35.  
  36.     rts        * stacks been restored with movem and ret value is in D0
  37.             * If you want to return a value then put it in D0 and rts
  38.             
  39. * variables section
  40.  
  41. value1    ds.l        1        * where the C passed parameters are stored
  42. value2    ds.l        1        * by this assembler code.
  43. value3    ds.l        1
  44.     end