]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avr/Z80int-jmp.asm
* avr/Z80int-jmp.asm
[avrcpm.git] / avr / Z80int-jmp.asm
index 01a877f2af8bcafbe3b59981792236855b1054e2..6641a924dd2669f98748e0eef78b9e64ad0127e5 100644 (file)
@@ -25,7 +25,7 @@
 ;
 
 #if EM_Z80
-  #define OPC_TABSTART 0x1a00
+  #define OPC_TABSTART 0x1900
 #else
   #define OPC_TABSTART 0x1200
 #endif
@@ -200,51 +200,63 @@ int_nobreak:
 ;
 .macro instr   
 
-  .set fetch_ = (do_@0 != do_fetch_nop)                ; must call or jump to fetch phase
-  .set op_    = (do_@1 != do_op_nop)           ; must call or jump to op phase
-  .set store_ = (do_@2 != do_store_nop)                ; must jump to store phase
-  .set cnt_ = fetch_ + op_ + store_
+  .set fetch_ = (do_@0 != do_fetch_nop)                ; must call or jump to fetch action
+  .set op_    = (do_@1 != do_op_nop)           ; must call or jump to op action
+  .set store_ = (do_@2 != do_store_nop)                ; must jump to store action
+  .set cnt_ = fetch_ + op_ + store_            ; number of actions for this instruction
+
+  .set action_1_ = 0
+  .set action_2_ = 0
+  .set action_3_ = 0
+
+  .if cnt_ == 1
+    .if fetch_
+      .set action_1_ = do_@0
+    .elif op_
+      .set action_1_ = do_@1
+    .else
+      .set action_1_ = do_@2
+    .endif
+  .elif cnt_ == 2
+    .if fetch_
+      .set action_1_ = do_@0
+      .if op_
+        .set action_2_ = do_@1
+      .else
+        .set action_2_ = do_@2
+      .endif
+    .else
+      .set action_1_ = do_@1
+      .set action_2_ = do_@2
+    .endif
+  .elif cnt_ == 3
+    .set action_1_ = do_@0
+    .set action_2_ = do_@1
+    .set action_3_ = do_@2
+  .endif
+
   .set longdist_ = 0
   .set pc_save_ = PC
 
   .org opcjmp_table_pos_
   .set opcjmp_table_pos_ = opcjmp_table_pos_ + 1
 
+
   .if cnt_ == 0                                        ; nothing to do (nop)
     ret                                                ; go back to main
   .elif cnt_ == 1                              ; jump direct to action
-    .if fetch_                                 ; 
-      .if (PC - do_@0) > 2047
-       .set longdist_ = 1
-      .else
-        rjmp do_@0                             ; do op and return to main
-      .endif
-    .endif    
-    .if op_
-      .if (PC - do_@1) > 2047
-       .set longdist_ = 1
-      .else
-        rjmp do_@1                             ; do op and return to main
-      .endif
-    .endif    
-    .if store_                                 ; 
-      .if (PC - do_@2) > 2047
-       .set longdist_ = 1
-      .else
-        rjmp do_@2                             ; do op and return to main
-      .endif
-    .endif    
+    .if (PC - action_1_) > 2047
+      .set longdist_ = 1                        ; target action out of reach for rel jump
+    .else
+        rjmp action_1_                         ; do op and return to main
+    .endif
   .endif
 
+
   .set done_ = 0
   .if (cnt_ > 1) || longdist_
-
-    .set labelexists_ = 0
-    .if defined (l_@0_@1_@2)
-      .set labelexists_ = 1
-    .endif
                                                ; two or tree actions
-    .if labelexists_                           ; same combination of fetch/op/store allready present?
+    .if defined (l_@0_@1_@2)
       .if (PC - l_@0_@1_@2) <= 2047
         rjmp l_@0_@1_@2                                ; generate a jump to action table
        .set done_ = 1
@@ -266,7 +278,7 @@ int_nobreak:
         .endif
       .endif
 
-      .if labelexists_
+      .if defined (l_@0_@1_@2)
         rjmp todo_table_pos_
         .org todo_table_pos_
        jmp l_@0_@1_@2
@@ -994,63 +1006,97 @@ do_op_ina:                               ; in a,(opl)
 ;|INC r     |**-P0-|Increment            |r=r+1                 |
 ;|INC [HL]  |**-P0-|Increment            |[HL]=[HL]+1           |
 ;
-; 
+
 do_op_inc:
+       andi    z_flags,(1<<ZFL_C)              ; preserve C-flag
        ldi     temp,1
        add     opl,temp
-       in      temp, sreg
-       andi    z_flags,(1<<ZFL_C)              ; preserve C-flag
-       ldpmx   temp2, sz53p_tab, opl
-       or      z_flags,temp2                   ;
-       bmov    z_flags, ZFL_H, temp, AVR_H
-       do_z80_flags_V
+#if EM_Z80
+       brpl    PC+2
+        sbr    z_flags,(1<<ZFL_S)
+       brne    PC+2
+        sbr    z_flags,(1<<ZFL_Z)
+       brhc    PC+2
+        sbr    z_flags,(1<<ZFL_H)
+       brvc    PC+2
+        sbr    z_flags,(1<<ZFL_P)
+#else /* 8080 */
+       ldpmx   temp,sz53p_tab,opl              ;S,Z,P flag
+       or      z_flags,temp
+#endif
        ret
 
 do_op_inca:
