home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Emulatoren / AMORICV0.LHA / AmoricV0_8b / src / runtime_020.asm < prev    next >
Encoding:
Assembly Source File  |  1995-10-14  |  4.4 KB  |  233 lines

  1. ; *** ORIC Emulator. Amiga Version 680x0 ***
  2. ; *** Copyright 1995/96 JF FABRE ***
  3. ; *** Main program ***
  4.  
  5. ; d1.b : A
  6. ; d2.b : X
  7. ; d3.b : Y
  8. ; d4.b : P
  9. ; d5.b : S
  10. ; D6   : **scratch**
  11. ; D7   : **scratch**
  12.  
  13. ; a0.l : Mem Ptr
  14. ; a1.l : Mem Ptr + $304
  15. ; a2.l : Functable pour les instructions
  16. ; a3.l : Pointeur sur diverses tables
  17. ; a4.l : PC+Base Adr
  18. ; a5.l : Retour apres traitement d'instruction
  19. ; a6.l : **Scratch**
  20.  
  21.     MACHINE    68020
  22.  
  23.         XDEF    _RunOric        ; C
  24.         XDEF    _ReturnToMonitor
  25.     XDEF    _StepOric        ; C
  26.     XDEF    _HandleCtrl
  27.     XDEF    _MainLoop
  28.     XDEF    _MainLoopReload
  29.  
  30.     XDEF    _BreakReason
  31.                
  32.         XREF    _InitKbTableOnce
  33.     XREF    _InitKbTable
  34.     XREF    _InitFonctions
  35.         XREF    _IRQ
  36.         XREF    _RegistersToMem
  37.         XREF    _MemToRegisters
  38.     XREF    _RefreshScreen
  39.     XREF    _RewindTapeLoadAsm
  40.     XREF    _GotoTextMode
  41.  
  42.     XREF    _RefreshScr
  43.     XREF    _ShowHelp
  44.  
  45.     XREF    _CtrlKeyPressed
  46.  
  47.     XREF    _NextJump
  48.  
  49.     XREF    _UserLoadT1
  50.     XREF    _UserLoadT2
  51.  
  52.         XREF    _M
  53.         XREF    _A
  54.         XREF    _X
  55.         XREF    _Y
  56.         XREF    _S
  57.         XREF    _P
  58.         XREF    _PC
  59.  
  60. NB_CYCLE = 4
  61.    
  62.         include "my_defs.i"
  63.     include    "libs.i"
  64.     include    "my_macros.asm"
  65.  
  66.         
  67. ; *** Programme principal ***
  68.  
  69.     
  70. _RunOric:            ; Point d'entree du C
  71. @RunOric:
  72.         STORE_REGS
  73.     move.l    AbsExecbase,A6
  74.     CALLLIB    _LVOForbid
  75.         jsr     _MemToRegisters
  76. _MainLoopReload:
  77.     move.l    #_MainLoop,_NextJump
  78. _MainLoop:
  79.     ;*** Horloge Timer 1
  80.  
  81. Timer1:
  82.     subq.b    #NB_CYCLE,(A1)    ; 3 = Nb de Cycles moyen par instruction
  83.     bcs.b    Dec305
  84. Timer2:
  85.     subq.b    #NB_CYCLE,4(A1)        ; 4 = Nb de Cycles moyen par instruction
  86.     bcs.b    Dec309
  87.  
  88. ProcessInst:
  89.     moveq.l    #0,D6
  90.     move.b    (A4)+,D6    ; Incrementation de 1 de A4 = PC++    
  91.     move.l    (A2,D6.W*4),A6
  92.     jmp    (A6)
  93.  
  94. InvertPB7:
  95.     bchg    #7,-4(A1)
  96.     bra.b    T1Int_Suite
  97.  
  98. Dec305:
  99.     DEC_TxH    1
  100.     subq.b    #1,1(A1)
  101.     bne.b    Timer2
  102.  
  103. T1Int:
  104.     RELOAD_TIMER1        ; Rechargement des cellules
  105.  
  106.     btst    #6,$7(A1)    ; Test du bit 6 de $30B -> Si 1 : Interruptions Continues
  107.     bne.b    T1DoInt        ; Si 0 : Interruptions uniquement lors d'un load
  108.  
  109.     btst    #7,$7(A1)    ; Test du bit 7 de $30B -> Si 1 : Inversion de PB7
  110.     bne.b    InvertPB7
  111. T1Int_Suite:
  112.     tst.b    _UserLoadT1
  113.     beq.b    Timer2
  114.     clr.b    _UserLoadT1
  115.  
  116. T1DoInt:
  117.  
  118.     bset    #6,$9(A1)    ; Met le bit 6 de $30D a 1
  119.     move.b    $A(A1),D6    ; $30E
  120.     bpl.b    Timer2        ; bit 7 de 0x30E
  121.     and.b    $9(A1),D6    ; Test $30D avec $30E
  122.     beq.b    Timer2
  123.     TST_PB    I_BIT
  124.     bne.b    Timer2        ; Interruptions masquees : Ne fait rien
  125.     CLR_PB    B_BIT
  126.     jmp    _IRQ        ; Saut a l'interruption IRQ
  127.  
  128.  
  129. Dec309:
  130.     DEC_TxH    2
  131.     subq.b    #1,5(A1)
  132.     bne.b    ProcessInst
  133.  
  134. T2Int:
  135. ;****    move.w    #$FFFF,4(A1)
  136.     btst    #5,$9(A1)
  137.     bne.b    ProcessInst    ; Countdown pulse pas implĂ©mentĂ©
  138.     tst.b    _UserLoadT2
  139.     beq.b    ProcessInst
  140.     clr.b    _UserLoadT2
  141.  
  142.     bset    #5,$9(A1)    ; Met le bit 5 de $30D a 1
  143.     move.b    $A(A1),D6    ; $30E
  144.     bpl.b    ProcessInst    ; bit 7 de 0x30E = 0 -> Pas d'IT
  145.     and.b    $9(A1),D6    ; Test $30D avec $30E
  146.     beq.b    ProcessInst
  147.     TST_PB    I_BIT
  148.     bne.b    ProcessInst    ; Interruptions masquees : Ne fait rien
  149.     CLR_PB    B_BIT
  150.     jmp    _IRQ        ; Saut a l'interruption IRQ
  151.     
  152.  
  153. _StepOric:            ; Point d'entree du C
  154.     STORE_REGS
  155.     jsr    _MemToRegisters
  156.     move.l    #_ReturnToMonitor,_NextJump
  157.     move.b    #STEP_COMMAND,_BreakReason
  158.     bra    _MainLoop    ; Ensuite, ca reviendra a _ReturnToMonitor
  159.  
  160.  
  161. _ReturnToMonitor:    
  162.     
  163.     jsr    _RegistersToMem
  164.     RESTORE_REGS
  165.         
  166.     moveq.l    #0,D0
  167.         move.b  _BreakReason(PC),D0
  168.     move.l    AbsExecbase,A6
  169.     CALLLIB    _LVOPermit
  170.         rts     ; Retour au C (moniteur)
  171.         
  172. BreakReq:
  173.     move.b    #USER_BREAK,_BreakReason
  174.     bra.b    _ReturnToMonitor
  175.  
  176. ChtLoad:
  177.     move.b    #CHANGE_TAPE,_BreakReason
  178.     bra.b    _ReturnToMonitor
  179.  
  180. _HandleCtrl:
  181.     move.b    _CtrlKeyPressed,D6
  182.     clr.b    _CtrlKeyPressed
  183.     andi.w    #$FF,D6
  184.     subq.w    #1,D6
  185.     lea    ControlTable(PC),A6
  186.     move.l    (A6,D6.W*4),A6
  187.     jmp    (A6)
  188.  
  189. WarmReset:
  190.     jsr    _InitKbTable
  191.     clr.b    -4(A1)    ; Port B a 0
  192.     moveq.l    #0,D6
  193.     moveq.l    #0,D6
  194.     move.w    #$FFFA,D6
  195.     move.b    1(A0,D6.L),D0
  196.     lsl.w    #8,D0
  197.     move.b    (A0,D6.L),D0
  198.     move.l    A0,A4
  199.     add.l    D0,A4
  200.     bra    _MainLoopReload
  201.  
  202. ColdReset:
  203.     jsr    _InitKbTable
  204.     clr.b    -4(A1)
  205.     moveq.l    #4,D4    ; Interrupts off
  206.     moveq.l    #0,D6
  207.     moveq.l    #0,D0
  208.     move.w    #$FFFC,D6
  209.     move.b    1(A0,D6.L),D0
  210.     lsl.w    #8,D0
  211.     move.b    (A0,D6.L),D0
  212.     move.l    A0,A4
  213.     add.l    D0,A4
  214.     jsr    _GotoTextMode
  215.     bra    _MainLoopReload
  216.  
  217.  
  218. HotRewind:
  219.     jsr    _RewindTapeLoadAsm
  220.     bra    _MainLoopReload
  221.     
  222.  
  223. _BreakReason:
  224.     dc.b    0
  225.     even
  226.  
  227. ControlTable:
  228.     dc.l    WarmReset,_RefreshScr,ChtLoad,_MainLoopReload,ColdReset
  229.     dc.l    _MainLoopReload,HotRewind,_MainLoopReload,_MainLoopReload,BreakReq
  230.     dc.l    _MainLoopReload,_MainLoopReload,_MainLoopReload
  231.     dc.l    _MainLoopReload,_MainLoopReload,_ShowHelp
  232.  
  233.