home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 254b.lha / AMXLISP_v2.0 / interface-src / xlcall.a < prev   
Text File  |  1989-05-09  |  4KB  |  169 lines

  1.  
  2.    CSECT text
  3.  
  4. *_doit is called by callasm, with parameters
  5. * offset (int), base (int), lreg (NODE *), larg (NODE *)
  6. * according the Lattice Manual (v3.10) we have :
  7. * top of stack :.....
  8. *               offset  4(a7)
  9. *               base    8(a7)
  10. *               lreg
  11. *               larg
  12. * we must preserve d2-d7,a2-a7
  13. * and we will return some value in d0
  14.  
  15.  
  16.  
  17.       XDEF    _doit
  18. _doit
  19.    movem.l 4(a7),d0-d1/a0-a1      ;offset=d0,base=d1,lreg=a0,larg=a1
  20.    movem.l d2-d7/a2-a6,-(a7)   ;save C registers
  21.    movea.l d1,a6         ;put the library base in a6. a1 is now free
  22.    move.w d0,newjsr+2   ;code modification. this is bad!
  23.  
  24. * and now, let's examine the arguments (lreg in a0,larg in a1)
  25. resumeload
  26.    move.l a1,d0            ;(tst impossible with An) no more arguments
  27.    beq endargs
  28.    movea.l 2(a1),a4     ;car of larg in a4
  29.  
  30. * find wether it is a string (type 7) or an integer (type 5)
  31.    cmpi.b #5,(a4)
  32.    beq  caseinteger
  33.    cmpi.b #7,(a4)
  34.    beq  casestring
  35.    bra shitty             ; should always of these types
  36. caseinteger
  37.    move.l 2(a4),param   ;store the integer
  38.    bra findreg
  39. casestring
  40.    move.l 6(a4),param   ;store the (char *)
  41.  
  42. findreg
  43.    movea.l 2(a0),a4          ;car of lreg
  44.    move.l 2(a4),d0          ;integer value (no type-checking)
  45.    movea.l 6(a0),a0          ;forward in lreg.
  46.    movea.l 6(a1),a1          ;forward in larg.
  47.  
  48.    lsl.l  #2,d0             ;* 4 register's code
  49.    movea.l #tabreg,A4       ;table of calls addresses
  50.    movea.l 0(a4,d0.w),a4    ;indexing of register storage
  51.    jmp    (a4)              ;store value
  52.  
  53.  
  54. endargs
  55.    movea.l speciala4,a4
  56.    move.l  speciald0,d0
  57.    movea.l  speciala0,a0
  58.    movea.l  speciala1,a1
  59. *we now have all our registers updated
  60. newjsr
  61.    JSR 0(a6)            ;the offset will be hand-modified (dirty)
  62. *                        the result is usually in D0
  63.    movem.l (a7)+,d2-d7/a2-a6      ;restore c-registers
  64.    rts
  65.  
  66. * Loading parameters into registers.
  67.  
  68. * a0 is used in the loop as temporariry storage
  69. rega0
  70.    MOVE.L param,speciala0
  71.    BRA    resumeload
  72.  
  73. * a1 is used in the loop as temporariry storage
  74. rega1
  75.    MOVE.L param,speciala1
  76.    BRA    resumeload
  77.  
  78. rega2
  79.    MOVE.L param,A2
  80.    BRA    resumeload
  81.  
  82. rega3
  83.    MOVE.L param,a3
  84.    BRA    resumeload
  85.  
  86. * a4 is used in the loop as temporariry storage
  87. rega4
  88.    MOVE.L param,speciala4
  89.    BRA    resumeload
  90.  
  91. rega5
  92.    MOVE.L param,A5
  93.    BRA    resumeload
  94.  
  95. * the user is mad. A6 must be the library base
  96. rega6
  97.    BRA    shitty
  98.  
  99. * A7 is the stack pointer. how could you pass an argument there ??
  100. rega7
  101.    BRA    shitty
  102.  
  103. * d0 is used in the loop as temporariry storage
  104. regd0
  105.    MOVE.L param,speciald0
  106.    BRA    resumeload
  107.  
  108. regd1
  109.    MOVE.L param,d1
  110.    BRA    resumeload
  111.  
  112. regd2
  113.    MOVE.L param,d2
  114.    BRA    resumeload
  115.  
  116. regd3
  117.    MOVE.L param,D3
  118.    BRA    resumeload
  119.  
  120. regd4
  121.    MOVE.L param,D4
  122.    BRA    resumeload
  123.  
  124. regd5
  125.    MOVE.L param,D5
  126.    BRA    resumeload
  127.  
  128. regd6
  129.    MOVE.L param,D6
  130.    BRA    resumeload
  131.  
  132. regd7
  133.    MOVE.L param,d7
  134.    BRA    resumeload
  135.  
  136. *when some error occurred
  137. shitty
  138.    movem.l (a7)+,d2-d7/a2-a6      ;restore c-registers
  139.    move.l #'ERRR',d0
  140.    rts
  141.  
  142.  
  143.       CSECT data
  144. tabreg
  145.    DC.L    rega0          ;index : 0
  146.    DC.L    rega1
  147.    DC.L    rega2
  148.    DC.L    rega3
  149.    DC.L    rega4
  150.    DC.L    rega5
  151.    DC.L    rega6
  152.    DC.L    rega7
  153.    DC.L    regd0          ;index: 8
  154.    DC.L    regd1
  155.    DC.L    regd2
  156.    DC.L    regd3
  157.    DC.L    regd4
  158.    DC.L    regd5
  159.    DC.L    regd6
  160.    DC.L    regd7
  161.  
  162. param       DC.L 0
  163. speciala0   DC.L 0
  164. speciala1   DC.L 0
  165. speciala4   DC.L 0
  166. speciald0   DC.L 0
  167.  
  168.       END
  169.