+       andi    z_flags,(1<<ZFL_C)              ; preserve C-flag
        ldi     temp,1
        add     z_a,temp
-       in      temp, sreg
-       andi    z_flags,(1<<ZFL_C)              ; preserve C-flag
-       ldpmx   temp2, sz53p_tab, z_a
-       or      z_flags,temp2                   ;
-       bmov    z_flags, ZFL_H, temp, AVR_H
-       do_z80_flags_V
+#if EM_Z80
+       brpl    PC+2
+        sbr    z_flags,(1<<ZFL_S)
+       brne    PC+2
+        sbr    z_flags,(1<<ZFL_Z)
+       brhc    PC+2
+        sbr    z_flags,(1<<ZFL_H)
+       brvc    PC+2
+        sbr    z_flags,(1<<ZFL_P)
+#else /* 8080 */
+       ldpmx   temp,sz53p_tab,opl              ;S,Z,P flag
+       or      z_flags,temp
+#endif
        ret
 
 ;----------------------------------------------------------------
 ;|Mnemonic  |SZHPNC|Description          |Notes                 |
 ;----------------------------------------------------------------
 ;|DEC r     |***V1-|Decrement            |s=s-1                 |
-;|INC [HL]  |***V0-|Increment            |[HL]=[HL]+1           |
-;|INC [xx+d]|***V0-|Increment            |[xx+d]=[xx+d]+1       |
+;|DEC [HL]  |***V0-|Increment            |[HL]=[HL]-1           |
+;|DEC [xx+d]|***V0-|Increment            |[xx+d]=[xx+d]-1       |
 ;|----------|SZHP C|---------- 8080 ----------------------------|
-;|DEC r     |**-P -|Increment            |r=r+1                 |
-;|DEC [HL]  |**-P -|Increment            |[HL]=[HL]+1           |
-;
+;|DEC r     |**-P -|Increment            |r=r-1                 |
+;|DEC [HL]  |**-P -|Increment            |[HL]=[HL]-1           |
 ;
+
 do_op_dec:
-       subi    opl,1
-       in    temp, sreg
        andi    z_flags,(1<<ZFL_C)              ; preserve C-flag
-       ldpmx   temp2, sz53p_tab, opl
-       or      z_flags,temp2           ;
-       bmov    z_flags, ZFL_H, temp, AVR_H
-       do_z80_flags_V
-       do_z80_flags_set_N
+       subi    opl,1
+#if EM_Z80
+       brpl    PC+2
+        sbr    z_flags,(1<<ZFL_S)
+       brne    PC+2
+        sbr    z_flags,(1<<ZFL_Z)
+       brhc    PC+2
+        sbr    z_flags,(1<<ZFL_H)
+       brvc    PC+2
+        sbr    z_flags,(1<<ZFL_P)
+       ori     z_flags,(1<<ZFL_N)              ; Set N-flag
+#else /* 8080 */
+       ldpmx   temp,sz53p_tab,opl              ; S,Z,P flag
+       or      z_flags,temp
+#endif
        ret
 
+
 do_op_deca:
-       ldi     opl,1
-       sub     z_a,opl
-       in    temp, sreg
        andi    z_flags,(1<<ZFL_C)              ; preserve C-flag
-       ldpmx   temp2, sz53p_tab, z_a
-       or      z_flags,temp2           ;
-       bmov    z_flags, ZFL_H, temp, AVR_H
-       do_z80_flags_V
-       do_z80_flags_set_N
+       ldi     temp,1
+#if EM_Z80
+       sub     z_a,temp
+       brpl    PC+2
+        sbr    z_flags,(1<<ZFL_S)
+       brne    PC+2
+        sbr    z_flags,(1<<ZFL_Z)
+       brhc    PC+2
+        sbr    z_flags,(1<<ZFL_H)
+       brvc    PC+2
+        sbr    z_flags,(1<<ZFL_P)
+       ori     z_flags,(1<<ZFL_N)              ; Set N-flag
+#else /* 8080 */
+       ldpmx   temp,sz53p_tab,opl              ; S,Z,P flag
+       or      z_flags,temp
+#endif
        ret
 
+
 ;----------------------------------------------------------------
 ;|Mnemonic  |SZHPNC|Description          |Notes                 |
 ;----------------------------------------------------------------
@@ -1405,7 +1451,7 @@ do_op_rmem8:
 
 #if 1
 
-do_op_da:
+do_op_daa:
 
 #if EM_Z80
        sbrc    z_flags,ZFL_N                   ;if add-op      
@@ -1445,7 +1491,7 @@ op_da_a13:                                        ;
 #if EM_Z80
 
 op_da_sub:                                     ;else (sub-op)
-       rcall do_op_inv                         ;  TODO: ! Z80 DAA whith N flag set.
+       rjmp    op_da_add                       ;  TODO: ! Z80 DAA whith N flag set.
        ret                                     ;endif
 #endif
 
@@ -1935,7 +1981,7 @@ instr     fetch_HL,       op_INC16,       store_HL        ;23             ;INC HL
 instr  fetch_H,        op_INC,         store_H         ;24             ;INC H
 instr  fetch_H,        op_DEC,         store_H         ;25             ;DEC H
 instr  fetch_DIR8,     op_nop,         store_H         ;26 nn          ;LD H,n
