home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / sinclairqlb.zip / ql2qtr.asm < prev    next >
Assembly Source File  |  1988-08-16  |  2KB  |  103 lines

  1. * access to qdos traps (1,2,and 3) for   BCPL
  2. *
  3. * Dr.A.J.Finch 27/5/87
  4. *  Physics Dept.,
  5. *   Lancaster University,
  6. *    Lancaster
  7. *
  8.        rorg  $0
  9. qtrap equ 276  this is the global to be assigned to this routine
  10. *                in global vector - alter kermain routine accordingly!
  11. * i.e. 
  12. * global $(
  13. * qtrap :  ug + 176
  14. * $)
  15. *
  16.  
  17. first dc.l  (endmod-first)/4
  18.  
  19.    cnop  0,4
  20.  
  21. label
  22.    BRA      start           
  23.    DC.B     'QTRAP'     THIS HELPS FOR DEBUGGING WITH C1 MONITOR!
  24.    CNOP      0,4
  25.  
  26. start      
  27.    movem.l  d0-d7/a0-a6,-(sp)  just to be safe !
  28. *    
  29. *set up registers for trap 
  30. *     
  31.    move.l   d1,d4           save trap   number
  32.    lsl.l #2,d2              bcpl address *4 for byte addresses
  33.    move.l   d2,a5           save address of input regs.     
  34.    lsl.l #2,d3              bcpl address *4 for byte addresses
  35.    move.l   d3,a6           save address of output regs.        
  36.      
  37. *
  38. * copy over input register
  39. *
  40.    move.l   0(a5),d0
  41.    move.l   4(a5),d1
  42.    move.l   8(a5),d2
  43.    move.l   12(a5),d3
  44.    move.l   16(a5),a0
  45.    move.l   20(a5),a1
  46.    move.l   24(a5),a2
  47.    move.l   28(a5),a3
  48. *
  49. * just in case  - save register needed to  return values
  50. *                   of output registers
  51. *    
  52.    move.l  a6,-(sp)
  53.      
  54.    cmpi.w   #1,d4 
  55.    beq      trap1
  56.    cmpi.w   #2,d4
  57.    beq      trap2
  58.    cmpi.w   #3,d4   
  59.    beq      trap3
  60.    bra      endtrap
  61.    
  62. trap1 trap  #1  
  63.       bra   endtrap 
  64. trap2 trap  #2  
  65.       bra   endtrap
  66. trap3 trap  #3  
  67. endtrap
  68. *
  69. * return registers
  70. *     
  71.    move.l  (sp)+,a6  restore address of output vector
  72. *
  73. * and copy over registers
  74. *
  75.    move.l   d0,0(a6)  
  76.    move.l   d1,4(a6)
  77.    move.l   d2,8(a6) 
  78.    move.l   d3,12(a6) 
  79.    move.l   a0,16(a6)
  80.    move.l   a1,20(a6)
  81.    move.l   a2,24(a6)
  82.    move.l   a3,28(a6)
  83.      
  84. *
  85. * restore previously saved registers
  86. *
  87.    movem.l  (sp)+,d0-d7/a0-a6
  88. *
  89. * and finally return to bcpl
  90. *      
  91.    jmp   (a6)
  92. *      
  93. *
  94. * globals
  95. *    
  96.    cnop  0,4
  97.    dc.l  0 
  98.    dc.l  qtrap,(label-first)
  99.    dc.  qtrap
  100.       
  101. endmod  end     
  102.