z_l: .byte 1
#if EM_Z80
+z_flags2: .byte 1
+z_a2: .byte 1
+z_b2: .byte 1
+z_c2: .byte 1
+z_d2: .byte 1
+z_e2: .byte 1
+z_h2: .byte 1
+z_l2: .byte 1
+
z_xh: .byte 1
z_xl: .byte 1
z_yh: .byte 1
z_i: .byte 1
z_r: .byte 1
+
+ .equ r2ofs = z_b2-z_b
+
#endif
.cseg
cbi flags,trace
clr intstat
printnewline
-#if EM_Z80
- printstring "Ok, Z80-CPU is live!"
-#else
- printstring "Ok, 8080-CPU is live!"
+
+#if INS_DEBUG
+ sbr intstat,(1<<i_break)
#endif
+
+ printstring "Ok, "CPUSTR"-CPU is live!"
printnewline
main:
-.if INS_DEBUG
- cbi flags,trace
- cpi z_pch,DBG_TRACE_BOTTOM
- brlo notraceon
- cpi z_pch,DBG_TRACE_TOP
- brsh notraceon
- sbi flags,trace
-notraceon:
-.endif
.if PRINT_PC
cpi z_pch,DBG_TRACE_BOTTOM
printnewline
printstring "PC="
movw temp,z_pcl
- rcall printhexw
+ lcall printhexw
printstring " "
noprintpc:
.endif
-.if INS_DEBUG
- sbic flags,trace
- rcall printregs
-.endif
-
;TODO: hier kommt die Interruptbehandlung rein
- cpse intstat,_0
+ cpse intstat,_0 ;fast path if no trace, int, break, ...
rjmp int_test
+int_instr:
mem_read_ds zl,z_pc ;zl = memReadByte(z_pc)
adiw z_pcl,1 ;++z_pc
ldi zh,high(opcjmp) ;
rjmp main ;
int_test:
+ sbrs intstat,i_trace
+ rjmp int_notrace
+ cpi z_pch,DBG_TRACE_BOTTOM
+ brlo int_notrace
+ cpi z_pch,DBG_TRACE_TOP
+ brsh int_notrace
+ lcall printregs
+int_notrace:
sbrs intstat,i_break
- rjmp inttst_1
- cbr intstat,(1<<i_break)
+ rjmp int_nobreak
+ cbr intstat,(1<<i_break)|(1<<i_halt)
printnewline
printstring "Break detected! "
mov z_pcl,_0
mov z_pch,_0
- rjmp inttst_e
+int_nobreak:
+
+ rjmp int_instr ;continue with normal instruction interpretation
-inttst_1:
-inttst_e:
- rjmp main
;--------------------------------------------------
; init opcode table
movw z_pcl,opl
ret
+do_store_pcrel: ;add displacement to PC
+ clr oph
+ tst opl ;sign extend
+ brpl stpcr1
+ com oph
+stpcr1:
+ add z_pcl,opl
+ adc z_pch,oph
+ ret
+
+
do_store_ret:
movw x,z_spl
mem_read_d z_pcl
;|ADC A,s |***V0*|Add with Carry |A=A+s+CY |
;|ADC HL,ss |**?V0*|Add with Carry |HL=HL+ss+CY |
;|ADD A,s |***V0*|Add |A=A+s |
-;|ADD HL,ss |--?-0*|Add |HL=HL+ss |
-;|ADD IX,pp |--?-0*|Add |IX=IX+pp |
-;|ADD IY,rr |--?-0*|Add |IY=IY+rr |
+;|ADD HL,ss |--*-0*|Add |HL=HL+ss |
+;|ADD IX,pp |--*-0*|Add |IX=IX+pp |
+;|ADD IY,rr |--*-0*|Add |IY=IY+rr |
;|AND s |**1P00|Logical AND |A=A&s |
;|BIT b,m |?*1?0-|Test Bit |m&{2^b} |
;|CALL cc,nn|------|Conditional Call |If cc CALL |
;|RRD |**0P0-|Rotate Right 4 bits |{A,[HL]}=->{A,[HL]} ##|
;|RST p |------|Restart | (p=0H,8H,10H,...,38H)|
;|SBC A,s |***V1*|Subtract with Carry |A=A-s-CY |
-;|SBC HL,ss |**?V1*|Subtract with Carry |HL=HL-ss-CY |
+;|SBC HL,ss |***V1*|Subtract with Carry |HL=HL-ss-CY |
;|SCF |--0-01|Set Carry Flag |CY=1 |
;|SET b,m |------|Set bit |m=mv{2^b} |
;|SLA m |**0P0*|Shift Left Arithmetic|m=m*2 |
#endif
.endm
+.macro do_z80_flags_H
+#if EM_Z80
+ bmov z_flags, ZFL_H, temp, AVR_H
+#endif
+.endm
+
.macro do_z80_flags_set_N
#if EM_Z80
ori z_flags, (1<<ZFL_N) ; Negation auf 1
do_op_nop:
ret
+
+;----------------------------------------------------------------
+;|Mnemonic |SZHPNC|Description |Notes |
+;----------------------------------------------------------------
+;|HALT |------|Halt | |
+
+
+do_op_HALT:
+ sbiw z_pcl,1
+ sbrc intstat,i_halt
+ ret
+ sbr intstat,(1<<i_halt)
+ lcall printregs
+ printstring "CPU halted! "
+ ret
+
;----------------------------------------------------------------
;|Mnemonic |SZHPNC|Description |Notes |
printnewline
printstring "Port write: "
mov temp,z_a
- rcall printhex
+ lcall printhex
printstring " -> ("
mov temp,opl
- rcall printhex
+ lcall printhex
printstring ") "
.endif
mov temp,z_a
lcall portWrite
ret
-do_op_out: ; out (c),opl
- mov temp,opl
- lds temp2,z_c
- lcall portWrite
- ret
-
;----------------------------------------------------------------
;|Mnemonic |SZHPNC|Description |Notes |
;----------------------------------------------------------------
;|IN A,[n] |------|Input |A=[n] |
;
;
-;TODO: do_op_ina and z80-flags
-;
-do_op_in: ; in a,(opl)
+do_op_ina: ; in a,(opl)
.if PORT_DEBUG
printnewline
printstring "Port read: ("
mov temp,opl
- rcall printhex
+ lcall printhex
printstring ") -> "
.endif
mov temp2,opl
lcall portRead
- mov opl,temp
+ mov z_a,temp
.if PORT_DEBUG
- rcall printhex
+ lcall printhex
printstring " "
.endif
ret
;----------------------------------------------------------------
;|Mnemonic |SZHPNC|Description |Notes |
;----------------------------------------------------------------
-;|ADD HL,ss |--?-0*|Add |HL=HL+ss |
+;|ADD HL,ss |--*-0*|Add |HL=HL+ss |
;|----------|SZHP C|---------- 8080 ----------------------------|
;|ADD HL,ss |---- *|Add |HL=HL+ss |
;
lds temp2,z_h
add opl,temp
adc oph,temp2
+ sts z_l,opl
+ sts z_h,oph
in temp,sreg
- bmov z_flags,ZFL_H, temp,AVR_H
bmov z_flags,ZFL_C, temp,AVR_C
+ do_z80_flags_H
do_z80_flags_clear_N
ret
pop temp ; direkt zuruech zu main
ret
+;----------------------------------------------------------------
+#if EM_Z80
+
+;----------------------------------------------------------------
+;|Mnemonic |SZHPNC|Description |Notes |
;----------------------------------------------------------------
+;|DJNZ e |------|Dec., Jump Non-Zero |B=B-1 till B=0 |
+;
+
+do_op_djnz:
+ lds temp,z_b
+ dec temp
+ sts z_b,temp
+ brne opdjnze
+ pop temp ; nix tun
+ pop temp ; direkt zuruech zu main
+opdjnze:
+ ret
+
+
+;----------------------------------------------------------------
+;|Mnemonic |SZHPNC|Description |Notes |
+;----------------------------------------------------------------
+;|EX AF,AF' |------|Exchange |AF<->AF' |
+
+do_op_EXAF:
+ lds temp,z_flags2
+ lds temp2,z_a2
+ sts z_flags2,z_flags
+ sts z_a2,z_a
+ mov z_flags,temp
+ mov z_a,temp2
+ ret
+
+
+;----------------------------------------------------------------
+;|Mnemonic |SZHPNC|Description |Notes |
+;----------------------------------------------------------------
+;|EXX |------|Exchange |qq<->qq' (except AF)|
+
+
+do_op_EXX:
+ ldiw z,z_b
+ ldi temp3,6
+opexx_loop:
+ ld temp,z
+ ldd temp2,z+r2ofs
+ std z+r2ofs,temp
+ st z+,temp2
+ dec temp3
+ brne opexx_loop
+ ret
+
+#else
+do_op_djnz:
+do_op_EXAF:
+do_op_EXX:
+ ret
+#endif
#if EM_Z80
do_op_prefixDD:
-;TODO: Flag für DD setzen
-
+ cbi flags,prefixfd
mem_read_ds zl,z_pc ;zl = memReadByte(z_pc)
adiw z_pcl,1 ;++z_pc
ldi zh,high(DDFDjmp) ;
do_op_prefixFD:
-;TODO: Flag für FD setzen
-
+ sbi flags,prefixfd
mem_read_ds zl,z_pc ;zl = memReadByte(z_pc)
adiw z_pcl,1 ;++z_pc
ldi zh,high(DDFDjmp) ;
ijmp
+do_op_prefixCB:
+ mem_read_ds zl,z_pc ;zl = memReadByte(z_pc)
+ adiw z_pcl,1 ;++z_pc
+ ldi zh,high(CBjmp) ;
+ ijmp
+
+
+do_op_prefixDDFDCB:
+ mem_read_ds temp4,z_pc ;temp4 = displacement
+ adiw z_pcl,1 ;++z_pc
+ mem_read_ds zl,z_pc ;zl = opcode
+ adiw z_pcl,1 ;++z_pc
+ ldi zh,high(DDFDCBjmp) ;
+ ijmp
+
+
#else ; TODO: geht das so?
do_op_prefixED:
do_op_prefixDD:
do_op_prefixFD:
+do_op_prefixCB:
ret
#endif
instr fetch_B, op_DEC, store_B ;05 ;DEC B
instr fetch_DIR8, op_nop, store_B ;06 ;LD B,n
instr fetch_nop, op_RLCA, store_nop ;07 ;RLCA
-instr fetch_nop, op_INV, store_nop ;08 ;EX AF,AF' (TODO: !)
-instr fetch_BC, op_ADDHL, store_HL ;09 ;ADD HL,BC
+instr fetch_nop, op_EXAF, store_nop ;08 ;EX AF,AF'
+instr fetch_BC, op_ADDHL, store_nop ;09 ;ADD HL,BC
instr fetch_MBC, op_nop, store_nop ;0A ;LD A,(BC)
instr fetch_BC, op_DEC16, store_BC ;0B ;DEC BC
instr fetch_C, op_INC, store_C ;0C ;INC C
instr fetch_C, op_DEC, store_C ;0D ;DEC C
instr fetch_DIR8, op_nop, store_C ;0E nn ;LD C,n
instr fetch_nop, op_RRCA, store_nop ;0F ;RRCA
-instr fetch_nop, op_INV, store_nop ;10 oo ;DJNZ o (TODO: !)
+instr fetch_DIR8, op_DJNZ, store_pcrel ;10 oo ;DJNZ o
instr fetch_DIR16, op_nop, store_DE ;11 nn nn ;LD DE,nn
instr fetch_nop, op_nop, store_MDE ;12 ;LD (DE),A
instr fetch_DE, op_INC16, store_DE ;13 ;INC DE
instr fetch_D, op_DEC, store_D ;15 ;DEC D
instr fetch_DIR8, op_nop, store_D ;16 nn ;LD D,n
instr fetch_nop, op_RLA, store_nop ;17 ;RLA
-instr fetch_nop, op_INV, store_nop ;18 oo ;JR o (TODO: !)
-instr fetch_DE, op_ADDHL, store_HL ;19 ;ADD HL,DE
+instr fetch_DIR8, op_nop, store_pcrel ;18 oo ;JR o
+instr fetch_DE, op_ADDHL, store_nop ;19 ;ADD HL,DE
instr fetch_MDE, op_nop, store_nop ;1A ;LD A,(DE)
instr fetch_DE, op_DEC16, store_DE ;1B ;DEC DE
instr fetch_E, op_INC, store_E ;1C ;INC E
instr fetch_E, op_DEC, store_E ;1D ;DEC E
instr fetch_DIR8, op_nop, store_E ;1E nn ;LD E,n
instr fetch_nop, op_RRA, store_nop ;1F ;RRA
-instr fetch_nop, op_INV, store_nop ;20 oo ;JR NZ,o (TODO: !)
+instr fetch_DIR8, op_IFNZ, store_pcrel ;20 oo ;JR NZ,o
instr fetch_DIR16, op_nop, store_HL ;21 nn nn ;LD HL,nn
instr fetch_DIR16, op_STHL, store_nop ;22 nn nn ;LD (nn),HL
instr fetch_HL, op_INC16, store_HL ;23 ;INC HL
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_nop, op_INV, store_nop ;28 oo ;JR Z,o (TODO: !)
-instr fetch_HL, op_ADDHL, store_HL ;29 ;ADD HL,HL
+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)
instr fetch_HL, op_DEC16, store_HL ;2B ;DEC HL
instr fetch_L, op_INC, store_L ;2C ;INC L
instr fetch_L, op_DEC, store_L ;2D ;DEC L
instr fetch_DIR8, op_nop, store_L ;2E nn ;LD L,n
instr fetch_nop, op_CPL, store_nop ;2F ;CPL
-instr fetch_nop, op_INV, store_nop ;30 oo ;JR NC,o (TODO: !)
+instr fetch_DIR8, op_IFNC, store_pcrel ;30 oo ;JR NC,o
instr fetch_DIR16, op_nop, store_SP ;31 nn nn ;LD SP,nn
instr fetch_DIR16, op_nop, store_AM ;32 nn nn ;LD (nn),A
instr fetch_SP, op_INC16, store_SP ;33 ;INC SP
instr fetch_MHL, op_DEC, store_MHL ;35 ;DEC (HL)
instr fetch_DIR8, op_nop, store_MHL ;36 nn ;LD (HL),n
instr fetch_nop, op_SCF, store_nop ;37 ;SCF
-instr fetch_nop, op_INV, store_nop ;38 oo ;JR C,o (TODO: !)
-instr fetch_SP, op_ADDHL, store_HL ;39 ;ADD HL,SP
+instr fetch_DIR8, op_IFC, store_pcrel ;38 oo ;JR C,o
+instr fetch_SP, op_ADDHL, store_nop ;39 ;ADD HL,SP
instr fetch_DIR16, op_RMEM8, store_A ;3A nn nn ;LD A,(nn)
instr fetch_SP, op_DEC16, store_SP ;3B ;DEC SP
instr fetch_nop, op_INCA, store_nop ;3C ;INC A
instr fetch_E, op_nop, store_MHL ;73 ;LD (HL),E
instr fetch_H, op_nop, store_MHL ;74 ;LD (HL),H
instr fetch_L, op_nop, store_MHL ;75 ;LD (HL),L
-instr fetch_nop, op_INV, store_nop ;76 ;HALT (TODO: !)
+instr fetch_nop, op_HALT, store_nop ;76 ;HALT
instr fetch_A, op_nop, store_MHL ;77 ;LD (HL),A
instr fetch_B, op_nop, store_A ;78 ;LD A,B
instr fetch_C, op_nop, store_A ;79 ;LD A,C
instr fetch_nop, op_IFZ, store_RET ;C8 ;RET Z
instr fetch_nop, op_nop, store_RET ;C9 ;RET
instr fetch_DIR16, op_IFZ, store_PC ;CA nn nn ;JP Z,nn
-instr fetch_nop, op_INV, store_nop ;CB ;(Z80 specific) (TODO: !)
+instr fetch_nop, op_prefixCB, store_nop ;CB ;(CB opcode prefix)
instr fetch_DIR16, op_IFZ, store_CALL ;CC nn nn ;CALL Z,nn
instr fetch_DIR16, op_nop, store_CALL ;CD nn nn ;CALL nn
instr fetch_DIR8, op_ADCA, store_nop ;CE nn ;ADC A,n
instr fetch_DIR8, op_SUBFA, store_nop ;D6 nn ;SUB n
instr fetch_RST, op_nop, store_CALL ;D7 ;RST 10H
instr fetch_nop, op_IFC, store_RET ;D8 ;RET C
-instr fetch_nop, op_nop, store_nop ;D9 ;EXX
+instr fetch_nop, op_EXX, store_nop ;D9 ;EXX
instr fetch_DIR16, op_IFC, store_PC ;DA nn nn ;JP C,nn
-instr fetch_DIR8, op_IN, store_A ;DB nn ;IN A,(n)
+instr fetch_DIR8, op_INA, store_nop ;DB nn ;IN A,(n)
instr fetch_DIR16, op_IFC, store_CALL ;DC nn nn ;CALL C,nn
instr fetch_nop, op_prefixDD, store_nop ;DD ;(FD opcode prefix)
instr fetch_DIR8, op_SBCFA, store_nop ;DE nn ;SBC A,n
;----------------------------------------------------------------
;|Mnemonic |SZHPNC|Description |Notes |
;----------------------------------------------------------------
-;|LD dst,src|------|Load |dst=src |
+;|IN r,[C] |***P0-|Input |r=[C] |
;
+
+do_op_in: ; in opl,(opl)
+.if PORT_DEBUG
+ printnewline
+ printstring "Port read: ("
+ mov temp,opl
+ rcall printhex
+ printstring ") -> "
+.endif
+
+ mov temp2,opl
+ lcall portRead
+ mov opl,temp
+ bst z_flags,ZFL_C ;save Carry
+ ldpmx z_flags,sz53p_tab,temp ;S,Z,P
+ bld z_flags,ZFL_C
+
+.if PORT_DEBUG
+ rcall printhex
+ printstring " "
+.endif
+ ret
+
+;----------------------------------------------------------------
+;|Mnemonic |SZHPNC|Description |Notes |
+;----------------------------------------------------------------
+;|OUT [C],r |------|Output |[C]=r |
;
+
+do_op_out: ; out (c),opl
+ mov temp,opl
+ lds temp2,z_c
+ lcall portWrite
+ ret
+
+;----------------------------------------------------------------
+;|Mnemonic |SZHPNC|Description |Notes |
+;----------------------------------------------------------------
+;|LD dst,src|------|Load |dst=src |
+;
+
do_op_stbc: ;store bc to mem loc in opl:h
movw xl,opl
lds temp,z_c
;----------------------------------------------------------------
;|Mnemonic |SZHPNC|Description |Notes |
;----------------------------------------------------------------
-;|ADC HL,ss |--?-0*|Add with carry |HL=HL+ss+CY |
+;|ADC HL,ss |***V0*|Add with Carry |HL=HL+ss+CY |
;
-;TODO: Flags
-
do_op_ADCHL:
lds temp,z_l
lds temp2,z_h
- add opl,temp
+ clc
+ sbrc z_flags,ZFL_C
+ sec
+ adc opl,temp
+ in temp,sreg ; save lower Z
adc oph,temp2
- in temp,sreg
- bmov z_flags,ZFL_H, temp,AVR_H
- bmov z_flags,ZFL_C, temp,AVR_C
- do_z80_flags_clear_N
+ in temp2,sreg
+ sts z_l,opl
+ sts z_h,oph
+ and temp,temp2 ; 16bit Z
+ ldi z_flags,0 ; clear N
+ bmov z_flags,ZFL_C, temp2,AVR_C
+ bmov z_flags,ZFL_P, temp2,AVR_V
+ bmov z_flags,ZFL_H, temp2,AVR_H
+ bmov z_flags,ZFL_Z, temp,AVR_Z
+ bmov z_flags,ZFL_S, temp2,AVR_S
ret
-
;----------------------------------------------------------------
;|Mnemonic |SZHPNC|Description |Notes |
;----------------------------------------------------------------
-;|SBC HL,ss |--?-0*|Subtract with carry |HL=HL-ss-CY |
+;|SBC HL,ss |***V1*|Subtract with carry |HL=HL-ss-CY |
;
;
do_op_sbchl:
clc
sbrc z_flags,ZFL_C
sec
+ clz
sbc temp,opl
sbc temp2,oph
sts z_l,temp
sts z_h,temp2
in temp,sreg
-;TODO: flags
+ ldi z_flags,(1<<ZFL_N) ; set N
bmov z_flags,ZFL_C, temp,AVR_C
+ bmov z_flags,ZFL_P, temp,AVR_V
bmov z_flags,ZFL_H, temp,AVR_H
- do_z80_flags_V
- do_z80_flags_set_N
+ bmov z_flags,ZFL_Z, temp,AVR_Z
+ bmov z_flags,ZFL_S, temp,AVR_S
ret
;----------------------------------------------------------------
bld z_flags,ZFL_C ;
ret
+
+do_fetch_xh:
+ sbis flags,prefixfd
+ lds opl,z_xh
+ sbic flags,prefixfd
+ lds opl,z_yh
+ ret
+
+do_fetch_xl:
+ sbis flags,prefixfd
+ lds opl,z_xl
+ sbic flags,prefixfd
+ lds opl,z_yl
+ ret
+
+
+do_fetch_mxx:
+ sbic flags,prefixfd
+ rjmp fetchmxx_fd
+ lds xh,z_xh
+ lds xl,z_xl
+ rjmp fetchmxx1
+fetchmxx_fd:
+ lds xh,z_yh
+ lds xl,z_yl
+fetchmxx1:
+ mem_read_ds opl, z_pc ;get displacement
+ adiw z_pcl,1
+ clr oph ;sign extend
+ tst opl
+ brpl fetchmxx2
+ com oph
+fetchmxx2:
+ add xl,opl ;add displacement
+ adc xh,oph
+ mem_read_d opl
+ ret
+
+
do_fetch_xx:
-;TODO: Flag testen
- lds opl,z_xl ;or z_yl
- lds oph,z_xh ;or z_yl
+ sbic flags,prefixfd
+ rjmp fetchxx_fd
+ lds opl,z_xl
+ lds oph,z_xh
+ ret
+fetchxx_fd:
+ lds opl,z_yl
+ lds oph,z_yh
+ ret
+
+
+do_store_xh:
+ sbis flags,prefixfd
+ sts z_xh,opl
+ sbic flags,prefixfd
+ sts z_yh,opl
+ ret
+
+do_store_xl:
+ sbis flags,prefixfd
+ sts z_xl,opl
+ sbic flags,prefixfd
+ sts z_yl,opl
ret
+
+do_store_mxx:
+ sbic flags,prefixfd
+ rjmp storemxx_fd
+ lds xh,z_xh
+ lds xl,z_xl
+ rjmp storemxx1
+storemxx_fd:
+ lds xh,z_yh
+ lds xl,z_yl
+storemxx1:
+ mem_read_s z_pc ;get displacement
+ adiw z_pcl,1
+ clr temp2 ;sign extend
+ tst temp
+ brpl storemxx2
+ com temp2
+storemxx2:
+ add xl,temp ;add displacement
+ adc xh,temp2
+ mem_read_d opl
+ ret
+
+do_store_xx:
+ sbic flags,prefixfd
+ rjmp storexx_fd
+ sts z_xl,opl
+ sts z_xh,oph
+ ret
+storexx_fd:
+ sts z_yl,opl
+ sts z_yh,oph
+ ret
+
+
;----------------------------------------------------------------
;|Mnemonic |SZHPNC|Description |Notes |
;----------------------------------------------------------------
-;|ADD HL,ss |--?-0*|Add |HL=HL+ss |
-;|----------|SZHP C|---------- 8080 ----------------------------|
-;|ADD HL,ss |---- *|Add |HL=HL+ss |
+;|LD dst,src|------|Load |dst=src |
+;
+;
+do_op_stxx: ;store xx to mem loc in opl:h
+
+ movw xl,opl
+ sbis flags,prefixfd
+ lds temp,z_xl
+ sbic flags,prefixfd
+ lds temp,z_yl
+ mem_write
+ adiw xl,1
+ sbis flags,prefixfd
+ lds temp,z_xh
+ sbic flags,prefixfd
+ lds temp,z_yh
+ mem_write
+ ret
+
+
+;----------------------------------------------------------------
+;|Mnemonic |SZHPNC|Description |Notes |
+;----------------------------------------------------------------
+;|EX [SP],IX|------|Exchange |[SP]<->IX |
+;|EX [SP],IY|------|Exchange |[SP]<->IY |
+;
+do_op_EXxx:
+ sbic flags,prefixfd
+ rjmp opexxx_fd
+ lds temp,z_xl
+ lds temp2,z_xh
+ sts z_xl,opl
+ sts z_xh,oph
+ rjmp opexxxe
+opexxx_fd:
+ lds temp,z_yl
+ lds temp2,z_yh
+ sts z_yl,opl
+ sts z_yh,oph
+opexxxe:
+ movw opl,temp
+ ret
+
+;----------------------------------------------------------------
+;|Mnemonic |SZHPNC|Description |Notes |
+;----------------------------------------------------------------
+;|ADD IX,pp |--*-0*|Add |IX=IX+pp |
+;|ADD IY,rr |--*-0*|Add |IY=IY+rr |
;
;
do_op_addxx:
-;TODO: Flag testen
-#if 1
- lds temp,z_xl ;or z_yl
- lds temp2,z_xh ;or z_yl
+ sbic flags,prefixfd
+ rjmp opadx_fd
+ lds temp,z_xl
+ lds temp2,z_xh
add opl,temp
adc oph,temp2
- sts z_xl,opl ;or z_yl
- sts z_xh,oph ;or z_yl
+ sts z_xl,opl
+ sts z_xh,oph
+ rjmp opadx_e
+opadx_fd:
+ lds temp,z_yl
+ lds temp2,z_yh
+ add opl,temp
+ adc oph,temp2
+ sts z_yl,opl
+ sts z_yh,oph
+opadx_e:
in temp,sreg
-;TODO: set flags
-;? bmov z_flags,ZFL_H, temp,AVR_H
-;? bmov z_flags,ZFL_C, temp,AVR_C
+ bmov z_flags,ZFL_C, temp,AVR_C
+ do_z80_flags_H
do_z80_flags_clear_N
ret
-#endif
+;----------------------------------------------------------------
+;|Mnemonic |SZHPNC|Description |Notes |
+;----------------------------------------------------------------
+;|LDD |--0*0-|Load and Decrement |[DE]=[HL],HL=HL-1,# |
+;|LDDR |--000-|Load, Dec., Repeat |LDD till BC=0 |
+;|LDI |--0*0-|Load and Increment |[DE]=[HL],HL=HL+1,# |
+;|LDIR |--000-|Load, Inc., Repeat |LDI till BC=0 |
+;
+
+do_op_LDDR:
+ ldiw z,z_b
+ ld oph,z+ ;B
+ ld opl,z+ ;C
+ ld xh,z+ ;D
+ ld xl,z+ ;E
+ ld yh,z+ ;H
+ ld yl,z+ ;L
+oplddr_l:
+ mem_read_ds temp, y
+ sbiw y,1
+ mem_write_ds x, temp
+ sbiw x,1
+ subi opl,1
+ sbci oph,0
+ brne oplddr_l
+ st -z,yl
+ st -z,yh
+ st -z,xl
+ st -z,xh
+ st -z,opl
+ st -z,oph
+ cbr z_flags,(1<<ZFL_H) | (1<<ZFL_P) | (1<<ZFL_N)
+ ret
+
opctable EDjmp
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_nop, store_nop ;B8 ;
+instr fetch_nop, op_LDDR, store_nop ;B8 ;LDDR
instr fetch_nop, op_nop, store_nop ;B9 ;
instr fetch_nop, op_nop, store_nop ;BA ;
instr fetch_nop, op_nop, store_nop ;BB ; TODO:
opctable DDFDjmp
-instr fetch_nop, op_nop, store_nop ;00 ;NOP
-instr fetch_nop, op_nop, store_nop ;01 ;NOP
-instr fetch_nop, op_nop, store_nop ;02 ;NOP
-instr fetch_nop, op_nop, store_nop ;03 ;NOP
-instr fetch_nop, op_nop, store_nop ;04 ;NOP
-instr fetch_nop, op_nop, store_nop ;05 ;NOP
-instr fetch_nop, op_nop, store_nop ;06 ;NOP
-instr fetch_nop, op_nop, store_nop ;07 ;NOP
-instr fetch_nop, op_nop, store_nop ;08 ;NOP
-instr fetch_BC, op_ADDxx, store_nop ;09 ;ADD Ix,BC
-instr fetch_nop, op_nop, store_nop ;0A ;NOP
-instr fetch_nop, op_nop, store_nop ;0B ;NOP
-instr fetch_nop, op_nop, store_nop ;0C ;NOP
-instr fetch_nop, op_nop, store_nop ;0D ;NOP
-instr fetch_nop, op_nop, store_nop ;0E ;NOP
-instr fetch_nop, op_nop, store_nop ;0F ;NOP
-instr fetch_nop, op_nop, store_nop ;10 ;NOP
-instr fetch_nop, op_nop, store_nop ;11 ;NOP
-instr fetch_nop, op_nop, store_nop ;12 ;NOP
-instr fetch_nop, op_nop, store_nop ;13 ;NOP
-instr fetch_nop, op_nop, store_nop ;14 ;NOP
-instr fetch_nop, op_nop, store_nop ;15 ;NOP
-instr fetch_nop, op_nop, store_nop ;16 ;NOP
-instr fetch_nop, op_nop, store_nop ;17 ;NOP
-instr fetch_nop, op_nop, store_nop ;18 ;NOP
-instr fetch_DE, op_ADDxx, store_nop ;19 ;ADD Ix,DE
-instr fetch_nop, op_nop, store_nop ;1A ;NOP
-instr fetch_nop, op_nop, store_nop ;1B ;NOP
-instr fetch_nop, op_nop, store_nop ;1C ;NOP
-instr fetch_nop, op_nop, store_nop ;1D ;NOP
-instr fetch_nop, op_nop, store_nop ;1E ;NOP
-instr fetch_nop, op_nop, store_nop ;1F ;NOP
-instr fetch_nop, op_nop, store_nop ;20 ;NOP
-instr fetch_nop, op_nop, store_nop ;21 ;NOP
-instr fetch_nop, op_nop, store_nop ;22 ;NOP
-instr fetch_nop, op_nop, store_nop ;23 ;NOP
-instr fetch_nop, op_nop, store_nop ;24 ;NOP
-instr fetch_nop, op_nop, store_nop ;25 ;NOP
-instr fetch_nop, op_nop, store_nop ;26 ;NOP
-instr fetch_nop, op_nop, store_nop ;27 ;NOP
-instr fetch_nop, op_nop, store_nop ;28 ;NOP
+instr fetch_nop, op_nop, store_nop ;00 ;
+instr fetch_nop, op_nop, store_nop ;01 ;
+instr fetch_nop, op_nop, store_nop ;02 ;
+instr fetch_nop, op_nop, store_nop ;03 ;
+instr fetch_nop, op_nop, store_nop ;04 ;
+instr fetch_nop, op_nop, store_nop ;05 ;
+instr fetch_nop, op_nop, store_nop ;06 ;
+instr fetch_nop, op_nop, store_nop ;07 ;
+instr fetch_nop, op_nop, store_nop ;08 ;
+instr fetch_BC, op_ADDxx, store_nop ;09 ;ADD xx,BC
+instr fetch_nop, op_nop, store_nop ;0A ;
+instr fetch_nop, op_nop, store_nop ;0B ;
+instr fetch_nop, op_nop, store_nop ;0C ;
+instr fetch_nop, op_nop, store_nop ;0D ;
+instr fetch_nop, op_nop, store_nop ;0E ;
+instr fetch_nop, op_nop, store_nop ;0F ;
+instr fetch_nop, op_nop, store_nop ;10 ;
+instr fetch_nop, op_nop, store_nop ;11 ;
+instr fetch_nop, op_nop, store_nop ;12 ;
+instr fetch_nop, op_nop, store_nop ;13 ;
+instr fetch_nop, op_nop, store_nop ;14 ;
+instr fetch_nop, op_nop, store_nop ;15 ;
+instr fetch_nop, op_nop, store_nop ;16 ;
+instr fetch_nop, op_nop, store_nop ;17 ;
+instr fetch_nop, op_nop, store_nop ;18 ;
+instr fetch_DE, op_ADDxx, store_nop ;19 ;ADD xx,DE
+instr fetch_nop, op_nop, store_nop ;1A ;
+instr fetch_nop, op_nop, store_nop ;1B ;
+instr fetch_nop, op_nop, store_nop ;1C ;
+instr fetch_nop, op_nop, store_nop ;1D ;
+instr fetch_nop, op_nop, store_nop ;1E ;
+instr fetch_nop, op_nop, store_nop ;1F ;
+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_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_nop, op_nop, store_nop ;2A ;NOP
-instr fetch_nop, op_nop, store_nop ;2B ;NOP
-instr fetch_nop, op_nop, store_nop ;2C ;NOP
-instr fetch_nop, op_nop, store_nop ;2D ;NOP
-instr fetch_nop, op_nop, store_nop ;2E ;NOP
-instr fetch_nop, op_nop, store_nop ;2F ;NOP
-instr fetch_nop, op_nop, store_nop ;30 ;NOP
-instr fetch_nop, op_nop, store_nop ;31 ;NOP
-instr fetch_nop, op_nop, store_nop ;32 ;NOP
-instr fetch_nop, op_nop, store_nop ;33 ;NOP
-instr fetch_nop, op_nop, store_nop ;34 ;NOP
-instr fetch_nop, op_nop, store_nop ;35 ;NOP
-instr fetch_nop, op_nop, store_nop ;36 ;NOP
-instr fetch_nop, op_nop, store_nop ;37 ;NOP
-instr fetch_nop, op_nop, store_nop ;38 ;NOP
-instr fetch_xx, op_ADDxx, store_nop ;39 ;ADD xx,SP
-instr fetch_nop, op_nop, store_nop ;3A ;NOP
-instr fetch_nop, op_nop, store_nop ;3B ;NOP
-instr fetch_nop, op_nop, store_nop ;3C ;NOP
-instr fetch_nop, op_nop, store_nop ;3D ;NOP
-instr fetch_nop, op_nop, store_nop ;3E ;NOP
-instr fetch_nop, op_nop, store_nop ;3F ;NOP
-instr fetch_nop, op_nop, store_nop ;40 ;NOP
-instr fetch_nop, op_nop, store_nop ;41 ;NOP
-instr fetch_nop, op_nop, store_nop ;42 ;NOP
-instr fetch_nop, op_nop, store_nop ;43 ;NOP
-instr fetch_nop, op_nop, store_nop ;44 ;NOP
-instr fetch_nop, op_nop, store_nop ;45 ;NOP
-instr fetch_nop, op_nop, store_nop ;46 ;NOP
-instr fetch_nop, op_nop, store_nop ;47 ;NOP
-instr fetch_nop, op_nop, store_nop ;48 ;NOP
-instr fetch_nop, op_nop, store_nop ;49 ;NOP
-instr fetch_nop, op_nop, store_nop ;4A ;NOP
-instr fetch_nop, op_nop, store_nop ;4B ;NOP
-instr fetch_nop, op_nop, store_nop ;4C ;NOP
-instr fetch_nop, op_nop, store_nop ;4D ;NOP
-instr fetch_nop, op_nop, store_nop ;4E ;NOP
-instr fetch_nop, op_nop, store_nop ;4F ;NOP
-instr fetch_nop, op_nop, store_nop ;50 ;NOP
-instr fetch_nop, op_nop, store_nop ;51 ;NOP
-instr fetch_nop, op_nop, store_nop ;52 ;NOP
-instr fetch_nop, op_nop, store_nop ;53 ;NOP
-instr fetch_nop, op_nop, store_nop ;54 ;NOP
-instr fetch_nop, op_nop, store_nop ;55 ;NOP
-instr fetch_nop, op_nop, store_nop ;56 ;NOP
-instr fetch_nop, op_nop, store_nop ;57 ;NOP
-instr fetch_nop, op_nop, store_nop ;58 ;NOP
-instr fetch_nop, op_nop, store_nop ;59 ;NOP
-instr fetch_nop, op_nop, store_nop ;5A ;NOP
-instr fetch_nop, op_nop, store_nop ;5B ;NOP
-instr fetch_nop, op_nop, store_nop ;5C ;NOP
-instr fetch_nop, op_nop, store_nop ;5D ;NOP
-instr fetch_nop, op_nop, store_nop ;5E ;NOP
-instr fetch_nop, op_nop, store_nop ;5F ;NOP
-instr fetch_nop, op_nop, store_nop ;60 ;NOP
-instr fetch_nop, op_nop, store_nop ;61 ;NOP
-instr fetch_nop, op_nop, store_nop ;62 ;NOP
-instr fetch_nop, op_nop, store_nop ;63 ;NOP
-instr fetch_nop, op_nop, store_nop ;64 ;NOP
-instr fetch_nop, op_nop, store_nop ;65 ;NOP
-instr fetch_nop, op_nop, store_nop ;66 ;NOP
-instr fetch_nop, op_nop, store_nop ;67 ;NOP
-instr fetch_nop, op_nop, store_nop ;68 ;NOP
-instr fetch_nop, op_nop, store_nop ;69 ;NOP
-instr fetch_nop, op_nop, store_nop ;6A ;NOP
-instr fetch_nop, op_nop, store_nop ;6B ;NOP
-instr fetch_nop, op_nop, store_nop ;6C ;NOP
-instr fetch_nop, op_nop, store_nop ;6D ;NOP
-instr fetch_nop, op_nop, store_nop ;6E ;NOP
-instr fetch_nop, op_nop, store_nop ;6F ;NOP
-instr fetch_nop, op_nop, store_nop ;70 ;NOP
-instr fetch_nop, op_nop, store_nop ;71 ;NOP
-instr fetch_nop, op_nop, store_nop ;72 ;NOP
-instr fetch_nop, op_nop, store_nop ;73 ;NOP
-instr fetch_nop, op_nop, store_nop ;74 ;NOP
-instr fetch_nop, op_nop, store_nop ;75 ;NOP
-instr fetch_nop, op_nop, store_nop ;76 ;NOP
-instr fetch_nop, op_nop, store_nop ;77 ;NOP
-instr fetch_nop, op_nop, store_nop ;78 ;NOP
-instr fetch_nop, op_nop, store_nop ;79 ;NOP
-instr fetch_nop, op_nop, store_nop ;7A ;NOP
-instr fetch_nop, op_nop, store_nop ;7B ;NOP
-instr fetch_nop, op_nop, store_nop ;7C ;NOP
-instr fetch_nop, op_nop, store_nop ;7D ;NOP
-instr fetch_nop, op_nop, store_nop ;7E ;NOP
-instr fetch_nop, op_nop, store_nop ;7F ;NOP
-instr fetch_nop, op_nop, store_nop ;80 ;NOP
-instr fetch_nop, op_nop, store_nop ;81 ;NOP
-instr fetch_nop, op_nop, store_nop ;82 ;NOP
-instr fetch_nop, op_nop, store_nop ;83 ;NOP
-instr fetch_nop, op_nop, store_nop ;84 ;NOP
-instr fetch_nop, op_nop, store_nop ;85 ;NOP
-instr fetch_nop, op_nop, store_nop ;86 ;NOP
-instr fetch_nop, op_nop, store_nop ;87 ;NOP
-instr fetch_nop, op_nop, store_nop ;88 ;NOP
-instr fetch_nop, op_nop, store_nop ;89 ;NOP
-instr fetch_nop, op_nop, store_nop ;8A ;NOP
-instr fetch_nop, op_nop, store_nop ;8B ;NOP
-instr fetch_nop, op_nop, store_nop ;8C ;NOP
-instr fetch_nop, op_nop, store_nop ;8D ;NOP
-instr fetch_nop, op_nop, store_nop ;8E ;NOP
-instr fetch_nop, op_nop, store_nop ;8F ;NOP
-instr fetch_nop, op_nop, store_nop ;90 ;NOP
-instr fetch_nop, op_nop, store_nop ;91 ;NOP
-instr fetch_nop, op_nop, store_nop ;92 ;NOP
-instr fetch_nop, op_nop, store_nop ;93 ;NOP
-instr fetch_nop, op_nop, store_nop ;94 ;NOP
-instr fetch_nop, op_nop, store_nop ;95 ;NOP
-instr fetch_nop, op_nop, store_nop ;96 ;NOP
-instr fetch_nop, op_nop, store_nop ;97 ;NOP
-instr fetch_nop, op_nop, store_nop ;98 ;NOP
-instr fetch_nop, op_nop, store_nop ;99 ;NOP
-instr fetch_nop, op_nop, store_nop ;9A ;NOP
-instr fetch_nop, op_nop, store_nop ;9B ;NOP
-instr fetch_nop, op_nop, store_nop ;9C ;NOP
-instr fetch_nop, op_nop, store_nop ;9D ;NOP
-instr fetch_nop, op_nop, store_nop ;9E ;NOP
-instr fetch_nop, op_nop, store_nop ;9F ;NOP
-instr fetch_nop, op_nop, store_nop ;A0 ;NOP
-instr fetch_nop, op_nop, store_nop ;A1 ;NOP
-instr fetch_nop, op_nop, store_nop ;A2 ;NOP
-instr fetch_nop, op_nop, store_nop ;A3 ;NOP
-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_nop, store_nop ;A8 ;NOP
-instr fetch_nop, op_nop, store_nop ;A9 ;NOP
-instr fetch_nop, op_nop, store_nop ;AA ;NOP
-instr fetch_nop, op_nop, store_nop ;AB ;NOP
-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_nop, store_nop ;B0 ;NOP
-instr fetch_nop, op_nop, store_nop ;B1 ;NOP
-instr fetch_nop, op_nop, store_nop ;B2 ;NOP
-instr fetch_nop, op_nop, store_nop ;B3 ;NOP
-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_nop, store_nop ;B8 ;NOP
-instr fetch_nop, op_nop, store_nop ;B9 ;NOP
-instr fetch_nop, op_nop, store_nop ;BA ;NOP
-instr fetch_nop, op_nop, store_nop ;BB ;NOP
-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
-instr fetch_nop, op_nop, store_nop ;BF ;NOP
-instr fetch_nop, op_nop, store_nop ;C0 ;NOP
-instr fetch_nop, op_nop, store_nop ;C1 ;NOP
-instr fetch_nop, op_nop, store_nop ;C2 ;NOP
-instr fetch_nop, op_nop, store_nop ;C3 ;NOP
-instr fetch_nop, op_nop, store_nop ;C4 ;NOP
-instr fetch_nop, op_nop, store_nop ;C5 ;NOP
-instr fetch_nop, op_nop, store_nop ;C6 ;NOP
-instr fetch_nop, op_nop, store_nop ;C7 ;NOP
-instr fetch_nop, op_nop, store_nop ;C8 ;NOP
-instr fetch_nop, op_nop, store_nop ;C9 ;NOP
-instr fetch_nop, op_nop, store_nop ;CA ;NOP
-instr fetch_nop, op_nop, store_nop ;CB ;NOP
-instr fetch_nop, op_nop, store_nop ;CC ;NOP
-instr fetch_nop, op_nop, store_nop ;CD ;NOP
-instr fetch_nop, op_nop, store_nop ;CE ;NOP
-instr fetch_nop, op_nop, store_nop ;CF ;NOP
-instr fetch_nop, op_nop, store_nop ;D0 ;NOP
-instr fetch_nop, op_nop, store_nop ;D1 ;NOP
-instr fetch_nop, op_nop, store_nop ;D2 ;NOP
-instr fetch_nop, op_nop, store_nop ;D3 ;NOP
-instr fetch_nop, op_nop, store_nop ;D4 ;NOP
-instr fetch_nop, op_nop, store_nop ;D5 ;NOP
-instr fetch_nop, op_nop, store_nop ;D6 ;NOP
-instr fetch_nop, op_nop, store_nop ;D7 ;NOP
-instr fetch_nop, op_nop, store_nop ;D8 ;NOP
-instr fetch_nop, op_nop, store_nop ;D9 ;NOP
-instr fetch_nop, op_nop, store_nop ;DA ;NOP
-instr fetch_nop, op_nop, store_nop ;DB ;NOP
-instr fetch_nop, op_nop, store_nop ;DC ;NOP
-instr fetch_nop, op_nop, store_nop ;DD ;NOP
-instr fetch_nop, op_nop, store_nop ;DE ;NOP
-instr fetch_nop, op_nop, store_nop ;DF ;NOP
-instr fetch_nop, op_nop, store_nop ;E0 ;NOP
-instr fetch_nop, op_nop, store_nop ;E1 ;NOP
-instr fetch_nop, op_nop, store_nop ;E2 ;NOP
-instr fetch_nop, op_nop, store_nop ;E3 ;NOP
-instr fetch_nop, op_nop, store_nop ;E4 ;NOP
-instr fetch_nop, op_nop, store_nop ;E5 ;NOP
-instr fetch_nop, op_nop, store_nop ;E6 ;NOP
-instr fetch_nop, op_nop, store_nop ;E7 ;NOP
-instr fetch_nop, op_nop, store_nop ;E8 ;NOP
-instr fetch_nop, op_nop, store_nop ;E9 ;NOP
-instr fetch_nop, op_nop, store_nop ;EA ;NOP
-instr fetch_nop, op_nop, store_nop ;EB ;NOP
-instr fetch_nop, op_nop, store_nop ;EC ;NOP
-instr fetch_nop, op_nop, store_nop ;ED ;NOP
-instr fetch_nop, op_nop, store_nop ;EE ;NOP
-instr fetch_nop, op_nop, store_nop ;EF ;NOP
-instr fetch_nop, op_nop, store_nop ;F0 ;NOP
-instr fetch_nop, op_nop, store_nop ;F1 ;NOP
-instr fetch_nop, op_nop, store_nop ;F2 ;NOP
-instr fetch_nop, op_nop, store_nop ;F3 ;NOP
-instr fetch_nop, op_nop, store_nop ;F4 ;NOP
-instr fetch_nop, op_nop, store_nop ;F5 ;NOP
-instr fetch_nop, op_nop, store_nop ;F6 ;NOP
-instr fetch_nop, op_nop, store_nop ;F7 ;NOP
-instr fetch_nop, op_nop, store_nop ;F8 ;NOP
-instr fetch_nop, op_nop, store_nop ;F9 ;NOP
-instr fetch_nop, op_nop, store_nop ;FA ;NOP
-instr fetch_nop, op_nop, store_nop ;FB ;NOP
-instr fetch_nop, op_nop, store_nop ;FC ;NOP
-instr fetch_nop, op_nop, store_nop ;FD ;NOP
-instr fetch_nop, op_nop, store_nop ;FE ;NOP
-instr fetch_nop, op_nop, store_nop ;FF ;NOP
+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_nop, op_nop, store_nop ;2F ;
+instr fetch_nop, op_nop, store_nop ;30 ;
+instr fetch_nop, op_nop, store_nop ;31 ;
+instr fetch_nop, op_nop, store_nop ;32 ;
+instr fetch_nop, op_nop, store_nop ;33 ;
+instr fetch_MXX, op_INC, store_MXX ;34 ;INC (xx+d)
+instr fetch_MXX, op_DEC, store_MXX ;35 ;DEC (xx+d)
+instr fetch_DIR8, op_nop, store_MXX ;36 ;LD (xx+d),n
+instr fetch_nop, op_nop, store_nop ;37 ;
+instr fetch_nop, op_nop, store_nop ;38 ;
+instr fetch_SP, op_ADDxx, store_nop ;39 ;ADD xx,SP
+instr fetch_nop, op_nop, store_nop ;3A ;
+instr fetch_nop, op_nop, store_nop ;3B ;
+instr fetch_nop, op_nop, store_nop ;3C ;
+instr fetch_nop, op_nop, store_nop ;3D ;
+instr fetch_nop, op_nop, store_nop ;3E ;
+instr fetch_nop, op_nop, store_nop ;3F ;
+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_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_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_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_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_nop, op_nop, store_nop ;64 ;LD xh,xh
+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_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_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
+instr fetch_E, op_nop, store_MXX ;73 ;LD (xx+d),E
+instr fetch_H, op_nop, store_MXX ;74 ;LD (xx+d),H
+instr fetch_L, op_nop, store_MXX ;75 ;LD (xx+d),L
+instr fetch_nop, op_nop, store_nop ;76 ;
+instr fetch_A, op_nop, store_MXX ;77 ;LD (xx+d),A
+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_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_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_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_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_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_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_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_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_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 ;
+instr fetch_nop, op_nop, store_nop ;C1 ;
+instr fetch_nop, op_nop, store_nop ;C2 ;
+instr fetch_nop, op_nop, store_nop ;C3 ;
+instr fetch_nop, op_nop, store_nop ;C4 ;
+instr fetch_nop, op_nop, store_nop ;C5 ;
+instr fetch_nop, op_nop, store_nop ;C6 ;
+instr fetch_nop, op_nop, store_nop ;C7 ;
+instr fetch_nop, op_nop, store_nop ;C8 ;
+instr fetch_nop, op_nop, store_nop ;C9 ;
+instr fetch_nop, op_nop, store_nop ;CA ;
+instr fetch_nop, op_nop, store_nop ;CB ;
+instr fetch_nop, op_nop, store_nop ;CC ;
+instr fetch_nop, op_nop, store_nop ;CD ;
+instr fetch_nop, op_nop, store_nop ;CE ;
+instr fetch_nop, op_nop, store_nop ;CF ;
+instr fetch_nop, op_nop, store_nop ;D0 ;
+instr fetch_nop, op_nop, store_nop ;D1 ;
+instr fetch_nop, op_nop, store_nop ;D2 ;
+instr fetch_nop, op_nop, store_nop ;D3 ;
+instr fetch_nop, op_nop, store_nop ;D4 ;
+instr fetch_nop, op_nop, store_nop ;D5 ;
+instr fetch_nop, op_nop, store_nop ;D6 ;
+instr fetch_nop, op_nop, store_nop ;D7 ;
+instr fetch_nop, op_nop, store_nop ;D8 ;
+instr fetch_nop, op_nop, store_nop ;D9 ;
+instr fetch_nop, op_nop, store_nop ;DA ;
+instr fetch_nop, op_nop, store_nop ;DB ;
+instr fetch_nop, op_nop, store_nop ;DC ;
+instr fetch_nop, op_nop, store_nop ;DD ;
+instr fetch_nop, op_nop, store_nop ;DE ;
+instr fetch_nop, op_nop, store_nop ;DF ;
+instr fetch_nop, op_nop, store_nop ;E0 ;
+instr fetch_nop, op_POP16, store_xx ;E1 ;POP xx
+instr fetch_nop, op_nop, store_nop ;E2 ;
+instr fetch_MSP, op_EXxx, store_MSP ;E3 ;EX (SP),xx
+instr fetch_nop, op_nop, store_nop ;E4 ;
+instr fetch_xx, op_PUSH16, store_nop ;E5 ;PUSH xx
+instr fetch_nop, op_nop, store_nop ;E6 ;
+instr fetch_nop, op_nop, store_nop ;E7 ;
+instr fetch_nop, op_nop, store_nop ;E8 ;
+instr fetch_xx, op_nop, store_PC ;E9 ;JP xx
+instr fetch_nop, op_nop, store_nop ;EA ;
+instr fetch_nop, op_nop, store_nop ;EB ;
+instr fetch_nop, op_nop, store_nop ;EC ;
+instr fetch_nop, op_nop, store_nop ;ED ;
+instr fetch_nop, op_nop, store_nop ;EE ;
+instr fetch_nop, op_nop, store_nop ;EF ;
+instr fetch_nop, op_nop, store_nop ;F0 ;
+instr fetch_nop, op_nop, store_nop ;F1 ;
+instr fetch_nop, op_nop, store_nop ;F2 ;
+instr fetch_nop, op_nop, store_nop ;F3 ;
+instr fetch_nop, op_nop, store_nop ;F4 ;
+instr fetch_nop, op_nop, store_nop ;F5 ;
+instr fetch_nop, op_nop, store_nop ;F6 ;
+instr fetch_nop, op_nop, store_nop ;F7 ;
+instr fetch_nop, op_nop, store_nop ;F8 ;
+instr fetch_xx, op_nop, store_SP ;F9 ;LD SP,xx
+instr fetch_nop, op_nop, store_nop ;FA ;
+instr fetch_nop, op_nop, store_nop ;FB ;
+instr fetch_nop, op_nop, store_nop ;FC ;
+instr fetch_nop, op_nop, store_nop ;FD ;
+instr fetch_nop, op_nop, store_nop ;FE ;
+instr fetch_nop, op_nop, store_nop ;FF ;
opctable CBjmp