-instr  fetch_A,        op_DA         store_A         ;27             ;DAA
+instr  fetch_A,        op_DAA,         store_A         ;27             ;DAA
 instr  fetch_DIR8,     op_IFZ,         store_pcrel     ;28 oo          ;JR Z,o
 instr  fetch_HL,       op_ADDHL,       store_nop       ;29             ;ADD HL,HL
 instr  fetch_DIR16,    op_RMEM16,      store_HL        ;2A nn nn       ;LD HL,(nn)
@@ -2630,101 +2676,56 @@ opadx_e:
 ;|LDIR      |--000-|Load, Inc., Repeat   |LDI till BC=0         |
 ;
 
-do_op_LDD:
-       ldd     oph,y+oz_b              ;B
-       ldd     opl,y+oz_c              ;C
-       ldd     xh,y+oz_d               ;D
-       ldd     xl,y+oz_e               ;E
+op_LDxx_common:
        ldd     zh,y+oz_h               ;H
        ldd     zl,y+oz_l               ;L
-       mem_read_ds temp, z
-       sbiw    z,1
-       mem_write_ds x, temp
-       sbiw    x,1
-       cbr     z_flags,(1<<ZFL_H) | (1<<ZFL_P) | (1<<ZFL_N)
-       subi    opl,1
-       sbci    oph,0
-       breq    PC+2
-        sbr    z_flags,(1<<ZFL_P)
-       std     y+oz_l,zl               ;L
-       std     y+oz_h,zh               ;H
-       std     y+oz_e,xl               ;E
-       std     y+oz_d,xh               ;D
-       std     y+oz_c,opl              ;C
-       std     y+oz_b,oph              ;B
-       ret
-
-
-do_op_LDDR:
-       ldd     oph,y+oz_b              ;B
-       ldd     opl,y+oz_c              ;C
        ldd     xh,y+oz_d               ;D
        ldd     xl,y+oz_e               ;E
-       ldd     zh,y+oz_h               ;H
-       ldd     zl,y+oz_l               ;L
-oplddr_l:
-       mem_read_ds temp, z
-       sbiw    z,1
-       mem_write_ds x, temp
-       sbiw    x,1
-       subi    opl,1
-       sbci    oph,0
-       brne    oplddr_l
-       std     y+oz_l,zl               ;L
-       std     y+oz_h,zh               ;H
-       std     y+oz_e,xl               ;E
-       std     y+oz_d,xh               ;D
-       std     y+oz_c,opl              ;C
-       std     y+oz_b,oph              ;B
-       cbr     z_flags,(1<<ZFL_H) | (1<<ZFL_P) | (1<<ZFL_N)
-       ret
-
-do_op_LDI:
        ldd     oph,y+oz_b              ;B
        ldd     opl,y+oz_c              ;C
-       ldd     xh,y+oz_d               ;D
-       ldd     xl,y+oz_e               ;E
-       ldd     zh,y+oz_h               ;H
-       ldd     zl,y+oz_l               ;L
        mem_read_ds temp, z
-       adiw    z,1
        mem_write_ds x, temp
-       adiw    x,1
        cbr     z_flags,(1<<ZFL_H) | (1<<ZFL_P) | (1<<ZFL_N)
        subi    opl,1
        sbci    oph,0
        breq    PC+2
         sbr    z_flags,(1<<ZFL_P)
-       std     y+oz_l,zl               ;L
-       std     y+oz_h,zh               ;H
-       std     y+oz_e,xl               ;E
-       std     y+oz_d,xh               ;D
        std     y+oz_c,opl              ;C
        std     y+oz_b,oph              ;B
        ret
 
-do_op_LDIR:
-       ldd     oph,y+oz_b              ;B
-       ldd     opl,y+oz_c              ;C
-       ldd     xh,y+oz_d               ;D
-       ldd     xl,y+oz_e               ;E
-       ldd     zh,y+oz_h               ;H
-       ldd     zl,y+oz_l               ;L
-opldir_l:
-       mem_read_ds temp, z
+do_op_LDI:
+       rcall   op_LDxx_common
        adiw    z,1
-       mem_write_ds x, temp
        adiw    x,1
-       subi    opl,1
-       sbci    oph,0
-       brne    opldir_l
+       std     y+oz_e,xl               ;E
+       std     y+oz_d,xh               ;D
        std     y+oz_l,zl               ;L
        std     y+oz_h,zh               ;H
+       ret
+
+do_op_LDD:
+       rcall   op_LDxx_common
+       sbiw    z,1
+       sbiw    x,1
        std     y+oz_e,xl               ;E
        std     y+oz_d,xh               ;D
-       std     y+oz_c,opl              ;C
-       std     y+oz_b,oph              ;B
-       cbr     z_flags,(1<<ZFL_H) | (1<<ZFL_P) | (1<<ZFL_N)
+       std     y+oz_l,zl               ;L
+       std     y+oz_h,zh               ;H
+       ret
+
+do_op_LDIR:
+       rcall   do_op_LDI
+       sbrs    z_flags,ZFL_P
+        ret
+       sbiw    z_pcl,2
+       ret
+
+do_op_LDDR:
+       rcall   do_op_LDD
+       sbrs    z_flags,ZFL_P
+        ret
+       sbiw    z_pcl,2
        ret
 
 ;----------------------------------------------------------------
@@ -2736,61 +2737,165 @@ opldir_l:
 ;|CPIR      |****1-|Compare, Inc., Repeat|CPI till A=[HL]or BC=0|
 
 
+op_CPxx_common:
+       ldd     xh,y+oz_h               ; H
+       ldd     xl,y+oz_l               ; L
+       ldd     zh,y+oz_b               ; B
+       ldd     zl,y+oz_c               ; C
+
+       cbr     z_flags,(1<<ZFL_S)|(1<<ZFL_Z)|(1<<ZFL_H)|(1<<ZFL_P)
+       sbr     z_flags,(1<<ZFL_N)
+       mem_read                        ; temp = (HL)
+       mov     temp2,z_a
+       sub     temp2,temp              ; A - (HL)
+       brpl    PC+2
+        sbr    z_flags,(1<<ZFL_S)
+       brne    PC+2
+        sbr    z_flags,(1<<ZFL_Z)
+       brhc    PC+2
+        sbr    z_flags,(1<<ZFL_H)
+
+       sbiw    z,1                     ; BC--
+       breq    PC+2
+        sbr    z_flags,(1<<ZFL_P)
+       std     y+oz_c,zl               ; C
+       std     y+oz_b,zh               ; B
+       ret
+
 do_op_CPI:
+       rcall   op_CPxx_common
+       adiw    x,1                     ; HL++
+       std     y+oz_l,xl               ; L
+       std     y+oz_h,xh               ; H
+       ret
+
+
+do_op_CPD:
+       rcall   op_CPxx_common
+       sbiw    x,1                     ; HL--
+       std     y+oz_l,xl               ; L
+       std     y+oz_h,xh               ; H
+       ret
+
+do_op_CPIR:
+       rcall   do_op_CPI
+       sbrc    z_flags,ZFL_Z
+        ret
+       sbrs    z_flags,ZFL_P
+        ret
+       sbiw    z_pcl,2
+       ret
+
+do_op_CPDR:
+       rcall   do_op_CPD
+       sbrc    z_flags,ZFL_Z
+        ret
+       sbrs    z_flags,ZFL_P
+        ret
+       sbiw    z_pcl,2
+       ret
+
+;----------------------------------------------------------------
+;|Mnemonic  |SZHPNC|Description          |Notes                 |
+;----------------------------------------------------------------
+;|INI       |?*??1-|Input and Increment  |[HL]=[C],HL=HL+1,B=B-1|
+;|IND       |?*??1-|Input and Decrement  |[HL]=[C],HL=HL-1,B=B-1|
+;|INIR      |?1??1-|Input, Inc., Repeat  |INI till B=0          |
+;|INDR      |?1??1-|Input, Dec., Repeat  |IND till B=0          |
+
+op_INxx_common:
+       cbr     z_flags,(1<<ZFL_Z)
+       sbr     z_flags,(1<<ZFL_N)
+       ldd     temp2,y+oz_c            ;C
+       lcall   portRead
        ldd     xh,y+oz_h               ;H
        ldd     xl,y+oz_l               ;L
-       ldd     zh,y+oz_b               ;B
-       ldd     zl,y+oz_c               ;C
-       push    zh
-       push    zl
-       mem_read_ds opl, x
-       lcall   do_op_cpfa
-       pop     zl
-       pop     zh
+       lcall   dram_write
+       ldd     temp,y+oz_b             ;B
+       dec     temp
+       std     y+oz_b,oph              ;B
+       brne    PC+2
+        sbr    z_flags,(1<<ZFL_Z)
+       ret
+
+do_op_INI:
+       rcall   op_INxx_common
        adiw    x,1
-       sbiw    z,1
-       breq    PC+2
-        sbr    z_flags,(1<<ZFL_P)
-       std     y+oz_c,zl               ;C
-       std     y+oz_b,zh               ;B
        std     y+oz_l,xl               ;L
        std     y+oz_h,xh               ;H
        ret
 
-do_op_CPD:
-       ldd     xh,y+oz_h               ;H
-       ldd     xl,y+oz_l               ;L
-       ldd     zh,y+oz_b               ;B
-       ldd     zl,y+oz_c               ;C
-       push    zh
-       push    zl
-       mem_read_ds opl, x
-       lcall   do_op_cpfa
-       pop     zl
-       pop     zh
+do_op_IND:
+       rcall   op_INxx_common
        sbiw    x,1
-       sbiw    z,1
-       breq    PC+2
-        sbr    z_flags,(1<<ZFL_P)
-       std     y+oz_c,zl               ;C
-       std     y+oz_b,zh               ;B
        std     y+oz_l,xl               ;L
        std     y+oz_h,xh               ;H
        ret
 
-do_op_CPIR:
-       rcall   do_op_CPI
+do_op_INIR:
+       rcall   do_op_INI
        sbrc    z_flags,ZFL_Z
         ret
+       sbiw    z_pcl,2
+       ret
+
+do_op_INDR:
+       rcall   do_op_IND
        sbrs    z_flags,ZFL_P
         ret
        sbiw    z_pcl,2
        ret
 
-do_op_CPDR:
-       rcall   do_op_CPD
+;----------------------------------------------------------------
+;|Mnemonic  |SZHPNC|Description          |Notes                 |
+;----------------------------------------------------------------
+;|OUTI      |?*??1-|Output and Increment |[C]=[HL],HL=HL+1,B=B-1|
+;|OUTD      |?*??1-|Output and Decrement |[C]=[HL],HL=HL-1,B=B-1|
+;|OTIR      |?1??1-|Output, Inc., Repeat |OUTI till B=0         |
+;|OTDR      |?1??1-|Output, Dec., Repeat |OUTD till B=0         |
+
+op_OUTxx_common:
+       cbr     z_flags,(1<<ZFL_Z)
+       sbr     z_flags,(1<<ZFL_N)
+       lcall   dram_read               ;temp = (z)
+       ldd     temp2,y+oz_c            ;C
+       lcall   portWrite
+       ldd     temp,y+oz_b             ;B
+       dec     temp
+       std     y+oz_b,temp             ;B
+       brne    PC+2
+        sbr    z_flags,(1<<ZFL_Z)
+       ret
+
+do_op_OUTI:
+       ldd     xh,y+oz_h               ;H
+       ldd     xl,y+oz_l               ;L
+       adiw    x,1
+       std     y+oz_l,xl               ;L
+       std     y+oz_h,xh               ;H
+       sbiw    x,1
+       rcall   op_OUTxx_common
+       ret
+
+do_op_OUTD:
+       ldd     xh,y+oz_h               ;H
+       ldd     xl,y+oz_l               ;L
+       sbiw    x,1
+       std     y+oz_l,xl               ;L
+       std     y+oz_h,xh               ;H
+       adiw    x,1
+       rcall   op_OUTxx_common
+       ret
+
+do_op_OTIR:
+       rcall   do_op_OUTI
        sbrc    z_flags,ZFL_Z
         ret
+       sbiw    z_pcl,2
+       ret
+
+do_op_OTDR:
+       rcall   do_op_OUTD
        sbrs    z_flags,ZFL_P
         ret
        sbiw    z_pcl,2
@@ -3203,32 +3308,32 @@ instr   fetch_nop,      op_nop,         store_nop       ;9E             ;NOP
 instr  fetch_nop,      op_nop,         store_nop       ;9F             ;NOP
 instr  fetch_nop,      op_LDI,         store_nop       ;A0             ;LDI
 instr  fetch_nop,      op_CPI,         store_nop       ;A1             ;CPI
-instr  fetch_nop,      op_nop,         store_nop       ;A2             ;   TODO:
-instr  fetch_nop,      op_nop,         store_nop       ;A3             ;
+instr  fetch_nop,      op_INI,         store_nop       ;A2             ;INI
+instr  fetch_nop,      op_OUTI,        store_nop       ;A3             ;OUTI
 instr  fetch_nop,      op_nop,         store_nop       ;A4             ;NOP
 instr  fetch_nop,      op_nop,         store_nop       ;A5             ;NOP
 instr  fetch_nop,      op_nop,         store_nop       ;A6             ;NOP
 instr  fetch_nop,      op_nop,         store_nop       ;A7             ;NOP
 instr  fetch_nop,      op_LDD,         store_nop       ;A8             ;LDD
 instr  fetch_nop,      op_CPD,         store_nop       ;A9             ;CPD
-instr  fetch_nop,      op_nop,         store_nop       ;AA             ;    TODO:
-instr  fetch_nop,      op_nop,         store_nop       ;AB             ;
+instr  fetch_nop,      op_IND,         store_nop       ;AA             ;IND
+instr  fetch_nop,      op_OUTD,        store_nop       ;AB             ;OUTD
 instr  fetch_nop,      op_nop,         store_nop       ;AC             ;NOP
 instr  fetch_nop,      op_nop,         store_nop       ;AD             ;NOP
 instr  fetch_nop,      op_nop,         store_nop       ;AE             ;NOP
 instr  fetch_nop,      op_nop,         store_nop       ;AF             ;NOP
 instr  fetch_nop,      op_LDIR,        store_nop       ;B0             ;LDIR
 instr  fetch_nop,      op_CPIR,        store_nop       ;B1             ;CPIR
-instr  fetch_nop,      op_nop,         store_nop       ;B2             ;
-instr  fetch_nop,      op_nop,         store_nop       ;B3             ;   TODO:
+instr  fetch_nop,      op_INIR,        store_nop       ;B2             ;INIR
+instr  fetch_nop,      op_OTIR,        store_nop       ;B3             ;OTIR
 instr  fetch_nop,      op_nop,         store_nop       ;B4             ;NOP
 instr  fetch_nop,      op_nop,         store_nop       ;B5             ;NOP
 instr  fetch_nop,      op_nop,         store_nop       ;B6             ;NOP
 instr  fetch_nop,      op_nop,         store_nop       ;B7             ;NOP
 instr  fetch_nop,      op_LDDR,        store_nop       ;B8             ;LDDR
 instr  fetch_nop,      op_CPDR,        store_nop       ;B9             ;CPDR
-instr  fetch_nop,      op_nop,         store_nop       ;BA             ;
-instr  fetch_nop,      op_nop,         store_nop       ;BB             ;   TODO:
+instr  fetch_nop,      op_INDR,        store_nop       ;BA             ;INDR
+instr  fetch_nop,      op_OTDR,        store_nop       ;BB             ;OTDR
 instr  fetch_nop,      op_nop,         store_nop       ;BC             ;NOP
 instr  fetch_nop,      op_nop,         store_nop       ;BD             ;NOP
 instr  fetch_nop,      op_nop,         store_nop       ;BE             ;NOP
@@ -3337,17 +3442,17 @@ instr   fetch_nop,      op_nop,         store_nop       ;20             ;
 instr  fetch_DIR16,    op_nop,         store_xx        ;21             ;LD xx,nn
 instr  fetch_DIR16,    op_STxx,        store_nop       ;22             ;LD (nn),xx
 instr  fetch_xx,       op_INC16,       store_xx        ;23             ;INC xx
-instr  fetch_xh,       op_INC,         store_xh        ;24             ;INC xh
-instr  fetch_xh,       op_DEC,         store_xh        ;25             ;DEC xh
-instr  fetch_DIR8,     op_nop,         store_xh        ;26             ;LD xh,n
+instr  fetch_xH,       op_INC,         store_xH        ;24             ;INC xh
+instr  fetch_xH,       op_DEC,         store_xH        ;25             ;DEC xh
+instr  fetch_DIR8,     op_nop,         store_xH        ;26             ;LD xh,n
 instr  fetch_nop,      op_nop,         store_nop       ;27             ;
 instr  fetch_nop,      op_nop,         store_nop       ;28             ;
 instr  fetch_xx,       op_ADDxx,       store_nop       ;29             ;ADD xx,xx
 instr  fetch_DIR16,    op_RMEM16,      store_xx        ;2A             ;LD xx,(nn)
 instr  fetch_xx,       op_DEC16,       store_xx        ;2B             ;DEC xx
-instr  fetch_xl,       op_INC,         store_xl        ;2C             ;INC xl
-instr  fetch_xl,       op_DEC,         store_xl        ;2D             ;DEC xl
-instr  fetch_DIR8,     op_nop,         store_xl        ;2E             ;LD xl,n
+instr  fetch_xL,       op_INC,         store_xL        ;2C             ;INC xl
+instr  fetch_xL,       op_DEC,         store_xL        ;2D             ;DEC xl
+instr  fetch_DIR8,     op_nop,         store_xL        ;2E             ;LD xl,n
 instr  fetch_nop,      op_nop,         store_nop       ;2F             ;
 instr  fetch_nop,      op_nop,         store_nop       ;30             ;
 instr  fetch_nop,      op_nop,         store_nop       ;31             ;
@@ -3369,50 +3474,50 @@ instr   fetch_nop,      op_nop,         store_nop       ;40             ;
 instr  fetch_nop,      op_nop,         store_nop       ;41             ;
 instr  fetch_nop,      op_nop,         store_nop       ;42             ;
 instr  fetch_nop,      op_nop,         store_nop       ;43             ;
-instr  fetch_xh,       op_nop,         store_B         ;44             ;LD B,xh
-instr  fetch_xl,       op_nop,         store_B         ;45             ;LD B,xl
+instr  fetch_xH,       op_nop,         store_B         ;44             ;LD B,xh
+instr  fetch_xL,       op_nop,         store_B         ;45             ;LD B,xl
 instr  fetch_MXX,      op_nop,         store_B         ;46             ;LD B,(xx+d)
 instr  fetch_nop,      op_nop,         store_nop       ;47             ;
 instr  fetch_nop,      op_nop,         store_nop       ;48             ;
 instr  fetch_nop,      op_nop,         store_nop       ;49             ;
 instr  fetch_nop,      op_nop,         store_nop       ;4A             ;
 instr  fetch_nop,      op_nop,         store_nop       ;4B             ;
-instr  fetch_xh,       op_nop,         store_C         ;4C             ;LD C,xh
-instr  fetch_xl,       op_nop,         store_C         ;4D             ;LD C,xl
+instr  fetch_xH,       op_nop,         store_C         ;4C             ;LD C,xh
+instr  fetch_xL,       op_nop,         store_C         ;4D             ;LD C,xl
 instr  fetch_MXX,      op_nop,         store_C         ;4E             ;LD C,(xx+d)
 instr  fetch_nop,      op_nop,         store_nop       ;4F             ;
 instr  fetch_nop,      op_nop,         store_nop       ;50             ;
 instr  fetch_nop,      op_nop,         store_nop       ;51             ;
 instr  fetch_nop,      op_nop,         store_nop       ;52             ;
 instr  fetch_nop,      op_nop,         store_nop       ;53             ;
-instr  fetch_xh,       op_nop,         store_D         ;54             ;LD D,xh
-instr  fetch_xl,       op_nop,         store_D         ;55             ;LD D,xl
+instr  fetch_xH,       op_nop,         store_D         ;54             ;LD D,xh
+instr  fetch_xL,       op_nop,         store_D         ;55             ;LD D,xl
 instr  fetch_MXX,      op_nop,         store_D         ;56             ;LD D,(xx+d)
 instr  fetch_nop,      op_nop,         store_nop       ;57             ;
 instr  fetch_nop,      op_nop,         store_nop       ;58             ;
 instr  fetch_nop,      op_nop,         store_nop       ;59             ;
 instr  fetch_nop,      op_nop,         store_nop       ;5A             ;
 instr  fetch_nop,      op_nop,         store_nop       ;5B             ;
-instr  fetch_xh,       op_nop,         store_E         ;5C             ;LD E,xh
-instr  fetch_xl,       op_nop,         store_E         ;5D             ;LD E,xl
+instr  fetch_xH,       op_nop,         store_E         ;5C             ;LD E,xh
+instr  fetch_xL,       op_nop,         store_E         ;5D             ;LD E,xl
 instr  fetch_MXX,      op_nop,         store_E         ;5E             ;LD E,(xx+d)
 instr  fetch_nop,      op_nop,         store_nop       ;5F             ;
-instr  fetch_B,        op_nop,         store_xh        ;60             ;LD xh,B
-instr  fetch_C,        op_nop,         store_xh        ;61             ;LD xh,C
-instr  fetch_D,        op_nop,         store_xh        ;62             ;LD xh,D
-instr  fetch_E,        op_nop,         store_xh        ;63             ;LD xh,E
+instr  fetch_B,        op_nop,         store_xH        ;60             ;LD xh,B
+instr  fetch_C,        op_nop,         store_xH        ;61             ;LD xh,C
+instr  fetch_D,        op_nop,         store_xH        ;62             ;LD xh,D
+instr  fetch_E,        op_nop,         store_xH        ;63             ;LD xh,E
 instr  fetch_nop,      op_nop,         store_nop       ;64             ;LD xh,xh
-instr  fetch_xl,       op_nop,         store_xh        ;65             ;LD xh,xl
+instr  fetch_xL,       op_nop,         store_xH        ;65             ;LD xh,xl
 instr  fetch_MXX,      op_nop,         store_H         ;66             ;LD H,(xx+d)
-instr  fetch_A,        op_nop,         store_xh        ;67             ;LD xh,A
-instr  fetch_B,        op_nop,         store_xl        ;68             ;LD xl,B
-instr  fetch_C,        op_nop,         store_xl        ;69             ;LD xl,C
-instr  fetch_D,        op_nop,         store_xl        ;6A             ;LD xl,D
-instr  fetch_E,        op_nop,         store_xl        ;6B             ;LD xl,E
-instr  fetch_xh,       op_nop,         store_xl        ;6C             ;LD xl,xh
+instr  fetch_A,        op_nop,         store_xH        ;67             ;LD xh,A
+instr  fetch_B,        op_nop,         store_xL        ;68             ;LD xl,B
+instr  fetch_C,        op_nop,         store_xL        ;69             ;LD xl,C
+instr  fetch_D,        op_nop,         store_xL        ;6A             ;LD xl,D
+instr  fetch_E,        op_nop,         store_xL        ;6B             ;LD xl,E
+instr  fetch_xH,       op_nop,         store_xL        ;6C             ;LD xl,xh
 instr  fetch_nop,      op_nop,         store_nop       ;6D             ;LD xl,xl
 instr  fetch_MXX,      op_nop,         store_L         ;6E             ;LD L,(xx+d)
-instr  fetch_A,        op_nop,         store_xl        ;6F             ;LD xl,A
+instr  fetch_A,        op_nop,         store_xL        ;6F             ;LD xl,A
 instr  fetch_B,        op_nop,         store_MXX       ;70             ;LD (xx+d),B
 instr  fetch_C,        op_nop,         store_MXX       ;71             ;LD (xx+d),C
 instr  fetch_D,        op_nop,         store_MXX       ;72             ;LD (xx+d),D
@@ -3425,72 +3530,72 @@ instr   fetch_nop,      op_nop,         store_nop       ;78             ;
 instr  fetch_nop,      op_nop,         store_nop       ;79             ;
 instr  fetch_nop,      op_nop,         store_nop       ;7A             ;
 instr  fetch_nop,      op_nop,         store_nop       ;7B             ;
-instr  fetch_xh,       op_nop,         store_A         ;7C             ;LD A,xh
-instr  fetch_xl,       op_nop,         store_A         ;7D             ;LD A,xl
+instr  fetch_xH,       op_nop,         store_A         ;7C             ;LD A,xh
+instr  fetch_xL,       op_nop,         store_A         ;7D             ;LD A,xl
 instr  fetch_MXX,      op_nop,         store_A         ;7E             ;LD A,(xx+d)
 instr  fetch_nop,      op_nop,         store_nop       ;7F             ;
 instr  fetch_nop,      op_nop,         store_nop       ;80             ;
 instr  fetch_nop,      op_nop,         store_nop       ;81             ;
 instr  fetch_nop,      op_nop,         store_nop       ;82             ;
 instr  fetch_nop,      op_nop,         store_nop       ;83             ;
-instr  fetch_xh,       op_ADDA,        store_nop       ;84             ;ADD A,xh
-instr  fetch_xl,       op_ADDA,        store_nop       ;85             ;ADD A,xl
+instr  fetch_xH,       op_ADDA,        store_nop       ;84             ;ADD A,xh
+instr  fetch_xL,       op_ADDA,        store_nop       ;85             ;ADD A,xl
 instr  fetch_MXX,      op_ADDA,        store_nop       ;86             ;ADD A,(xx)
 instr  fetch_nop,      op_nop,         store_nop       ;87             ;
 instr  fetch_nop,      op_nop,         store_nop       ;88             ;
 instr  fetch_nop,      op_nop,         store_nop       ;89             ;
 instr  fetch_nop,      op_nop,         store_nop       ;8A             ;
 instr  fetch_nop,      op_nop,         store_nop       ;8B             ;
-instr  fetch_xh,       op_ADCA,        store_nop       ;8C             ;ADC A,xh
-instr  fetch_xl,       op_ADCA,        store_nop       ;8D             ;ADC A,xl
+instr  fetch_xH,       op_ADCA,        store_nop       ;8C             ;ADC A,xh
+instr  fetch_xL,       op_ADCA,        store_nop       ;8D             ;ADC A,xl
 instr  fetch_MXX,      op_ADCA,        store_nop       ;8E             ;ADC A,(xx)
 instr  fetch_nop,      op_nop,         store_nop       ;8F             ;
 instr  fetch_nop,      op_nop,         store_nop       ;90             ;
 instr  fetch_nop,      op_nop,         store_nop       ;91             ;
 instr  fetch_nop,      op_nop,         store_nop       ;92             ;
 instr  fetch_nop,      op_nop,         store_nop       ;93             ;
-instr  fetch_xh,       op_SUBFA,       store_nop       ;94             ;SUB A,xh
-instr  fetch_xl,       op_SUBFA,       store_nop       ;95             ;SUB A,xl
+instr  fetch_xH,       op_SUBFA,       store_nop       ;94             ;SUB A,xh
+instr  fetch_xL,       op_SUBFA,       store_nop       ;95             ;SUB A,xl
 instr  fetch_MXX,      op_SUBFA,       store_nop       ;96             ;SUB A,(xx)
 instr  fetch_nop,      op_nop,         store_nop       ;97             ;
 instr  fetch_nop,      op_nop,         store_nop       ;98             ;
 instr  fetch_nop,      op_nop,         store_nop       ;99             ;
 instr  fetch_nop,      op_nop,         store_nop       ;9A             ;
 instr  fetch_nop,      op_nop,         store_nop       ;9B             ;
-instr  fetch_xh,       op_SBCFA,       store_nop       ;9C             ;SBC A,xh
-instr  fetch_xl,       op_SBCFA,       store_nop       ;9D             ;SBC A,xl
+instr  fetch_xH,       op_SBCFA,       store_nop       ;9C             ;SBC A,xh
+instr  fetch_xL,       op_SBCFA,       store_nop       ;9D             ;SBC A,xl
 instr  fetch_MXX,      op_SBCFA,       store_nop       ;9E             ;SBC A,(xx)
 instr  fetch_nop,      op_nop,         store_nop       ;9F             ;
 instr  fetch_nop,      op_nop,         store_nop       ;A0             ;
 instr  fetch_nop,      op_nop,         store_nop       ;A1             ;
 instr  fetch_nop,      op_nop,         store_nop       ;A2             ;
 instr  fetch_nop,      op_nop,         store_nop       ;A3             ;
-instr  fetch_xh,       op_ANDA,        store_nop       ;A4             ;AND A,xh
-instr  fetch_xl,       op_ANDA,        store_nop       ;A5             ;AND A,xl
+instr  fetch_xH,       op_ANDA,        store_nop       ;A4             ;AND A,xh
+instr  fetch_xL,       op_ANDA,        store_nop       ;A5             ;AND A,xl
 instr  fetch_MXX,      op_ANDA,        store_nop       ;A6             ;AND A,(xx)
 instr  fetch_nop,      op_nop,         store_nop       ;A7             ;
 instr  fetch_nop,      op_nop,         store_nop       ;A8             ;
 instr  fetch_nop,      op_nop,         store_nop       ;A9             ;
 instr  fetch_nop,      op_nop,         store_nop       ;AA             ;
 instr  fetch_nop,      op_nop,         store_nop       ;AB             ;
-instr  fetch_xh,       op_ANDA,        store_nop       ;AC             ;XOR A,xh
-instr  fetch_xl,       op_ANDA,        store_nop       ;AD             ;XOR A,xl
-instr  fetch_MXX,      op_ANDA,        store_nop       ;AE             ;XOR A,(xx)
+instr  fetch_xH,       op_XORA,        store_nop       ;AC             ;XOR A,xh
+instr  fetch_xL,       op_XORA,        store_nop       ;AD             ;XOR A,xl
+instr  fetch_MXX,      op_XORA,        store_nop       ;AE             ;XOR A,(xx)
 instr  fetch_nop,      op_nop,         store_nop       ;AF             ;
 instr  fetch_nop,      op_nop,         store_nop       ;B0             ;
 instr  fetch_nop,      op_nop,         store_nop       ;B1             ;
 instr  fetch_nop,      op_nop,         store_nop       ;B2             ;
 instr  fetch_nop,      op_nop,         store_nop       ;B3             ;
-instr  fetch_xh,       op_ORA,         store_nop       ;B4             ;OR A,xh
-instr  fetch_xl,       op_ORA,         store_nop       ;B5             ;OR A,xl
+instr  fetch_xH,       op_ORA,         store_nop       ;B4             ;OR A,xh
+instr  fetch_xL,       op_ORA,         store_nop       ;B5             ;OR A,xl
 instr  fetch_MXX,      op_ORA,         store_nop       ;B6             ;OR A,(xx)
 instr  fetch_nop,      op_nop,         store_nop       ;B7             ;
 instr  fetch_nop,      op_nop,         store_nop       ;B8             ;
 instr  fetch_nop,      op_nop,         store_nop       ;B9             ;
 instr  fetch_nop,      op_nop,         store_nop       ;BA             ;
 instr  fetch_nop,      op_nop,         store_nop       ;BB             ;
-instr  fetch_xh,       op_CPFA,        store_nop       ;BC             ;CP A,xh
-instr  fetch_xl,       op_CPFA,        store_nop       ;BD             ;CP A,xl
+instr  fetch_xH,       op_CPFA,        store_nop       ;BC             ;CP A,xh
+instr  fetch_xL,       op_CPFA,        store_nop       ;BD             ;CP A,xl
 instr  fetch_MXX,      op_CPFA,        store_nop       ;BE             ;CP A,(xx)
 instr  fetch_nop,      op_nop,         store_nop       ;BF             ;
 instr  fetch_nop,      op_nop,         store_nop       ;C0             ;