-; 8080 Interpreter.
+; 8080/Z80 Interpreter.
; This is part of the Z80-CP/M emulator written by Sprite_tm.
;
; $Id$
;
+#if EM_Z80
+ #define OPC_TABSTART 0x1a00
+#else
+ #define OPC_TABSTART 0x1200
+#endif
+
.dseg
-
+z_regs:
z_b: .byte 1
z_c: .byte 1
z_d: .byte 1
z_h: .byte 1
z_l: .byte 1
+ .equ oz_b = 0
+ .equ oz_c = 1
+ .equ oz_d = 2
+ .equ oz_e = 3
+ .equ oz_h = 4
+ .equ oz_l = 5
+
+
#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_f2: .byte 1
+z_a2: .byte 1
+ .equ r2ofs = z_b2-z_b
+ .equ oz_b2 = 6
+ .equ oz_c2 = 7
+ .equ oz_d2 = 8
+ .equ oz_e2 = 9
+ .equ oz_h2 = 10
+ .equ oz_l2 = 11
+ .equ oz_f2 = 12
+ .equ oz_a2 = 13
z_xh: .byte 1
z_xl: .byte 1
z_i: .byte 1
z_r: .byte 1
+ .equ oz_xh = 14
+ .equ oz_xl = 15
+ .equ oz_yh = 16
+ .equ oz_yl = 17
+ .equ oz_i = 18
+ .equ oz_r = 19
z_istat: .byte 1
+ .equ oz_istat = 20
.equ IM_MASK = 0x03 ;Mask IM 0..2
.equ IM0 = 0
.equ IFF1 = 2 ;IFF1 Flag
.equ IFF2 = 3 ;IFF2 Flag
- .equ r2ofs = z_b2-z_b
#endif
.cseg
;Init z80
z80_init:
- ldi z_pcl,low (IPLADDR)
- ldi z_pch,high(IPLADDR)
+ ldiw z_pc,IPLADDR
+ ldiw y,z_regs
cbi flags,trace
clr intstat
+
printnewline
-#if INS_DEBUG
- sbr intstat,(1<<i_break)
-#endif
+.if INS_DEBUG
+ sbr intstat,(1<<i_trace)
+.endif
printstring "Ok, "CPUSTR"-CPU is live!"
printnewline
;
; opctable opc_name
;
+#if EM_Z80
+ .equ numtabs_ = 5
+#else
+ .equ numtabs_ = 1
+#endif
+
.macro opctable
.ifndef opc_tabnext_
- .set opc_tabnext_ = ((PC+255) & 0xff00)
- .set opc_tablow_ = opc_tabnext_
- .endif
-
- .if opc_tabnext_ < PC
- .set opc_tabnext_ = ((PC+255) & 0xff00)
- .set opc_tablow_ = opc_tabnext_
+ .if OPC_TABSTART & 0x00ff
+ .error "OPC_TABSTART is not page aligned!"
+ .endif
+ .set opc_tabnext_ = OPC_TABSTART
+ .equ opc_tablow_ = opc_tabnext_
+ .equ opc_tabend_ = opc_tablow_ + (256 * numtabs_) + 128
+ .equ sz53p_table_pos = opc_tablow_ + (256 * numtabs_)
.endif
.set opcjmp_table_pos_ = opc_tabnext_
.equ @0 = opcjmp_table_pos_
- .set todo_table_pos_ = PC
+ .set todo_table_pos_ = 0
+
.endm
-
;--------------------------------------------------
; Generate a table entry for one instruction
;
.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 longdist_ = 0
+ .set pc_save_ = PC
.org opcjmp_table_pos_
.set opcjmp_table_pos_ = opcjmp_table_pos_ + 1
ret ; go back to main
.elif cnt_ == 1 ; jump direct to action
.if fetch_ ;
- rjmp do_@0 ;
+ .if (PC - do_@0) > 2047
+ .set longdist_ = 1
+ .else
+ rjmp do_@0 ; do op and return to main
+ .endif
.endif
.if op_
- rjmp do_@1 ; do op and return to main
+ .if (PC - do_@1) > 2047
+ .set longdist_ = 1
+ .else
+ rjmp do_@1 ; do op and return to main
+ .endif
.endif
.if store_ ;
- rjmp do_@2 ;
+ .if (PC - do_@2) > 2047
+ .set longdist_ = 1
+ .else
+ rjmp do_@2 ; do op and return to main
+ .endif
.endif
- .else
+ .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 defined do_@0_@1_@2 ; same combination of fetch/op/store allready present?
- rjmp do_@0_@1_@2 ; generate a jump to action table
- .else
+ .if labelexists_ ; same combination of fetch/op/store allready present?
+ .if (PC - l_@0_@1_@2) <= 2047
+ rjmp l_@0_@1_@2 ; generate a jump to action table
+ .set done_ = 1
+ .endif
+ .endif
+
+ .if !done_
- .if todo_table_pos_ < opc_tabnext_
- .if todo_table_pos_ + 3 > opc_tablow_
- .set todo_table_pos_ = opc_tabnext_
+ .if todo_table_pos_ == 0
+ .set todo_table_pos_ = opcjmp_table_pos_ - 2048
+ .if todo_table_pos_ < pc_save_
+ .set todo_table_pos_ = pc_save_
.endif
.endif
- .equ do_@0_@1_@2 = todo_table_pos_ ; make a label
- rjmp do_@0_@1_@2 ; generate a jump to action table
+ .if todo_table_pos_ < opc_tablow_
+ .if todo_table_pos_ + 2*cnt_ > opc_tablow_
+ .set todo_table_pos_ = opc_tabend_
+ .endif
+ .endif
+
+ .if labelexists_
+ rjmp todo_table_pos_
+ .org todo_table_pos_
+ jmp l_@0_@1_@2
+ .set todo_table_pos_ = PC
+ .set done_ = 1
+ .endif
+ .endif
- .org do_@0_@1_@2
+ .if !done_
+
+ .equ l_@0_@1_@2 = todo_table_pos_ ; make a label
+ rjmp l_@0_@1_@2 ; generate a jump to action table
+
+ .org l_@0_@1_@2
.if fetch_ ; must fetch
- .if op_ || store_
- lcall do_@0 ; fetch and come back here
- .else ;
- ljmp do_@0 ; fetch and return to main
+ .if op_ || store_
+ .if do_@0 == 0
+ m_do_@0
+ .else
+ lcall do_@0 ; fetch and come back here
+ .endif
+ .else
+ .if do_@0 == 0
+ m_do_@0
+ ret
+ .else
+ ljmp do_@0 ; do op and return to main
+ .endif
.endif
.endif
.if op_ ; must exec op
.if store_
- lcall do_@1 ; do op and come back here
+ .if do_@1 == 0
+ m_do_@1
+ .else
+ lcall do_@1 ; fetch and come back here
+ .endif
.else
- ljmp do_@1 ; do op and return to main
+ .if do_@1 == 0
+ m_do_@1
+ ret
+ .else
+ ljmp do_@1 ; do op and return to main
+ .endif
.endif
.endif
- .if store_ ; must store
- ljmp do_@2 ; store is allways last
+ .if store_ ; must store
+ .if do_@2 == 0
+ m_do_@2
+ ret
+ .else
+ ljmp do_@2 ; store is allways last
+ .endif
.endif
-
+
.set todo_table_pos_ = PC
.endif
.endif
- .org todo_table_pos_
+ .if todo_table_pos_ == 0
+ .org pc_save_
+ .else
+ .org todo_table_pos_
+ .endif
.endm
-
+
+do_x_nop:
+ ret
+
; ------------ Fetch phase stuff -----------------
-;.org (PC+255) & 0xff00
fetch_ops:
-do_fetch_nop:
- ret
+.equ do_fetch_nop = do_x_nop
+
-do_fetch_a:
+.macro m_do_fetch_a
mov opl,z_a
- ret
+.endm
-do_fetch_b:
- lds opl,z_b
- ret
+.equ do_fetch_a = 0
+; mov opl,z_a
+; ret
-do_fetch_c:
- lds opl,z_c
- ret
+.macro m_do_fetch_b
+ ldd opl,y+oz_b
+.endm
-do_fetch_d:
- lds opl,z_d
- ret
+.equ do_fetch_b = 0
+; ldd opl,y+oz_b
+; ret
-do_fetch_e:
- lds opl,z_e
- ret
+.macro m_do_fetch_c
+ ldd opl,y+oz_c
+.endm
-do_fetch_h:
- lds opl,z_h
- ret
+.equ do_fetch_c = 0
+; ldd opl,y+oz_c
+; ret
-do_fetch_l:
- lds opl,z_l
- ret
+.macro m_do_fetch_d
+ ldd opl,y+oz_d
+.endm
+
+.equ do_fetch_d = 0
+; ldd opl,y+oz_d
+; ret
+
+.macro m_do_fetch_e
+ ldd opl,y+oz_e
+.endm
+
+.equ do_fetch_e = 0
+; ldd opl,y+oz_e
+; ret
+
+.macro m_do_fetch_h
+ ldd opl,y+oz_h
+.endm
+
+.equ do_fetch_h = 0
+; ldd opl,y+oz_h
+; ret
+
+.macro m_do_fetch_l
+ ldd opl,y+oz_l
+.endm
+
+.equ do_fetch_l = 0
+; ldd opl,y+oz_l
+; ret
do_fetch_af:
mov opl,z_flags
ret
do_fetch_bc:
- lds opl,z_c
- lds oph,z_b
+ ldd opl,y+oz_c
+ ldd oph,y+oz_b
ret
do_fetch_de:
- lds opl,z_e
- lds oph,z_d
+ ldd opl,y+oz_e
+ ldd oph,y+oz_d
ret
do_fetch_hl:
- lds opl,z_l
- lds oph,z_h
+ ldd opl,y+oz_l
+ ldd oph,y+oz_h
ret
-do_fetch_sp:
+.macro m_do_fetch_sp
movw opl,z_spl
- ret
+.endm
+
+.equ do_fetch_sp = 0
+; movw opl,z_spl
+; ret
do_fetch_mbc:
- lds xh,z_b
- lds xl,z_c
+ ldd xh,y+oz_b
+ ldd xl,y+oz_c
mem_read_d z_a
ret
do_fetch_mde:
- lds xh,z_d
- lds xl,z_e
+ ldd xh,y+oz_d
+ ldd xl,y+oz_e
mem_read_d z_a
ret
do_fetch_mhl:
- lds xh,z_h
- lds xl,z_l
+ ldd xh,y+oz_h
+ ldd xl,y+oz_l
mem_read_d opl
ret
; ------------ Store phase stuff -----------------
-;.org (PC+255) & 0xff00
store_ops:
-do_store_nop:
- ret
+.equ do_store_nop = do_x_nop
+
do_store_a:
mov z_a,opl
ret
+;.macro m_do_store_b
+; std y+oz_b,opl
+;.endm
+;.equ do_store_b = 0
do_store_b:
- sts z_b,opl
+ std y+oz_b,opl
ret
do_store_c:
- sts z_c,opl
+ std y+oz_c,opl
ret
do_store_d:
- sts z_d,opl
+ std y+oz_d,opl
ret
do_store_e:
- sts z_e,opl
+ std y+oz_e,opl
ret
do_store_h:
- sts z_h,opl
+ std y+oz_h,opl
ret
do_store_l:
- sts z_l,opl
+ std y+oz_l,opl
ret
do_store_af:
ret
do_store_bc:
- sts z_b,oph
- sts z_c,opl
+ std y+oz_b,oph
+ std y+oz_c,opl
ret
do_store_de:
- sts z_d,oph
- sts z_e,opl
+ std y+oz_d,oph
+ std y+oz_e,opl
ret
do_store_hl:
- sts z_h,oph
- sts z_l,opl
+ std y+oz_h,oph
+ std y+oz_l,opl
ret
do_store_mbc:
- lds xh,z_b
- lds xl,z_c
+ ldd xh,y+oz_b
+ ldd xl,y+oz_c
mem_write_s z_a
ret
do_store_mde:
- lds xh,z_d
- lds xl,z_e
+ ldd xh,y+oz_d
+ ldd xl,y+oz_e
mem_write_s z_a
ret
do_store_mhl:
- lds xh,z_h
- lds xl,z_l
+ ldd xh,y+oz_h
+ ldd xl,y+oz_l
mem_write_s opl
ret
mem_write_ds op, z_a
ret
-
; ------------ Operation phase stuff -----------------
;----------------------------------------------------------------
;----------------------------------------------------------------
+.equ do_op_nop = do_x_nop
+
do_op_inv:
sbiw z_pcl,1
lcall printregs
haltinv:
rjmp haltinv
-do_op_nop:
- ret
;----------------------------------------------------------------
;|Mnemonic |SZHPNC|Description |Notes |
printstring "CPU halted! "
ret
-
;----------------------------------------------------------------
;|Mnemonic |SZHPNC|Description |Notes |
;----------------------------------------------------------------
.endif
mov temp,z_a
mov temp2,opl
- lcall portWrite
+ lcall portWrite
ret
;----------------------------------------------------------------
;
;
do_op_xora:
- eor z_a,opl
+ eor z_a,opl
ldpmx z_flags,sz53p_tab,z_a ;S,Z,H,P,N,C
do_z80_flags_op_or
ret
;
;
do_op_addhl:
- lds temp,z_l
- lds temp2,z_h
- add opl,temp
- adc oph,temp2
- sts z_l,opl
- sts z_h,oph
- in temp,sreg
+ ldd temp,y+oz_l
+ ldd temp2,y+oz_h
+ add opl,temp
+ adc oph,temp2
+ std y+oz_l,opl
+ std y+oz_h,oph
+ in temp,sreg
bmov z_flags,ZFL_C, temp,AVR_C
do_z80_flags_H
do_z80_flags_clear_N
;
;
do_op_sthl: ;store hl to mem loc in opl:h
- movw xl,opl
- lds temp,z_l
+ movw xl,opl
+ ldd temp,y+oz_l
mem_write
- adiw xl,1
- lds temp,z_h
+ adiw xl,1
+ ldd temp,y+oz_h
mem_write
ret
;-----------------------------Z80--------------------------------
;
do_op_exhl:
- lds temp,z_l
- lds temp2,z_h
- sts z_l,opl
- sts z_h,oph
+ ldd temp,y+oz_l
+ ldd temp2,y+oz_h
+ std y+oz_l,opl
+ std y+oz_h,oph
movw opl,temp
ret
;
do_op_DI:
- lds temp,z_istat
+#if EM_Z80
+ ldd temp,y+oz_istat
andi temp,~((1<<IFF2) | (1<<IFF1))
- sts z_istat,temp
+ std y+oz_istat,temp
+#endif
ret
do_op_EI:
- lds temp,z_istat
+#if EM_Z80
+ ldd temp,y+oz_istat
ori temp,(1<<IFF2) | (1<<IFF1)
- sts z_istat,temp
+ std y+oz_istat,temp
+#endif
ret
;----------------------------------------------------------------
;
do_op_djnz:
- lds temp,z_b
+ ldd temp,y+oz_b
dec temp
- sts z_b,temp
+ std y+oz_b,temp
brne opdjnze
pop temp ; nix tun
pop temp ; direkt zuruech zu main
;|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
+ ldd temp,y+oz_f2
+ ldd temp2,y+oz_a2
+ std y+oz_f2,z_flags
+ std y+oz_a2,z_a
mov z_flags,temp
mov z_a,temp2
ret
do_op_prefixDDFDCB:
- mem_read_ds temp4,z_pc ;temp4 = displacement
- adiw z_pcl,1 ;++z_pc
+ sbic flags,prefixfd
+ rjmp opprxcb_fd
+ ldd xh,y+oz_xh
+ ldd xl,y+oz_xl
+ rjmp opprxcb_1
+opprxcb_fd:
+ ldd xh,y+oz_yh
+ ldd xl,y+oz_yl
+opprxcb_1:
+ mem_read_s z_pc ;get displacement
+ adiw z_pcl,1 ;++z_pc
+ clr temp2 ;sign extend
+ tst temp
+ brpl PC+2
+ com temp2
+ add xl,temp ;add displacement
+ adc xh,temp2
+ mem_read_d opl
+
mem_read_ds zl,z_pc ;zl = opcode
adiw z_pcl,1 ;++z_pc
- ldi zh,high(DDFDCBjmp) ;
- ijmp
+ ldi zh,high(DDFDCBjmp) ;
+ icall
+ mem_write_s opl
+ ret
#else ; TODO: geht das so?
instr fetch_DIR16, op_IFC, store_PC ;DA nn nn ;JP C,nn
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_nop, op_prefixDD, store_nop ;DD ;(DD opcode prefix)
instr fetch_DIR8, op_SBCFA, store_nop ;DE nn ;SBC A,n
instr fetch_RST, op_nop, store_CALL ;DF ;RST 18H
instr fetch_nop, op_IFPO, store_RET ;E0 ;RET PO
#if EM_Z80
+
+
do_fetch_0:
ldi opl,0
ret
do_op_out: ; out (c),opl
mov temp,opl
- lds temp2,z_c
+ ldd temp2,y+oz_c
lcall portWrite
ret
do_op_stbc: ;store bc to mem loc in opl:h
movw xl,opl
- lds temp,z_c
+ ldd temp,y+oz_c
mem_write
adiw xl,1
- lds temp,z_b
+ ldd temp,y+oz_b
mem_write
ret
;
do_op_stde: ;store de to mem loc in opl:h
movw xl,opl
- lds temp,z_e
+ ldd temp,y+oz_e
mem_write
adiw xl,1
- lds temp,z_d
+ ldd temp,y+oz_d
mem_write
ret
;
do_op_ADCHL:
- lds temp,z_l
- lds temp2,z_h
+ ldd temp,y+oz_l
+ ldd temp2,y+oz_h
clc
sbrc z_flags,ZFL_C
sec
in temp,sreg ; save lower Z
adc oph,temp2
in temp2,sreg
- sts z_l,opl
- sts z_h,oph
+ std y+oz_l,opl
+ std y+oz_h,oph
and temp,temp2 ; 16bit Z
ldi z_flags,0 ; clear N
bmov z_flags,ZFL_C, temp2,AVR_C
;
;
do_op_sbchl:
- lds temp,z_l
- lds temp2,z_h
+ ldd temp,y+oz_l
+ ldd temp2,y+oz_h
cp temp,opl ; set z
clc
sbrc z_flags,ZFL_C
sec
sbc temp,opl
sbc temp2,oph
- sts z_l,temp
- sts z_h,temp2
+ std y+oz_l,temp
+ std y+oz_h,temp2
in temp,sreg
ldi z_flags,(1<<ZFL_N) ; set N
bmov z_flags,ZFL_C, temp,AVR_C
do_op_RETI:
do_op_RETN:
- lds temp,z_istat
+ ldd temp,y+oz_istat
bmov temp,IFF1, temp,IFF2
- sts z_istat,temp
+ std y+oz_istat,temp
ljmp do_store_ret
;|IM n |------|Interrupt Mode | (n=0,1,2)|
do_op_IM0:
- lds temp,z_istat
+ ldd temp,y+oz_istat
andi temp, ~IM_MASK
- sts z_istat,temp
+ std y+oz_istat,temp
ret
do_op_IM1:
- lds temp,z_istat
+ ldd temp,y+oz_istat
andi temp,~IM_MASK
ori temp,IM1
- sts z_istat,temp
+ std y+oz_istat,temp
ret
do_op_IM2:
- lds temp,z_istat
+ ldd temp,y+oz_istat
andi temp, ~IM_MASK
ori temp,IM2
- sts z_istat,temp
+ std y+oz_istat,temp
ret
;----------------------------------------------------------------
;|LD i,A |------|Load |(i=I,R) |
do_op_ldai:
- lds z_a,z_i
+ ldd z_a,y+oz_i
rjmp op_ldar1
do_op_ldar:
- lds z_a,z_r
+ ldd z_a,y+oz_r
op_ldar1:
bst z_flags,ZFL_C ;save C
ldpmx z_flags,sz53p_tab,z_a ;S,Z,H,P,N
bld z_flags,ZFL_C ;
- lds temp,z_istat
+ ldd temp,y+oz_istat
bmov z_flags,ZFL_P, temp,IFF2
ret
do_op_ldia:
- sts z_i,z_a
+ std y+oz_i,z_a
ret
do_op_ldra:
- sts z_r,z_a
+ std y+oz_r,z_a
ret
;----------------------------------------------------------------
do_fetch_xh:
sbis flags,prefixfd
- lds opl,z_xh
+ ldd opl,y+oz_xh
sbic flags,prefixfd
- lds opl,z_yh
+ ldd opl,y+oz_yh
ret
do_fetch_xl:
sbis flags,prefixfd
- lds opl,z_xl
+ ldd opl,y+oz_xl
sbic flags,prefixfd
- lds opl,z_yl
+ ldd opl,y+oz_yl
ret
do_fetch_mxx:
sbic flags,prefixfd
rjmp fetchmxx_fd
- lds xh,z_xh
- lds xl,z_xl
+ ldd xh,y+oz_xh
+ ldd xl,y+oz_xl
rjmp fetchmxx1
fetchmxx_fd:
- lds xh,z_yh
- lds xl,z_yl
+ ldd xh,y+oz_yh
+ ldd xl,y+oz_yl
fetchmxx1:
mem_read_ds opl, z_pc ;get displacement
adiw z_pcl,1
fetchmxx2:
add xl,opl ;add displacement
adc xh,oph
- mem_read_d opl
+ mem_read_d opl ;get operand
ret
do_fetch_xx:
sbic flags,prefixfd
rjmp fetchxx_fd
- lds opl,z_xl
- lds oph,z_xh
+ ldd opl,y+oz_xl
+ ldd oph,y+oz_xh
ret
fetchxx_fd:
- lds opl,z_yl
- lds oph,z_yh
+ ldd opl,y+oz_yl
+ ldd oph,y+oz_yh
ret
-
do_store_xh:
sbis flags,prefixfd
- sts z_xh,opl
+ std y+oz_xh,opl
sbic flags,prefixfd
- sts z_yh,opl
+ std y+oz_yh,opl
ret
do_store_xl:
sbis flags,prefixfd
- sts z_xl,opl
+ std y+oz_xl,opl
sbic flags,prefixfd
- sts z_yl,opl
+ std y+oz_yl,opl
ret
-
do_store_mxx:
sbic flags,prefixfd
rjmp storemxx_fd
- lds xh,z_xh
- lds xl,z_xl
+ ldd xh,y+oz_xh
+ ldd xl,y+oz_xl
rjmp storemxx1
storemxx_fd:
- lds xh,z_yh
- lds xl,z_yl
+ ldd xh,y+oz_yh
+ ldd xl,y+oz_yl
storemxx1:
mem_read_s z_pc ;get displacement
adiw z_pcl,1
storemxx2:
add xl,temp ;add displacement
adc xh,temp2
- mem_read_d opl
+ mem_write_s opl ;store operand
ret
do_store_xx:
sbic flags,prefixfd
rjmp storexx_fd
- sts z_xl,opl
- sts z_xh,oph
+ std y+oz_xl,opl
+ std y+oz_xh,oph
ret
storexx_fd:
- sts z_yl,opl
- sts z_yh,oph
+ std y+oz_yl,opl
+ std y+oz_yh,oph
ret
-
;----------------------------------------------------------------
;|Mnemonic |SZHPNC|Description |Notes |
;----------------------------------------------------------------
movw xl,opl
sbis flags,prefixfd
- lds temp,z_xl
+ ldd temp,y+oz_xl
sbic flags,prefixfd
- lds temp,z_yl
+ ldd temp,y+oz_yl
mem_write
adiw xl,1
sbis flags,prefixfd
- lds temp,z_xh
+ ldd temp,y+oz_xh
sbic flags,prefixfd
- lds temp,z_yh
+ ldd temp,y+oz_yh
mem_write
ret
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
+ ldd temp,y+oz_xl
+ ldd temp2,y+oz_xh
+ std y+oz_xl,opl
+ std y+oz_xh,oph
rjmp opexxxe
opexxx_fd:
- lds temp,z_yl
- lds temp2,z_yh
- sts z_yl,opl
- sts z_yh,oph
+ ldd temp,y+oz_yl
+ ldd temp2,y+oz_yh
+ std y+oz_yl,opl
+ std y+oz_yh,oph
opexxxe:
movw opl,temp
ret
do_op_addxx:
sbic flags,prefixfd
rjmp opadx_fd
- lds temp,z_xl
- lds temp2,z_xh
- add opl,temp
- adc oph,temp2
- sts z_xl,opl
- sts z_xh,oph
+ ldd temp,y+oz_xl
+ ldd temp2,y+oz_xh
+ add opl,temp
+ adc oph,temp2
+ std y+oz_xl,opl
+ std y+oz_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
+ ldd temp,y+oz_yl
+ ldd temp2,y+oz_yh
+ add opl,temp
+ adc oph,temp2
+ std y+oz_yl,opl
+ std y+oz_yh,oph
opadx_e:
- in temp,sreg
+ in temp,sreg
bmov z_flags,ZFL_C, temp,AVR_C
do_z80_flags_H
do_z80_flags_clear_N
;|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
+ 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:
- 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
+ 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, y
- sbiw y,1
+ 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
- st -z,yl
- st -z,yh
- st -z,xl
- st -z,xh
- st -z,opl
- st -z,oph
+ 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
+ adiw z,1
+ mem_write_ds x, temp
+ adiw x,1
+ subi opl,1
+ sbci oph,0
+ brne opldir_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
+
+;----------------------------------------------------------------
+;|Mnemonic |SZHPNC|Description |Notes |
+;----------------------------------------------------------------
+;|CPD |****1-|Compare and Decrement|A-[HL],HL=HL-1,BC=BC-1|
+;|CPDR |****1-|Compare, Dec., Repeat|CPD till A=[HL]or BC=0|
+;|CPI |****1-|Compare and Increment|A-[HL],HL=HL+1,BC=BC-1|
+;|CPIR |****1-|Compare, Inc., Repeat|CPI till A=[HL]or BC=0|
+
+
+do_op_CPI:
+ 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
+ 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
+ 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
+ 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 |
+;----------------------------------------------------------------
+;|BIT b,m |?*1?0-|Test Bit |m&{2^b} |
+;|RES b,m |------|Reset bit |m=m&{~2^b} |
+;|SET b,m |------|Set bit |m=mv{2^b} |
+
+; .org ((PC+255) & 0xff00) + 0x600
+
do_op_BIT7:
- andi opl,0x80
+ ldi temp,0x80
rjmp opbit
do_op_BIT6:
- andi opl,0x40
+ ldi temp,0x40
rjmp opbit
do_op_BIT5:
- andi opl,0x20
+ ldi temp,0x20
rjmp opbit
do_op_BIT4:
- andi opl,0x10
+ ldi temp,0x10
rjmp opbit
do_op_BIT3:
- andi opl,0x08
+ ldi temp,0x08
rjmp opbit
do_op_BIT2:
- andi opl,0x04
+ ldi temp,0x04
rjmp opbit
do_op_BIT1:
- andi opl,0x02
+ ldi temp,0x02
rjmp opbit
do_op_BIT0:
- andi opl,0x01
+ ldi temp,0x01
opbit:
+ and temp,opl
in temp,sreg
ori z_flags,(1<<ZFL_H)
andi z_flags,~((1<<ZFL_N) | (1<<ZFL_Z))
bmov z_flags,ZFL_Z, temp,AVR_Z
ret
-do_op_RES7:
+
+.macro m_do_op_RES7
andi opl,~0x80
- rjmp opres
-do_op_RES6:
+.endm
+.equ do_op_RES7 = 0
+; andi opl,~0x80
+; ret
+
+.macro m_do_op_RES6
andi opl,~0x40
- rjmp opres
-do_op_RES5:
+.endm
+.equ do_op_RES6 = 0
+; andi opl,~0x40
+; ret
+
+.macro m_do_op_RES5
andi opl,~0x20
- rjmp opres
-do_op_RES4:
+.endm
+.equ do_op_RES5 = 0
+; andi opl,~0x20
+; ret
+
+.macro m_do_op_RES4
andi opl,~0x10
- rjmp opres
-do_op_RES3:
+.endm
+.equ do_op_RES4 = 0
+; andi opl,~0x10
+; ret
+
+.macro m_do_op_RES3
andi opl,~0x08
- rjmp opres
-do_op_RES2:
+.endm
+.equ do_op_RES3 = 0
+; andi opl,~0x08
+; ret
+
+.macro m_do_op_RES2
andi opl,~0x04
- rjmp opres
-do_op_RES1:
+.endm
+.equ do_op_RES2 = 0
+; andi opl,~0x04
+; ret
+
+.macro m_do_op_RES1
andi opl,~0x02
- rjmp opres
-do_op_RES0:
+.endm
+.equ do_op_RES1 = 0
+; andi opl,~0x02
+; ret
+
+.macro m_do_op_RES0
andi opl,~0x01
-opres:
- ; TODO: flags
- in temp,sreg
- ori z_flags,(1<<ZFL_H)
- andi z_flags,~((1<<ZFL_N) | (1<<ZFL_Z))
- bmov z_flags,ZFL_Z, temp,AVR_Z
- ret
+.endm
+.equ do_op_RES0 = 0
+; andi opl,~0x01
+; ret
-do_op_SET7:
+.macro m_do_op_SET7
ori opl,0x80
- rjmp opset
-do_op_SET6:
+.endm
+.equ do_op_SET7 = 0
+; ori opl,0x80
+; ret
+
+.macro m_do_op_SET6
ori opl,0x40
- rjmp opset
-do_op_SET5:
+.endm
+.equ do_op_SET6 = 0
+; ori opl,0x40
+; ret
+
+.macro m_do_op_SET5
ori opl,0x20
- rjmp opset
-do_op_SET4:
+.endm
+.equ do_op_SET5 = 0
+; ori opl,0x20
+; ret
+
+.macro m_do_op_SET4
ori opl,0x10
- rjmp opset
-do_op_SET3:
+.endm
+.equ do_op_SET4 = 0
+; ori opl,0x10
+; ret
+
+.macro m_do_op_SET3
ori opl,0x08
- rjmp opset
-do_op_SET2:
+.endm
+.equ do_op_SET3 = 0
+; ori opl,0x08
+; ret
+
+.macro m_do_op_SET2
ori opl,0x04
- rjmp opset
-do_op_SET1:
+.endm
+.equ do_op_SET2 = 0
+; ori opl,0x04
+; ret
+
+.macro m_do_op_SET1
ori opl,0x02
- rjmp opset
-do_op_SET0:
- ori opl,0x01
-opset:
- ; TODO: flags
- in temp,sreg
- ori z_flags,(1<<ZFL_H)
- andi z_flags,~((1<<ZFL_N) | (1<<ZFL_Z))
- bmov z_flags,ZFL_Z, temp,AVR_Z
- ret
+.endm
+.equ do_op_SET1 = 0
+; ori opl,0x02
+; ret
+.macro m_do_op_SET0
+ ori opl,0x01
+.endm
+.equ do_op_SET0 = 0
+; ori opl,0x01
+; ret
opctable EDjmp
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 ; TODO:
-instr fetch_nop, op_nop, store_nop ;A1 ;
-instr fetch_nop, op_nop, store_nop ;A2 ;
+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_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 ;
-instr fetch_nop, op_nop, store_nop ;A9 ;
-instr fetch_nop, op_nop, store_nop ;AA ;
+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_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 ;
-instr fetch_nop, op_nop, store_nop ;B1 ;
+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 ;
instr fetch_nop, op_nop, store_nop ;B4 ;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_nop, store_nop ;B9 ;
+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_nop, store_nop ;BC ;NOP
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_prefixDDFDCB,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 ;
opctable CBjmp
-
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 ;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_nop, op_BIT0, store_nop ;40 ;BIT 0,(Ix+d),B
+instr fetch_nop, op_BIT0, store_nop ;41 ;BIT 0,(Ix+d),C
+instr fetch_nop, op_BIT0, store_nop ;42 ;BIT 0,(Ix+d),D
+instr fetch_nop, op_BIT0, store_nop ;43 ;BIT 0,(Ix+d),E
+instr fetch_nop, op_BIT0, store_nop ;44 ;BIT 0,(Ix+d),H
+instr fetch_nop, op_BIT0, store_nop ;45 ;BIT 0,(Ix+d),L
+instr fetch_nop, op_BIT0, store_nop ;46 ;BIT 0,(Ix+d)
+instr fetch_nop, op_BIT0, store_nop ;47 ;BIT 0,(Ix+d),A
+instr fetch_nop, op_BIT1, store_nop ;48 ;BIT 1,(Ix+d),B
+instr fetch_nop, op_BIT1, store_nop ;49 ;BIT 1,(Ix+d),C
+instr fetch_nop, op_BIT1, store_nop ;4A ;BIT 1,(Ix+d),D
+instr fetch_nop, op_BIT1, store_nop ;4B ;BIT 1,(Ix+d),E
+instr fetch_nop, op_BIT1, store_nop ;4C ;BIT 1,(Ix+d),H
+instr fetch_nop, op_BIT1, store_nop ;4D ;BIT 1,(Ix+d),L
+instr fetch_nop, op_BIT1, store_nop ;4E ;BIT 1,(Ix+d)
+instr fetch_nop, op_BIT1, store_nop ;4F ;BIT 1,(Ix+d),A
+instr fetch_nop, op_BIT2, store_nop ;50 ;BIT 2,(Ix+d),B
+instr fetch_nop, op_BIT2, store_nop ;51 ;BIT 2,(Ix+d),C
+instr fetch_nop, op_BIT2, store_nop ;52 ;BIT 2,(Ix+d),D
+instr fetch_nop, op_BIT2, store_nop ;53 ;BIT 2,(Ix+d),E
+instr fetch_nop, op_BIT2, store_nop ;54 ;BIT 2,(Ix+d),H
+instr fetch_nop, op_BIT2, store_nop ;55 ;BIT 2,(Ix+d),L
+instr fetch_nop, op_BIT2, store_nop ;56 ;BIT 2,(Ix+d)
+instr fetch_nop, op_BIT2, store_nop ;57 ;BIT 2,(Ix+d),A
+instr fetch_nop, op_BIT3, store_nop ;58 ;BIT 3,(Ix+d),B
+instr fetch_nop, op_BIT3, store_nop ;59 ;BIT 3,(Ix+d),C
+instr fetch_nop, op_BIT3, store_nop ;5A ;BIT 3,(Ix+d),D
+instr fetch_nop, op_BIT3, store_nop ;5B ;BIT 3,(Ix+d),E
+instr fetch_nop, op_BIT3, store_nop ;5C ;BIT 3,(Ix+d),H
+instr fetch_nop, op_BIT3, store_nop ;5D ;BIT 3,(Ix+d),L
+instr fetch_nop, op_BIT3, store_nop ;5E ;BIT 3,(Ix+d)
+instr fetch_nop, op_BIT3, store_nop ;5F ;BIT 3,(Ix+d),A
+instr fetch_nop, op_BIT4, store_nop ;60 ;BIT 4,(Ix+d),B
+instr fetch_nop, op_BIT4, store_nop ;61 ;BIT 4,(Ix+d),C
+instr fetch_nop, op_BIT4, store_nop ;62 ;BIT 4,(Ix+d),D
+instr fetch_nop, op_BIT4, store_nop ;63 ;BIT 4,(Ix+d),E
+instr fetch_nop, op_BIT4, store_nop ;64 ;BIT 4,(Ix+d),H
+instr fetch_nop, op_BIT4, store_nop ;65 ;BIT 4,(Ix+d),L
+instr fetch_nop, op_BIT4, store_nop ;66 ;BIT 4,(Ix+d)
+instr fetch_nop, op_BIT4, store_nop ;67 ;BIT 4,(Ix+d),A
+instr fetch_nop, op_BIT5, store_nop ;68 ;BIT 5,(Ix+d),B
+instr fetch_nop, op_BIT5, store_nop ;69 ;BIT 5,(Ix+d),C
+instr fetch_nop, op_BIT5, store_nop ;6A ;BIT 5,(Ix+d),D
+instr fetch_nop, op_BIT5, store_nop ;6B ;BIT 5,(Ix+d),E
+instr fetch_nop, op_BIT5, store_nop ;6C ;BIT 5,(Ix+d),H
+instr fetch_nop, op_BIT5, store_nop ;6D ;BIT 5,(Ix+d),L
+instr fetch_nop, op_BIT5, store_nop ;6E ;BIT 5,(Ix+d)
+instr fetch_nop, op_BIT5, store_nop ;6F ;BIT 5,(Ix+d),A
+instr fetch_nop, op_BIT6, store_nop ;70 ;BIT 6,(Ix+d),B
+instr fetch_nop, op_BIT6, store_nop ;71 ;BIT 6,(Ix+d),C
+instr fetch_nop, op_BIT6, store_nop ;72 ;BIT 6,(Ix+d),D
+instr fetch_nop, op_BIT6, store_nop ;73 ;BIT 6,(Ix+d),E
+instr fetch_nop, op_BIT6, store_nop ;74 ;BIT 6,(Ix+d),H
+instr fetch_nop, op_BIT6, store_nop ;75 ;BIT 6,(Ix+d),L
+instr fetch_nop, op_BIT6, store_nop ;76 ;BIT 6,(Ix+d)
+instr fetch_nop, op_BIT6, store_nop ;77 ;BIT 6,(Ix+d),A
+instr fetch_nop, op_BIT7, store_nop ;78 ;BIT 7,(Ix+d),B
+instr fetch_nop, op_BIT7, store_nop ;79 ;BIT 7,(Ix+d),C
+instr fetch_nop, op_BIT7, store_nop ;7A ;BIT 7,(Ix+d),D
+instr fetch_nop, op_BIT7, store_nop ;7B ;BIT 7,(Ix+d),E
+instr fetch_nop, op_BIT7, store_nop ;7C ;BIT 7,(Ix+d),H
+instr fetch_nop, op_BIT7, store_nop ;7D ;BIT 7,(Ix+d),L
+instr fetch_nop, op_BIT7, store_nop ;7E ;BIT 7,(Ix+d)
+instr fetch_nop, op_BIT7, store_nop ;7F ;BIT 7,(Ix+d),A
+instr fetch_nop, op_RES0, store_B ;80 ;RES 0,(Ix+d),B
+instr fetch_nop, op_RES0, store_C ;81 ;RES 0,(Ix+d),C
+instr fetch_nop, op_RES0, store_D ;82 ;RES 0,(Ix+d),D
+instr fetch_nop, op_RES0, store_E ;83 ;RES 0,(Ix+d),E
+instr fetch_nop, op_RES0, store_H ;84 ;RES 0,(Ix+d),H
+instr fetch_nop, op_RES0, store_L ;85 ;RES 0,(Ix+d),L
+instr fetch_nop, op_RES0, store_nop ;86 ;RES 0,(Ix+d)
+instr fetch_nop, op_RES0, store_A ;87 ;RES 0,(Ix+d),A
+instr fetch_nop, op_RES1, store_B ;88 ;RES 1,(Ix+d),B
+instr fetch_nop, op_RES1, store_C ;89 ;RES 1,(Ix+d),C
+instr fetch_nop, op_RES1, store_D ;8A ;RES 1,(Ix+d),D
+instr fetch_nop, op_RES1, store_E ;8B ;RES 1,(Ix+d),E
+instr fetch_nop, op_RES1, store_H ;8C ;RES 1,(Ix+d),H
+instr fetch_nop, op_RES1, store_L ;8D ;RES 1,(Ix+d),L
+instr fetch_nop, op_RES1, store_nop ;8E ;RES 1,(Ix+d)
+instr fetch_nop, op_RES1, store_A ;8F ;RES 1,(Ix+d),A
+instr fetch_nop, op_RES2, store_B ;90 ;RES 2,(Ix+d),B
+instr fetch_nop, op_RES2, store_C ;91 ;RES 2,(Ix+d),C
+instr fetch_nop, op_RES2, store_D ;92 ;RES 2,(Ix+d),D
+instr fetch_nop, op_RES2, store_E ;93 ;RES 2,(Ix+d),E
+instr fetch_nop, op_RES2, store_H ;94 ;RES 2,(Ix+d),H
+instr fetch_nop, op_RES2, store_L ;95 ;RES 2,(Ix+d),L
+instr fetch_nop, op_RES2, store_nop ;96 ;RES 2,(Ix+d)
+instr fetch_nop, op_RES2, store_A ;97 ;RES 2,(Ix+d),A
+instr fetch_nop, op_RES3, store_B ;98 ;RES 3,(Ix+d),B
+instr fetch_nop, op_RES3, store_C ;99 ;RES 3,(Ix+d),C
+instr fetch_nop, op_RES3, store_D ;9A ;RES 3,(Ix+d),D
+instr fetch_nop, op_RES3, store_E ;9B ;RES 3,(Ix+d),E
+instr fetch_nop, op_RES3, store_H ;9C ;RES 3,(Ix+d),H
+instr fetch_nop, op_RES3, store_L ;9D ;RES 3,(Ix+d),L
+instr fetch_nop, op_RES3, store_nop ;9E ;RES 3,(Ix+d)
+instr fetch_nop, op_RES3, store_A ;9F ;RES 3,(Ix+d),A
+instr fetch_nop, op_RES4, store_B ;A0 ;RES 4,(Ix+d),B
+instr fetch_nop, op_RES4, store_C ;A1 ;RES 4,(Ix+d),C
+instr fetch_nop, op_RES4, store_D ;A2 ;RES 4,(Ix+d),D
+instr fetch_nop, op_RES4, store_E ;A3 ;RES 4,(Ix+d),E
+instr fetch_nop, op_RES4, store_H ;A4 ;RES 4,(Ix+d),H
+instr fetch_nop, op_RES4, store_L ;A5 ;RES 4,(Ix+d),L
+instr fetch_nop, op_RES4, store_nop ;A6 ;RES 4,(Ix+d)
+instr fetch_nop, op_RES4, store_A ;A7 ;RES 4,(Ix+d),A
+instr fetch_nop, op_RES5, store_B ;A8 ;RES 5,(Ix+d),B
+instr fetch_nop, op_RES5, store_C ;A9 ;RES 5,(Ix+d),C
+instr fetch_nop, op_RES5, store_D ;AA ;RES 5,(Ix+d),D
+instr fetch_nop, op_RES5, store_E ;AB ;RES 5,(Ix+d),E
+instr fetch_nop, op_RES5, store_H ;AC ;RES 5,(Ix+d),H
+instr fetch_nop, op_RES5, store_L ;AD ;RES 5,(Ix+d),L
+instr fetch_nop, op_RES5, store_nop ;AE ;RES 5,(Ix+d)
+instr fetch_nop, op_RES5, store_A ;AF ;RES 5,(Ix+d),A
+instr fetch_nop, op_RES6, store_B ;B0 ;RES 6,(Ix+d),B
+instr fetch_nop, op_RES6, store_C ;B1 ;RES 6,(Ix+d),C
+instr fetch_nop, op_RES6, store_D ;B2 ;RES 6,(Ix+d),D
+instr fetch_nop, op_RES6, store_E ;B3 ;RES 6,(Ix+d),E
+instr fetch_nop, op_RES6, store_H ;B4 ;RES 6,(Ix+d),H
+instr fetch_nop, op_RES6, store_L ;B5 ;RES 6,(Ix+d),L
+instr fetch_nop, op_RES6, store_nop ;B6 ;RES 6,(Ix+d)
+instr fetch_nop, op_RES6, store_A ;B7 ;RES 6,(Ix+d),A
+instr fetch_nop, op_RES7, store_B ;B8 ;RES 7,(Ix+d),B
+instr fetch_nop, op_RES7, store_C ;B9 ;RES 7,(Ix+d),C
+instr fetch_nop, op_RES7, store_D ;BA ;RES 7,(Ix+d),D
+instr fetch_nop, op_RES7, store_E ;BB ;RES 7,(Ix+d),E
+instr fetch_nop, op_RES7, store_H ;BC ;RES 7,(Ix+d),H
+instr fetch_nop, op_RES7, store_L ;BD ;RES 7,(Ix+d),L
+instr fetch_nop, op_RES7, store_nop ;BE ;RES 7,(Ix+d)
+instr fetch_nop, op_RES7, store_A ;BF ;RES 7,(Ix+d),A
+instr fetch_nop, op_SET0, store_B ;C0 ;SET 0,(Ix+d),B
+instr fetch_nop, op_SET0, store_C ;C1 ;SET 0,(Ix+d),C
+instr fetch_nop, op_SET0, store_D ;C2 ;SET 0,(Ix+d),D
+instr fetch_nop, op_SET0, store_E ;C3 ;SET 0,(Ix+d),E
+instr fetch_nop, op_SET0, store_H ;C4 ;SET 0,(Ix+d),H
+instr fetch_nop, op_SET0, store_L ;C5 ;SET 0,(Ix+d),L
+instr fetch_nop, op_SET0, store_nop ;C6 ;SET 0,(Ix+d)
+instr fetch_nop, op_SET0, store_A ;C7 ;SET 0,(Ix+d),A
+instr fetch_nop, op_SET1, store_B ;C8 ;SET 1,(Ix+d),B
+instr fetch_nop, op_SET1, store_C ;C9 ;SET 1,(Ix+d),C
+instr fetch_nop, op_SET1, store_D ;CA ;SET 1,(Ix+d),D
+instr fetch_nop, op_SET1, store_E ;CB ;SET 1,(Ix+d),E
+instr fetch_nop, op_SET1, store_H ;CC ;SET 1,(Ix+d),H
+instr fetch_nop, op_SET1, store_L ;CD ;SET 1,(Ix+d),L
+instr fetch_nop, op_SET1, store_nop ;CE ;SET 1,(Ix+d)
+instr fetch_nop, op_SET1, store_A ;CF ;SET 1,(Ix+d),A
+instr fetch_nop, op_SET2, store_B ;D0 ;SET 2,(Ix+d),B
+instr fetch_nop, op_SET2, store_C ;D1 ;SET 2,(Ix+d),C
+instr fetch_nop, op_SET2, store_D ;D2 ;SET 2,(Ix+d),D
+instr fetch_nop, op_SET2, store_E ;D3 ;SET 2,(Ix+d),E
+instr fetch_nop, op_SET2, store_H ;D4 ;SET 2,(Ix+d),H
+instr fetch_nop, op_SET2, store_L ;D5 ;SET 2,(Ix+d),L
+instr fetch_nop, op_SET2, store_nop ;D6 ;SET 2,(Ix+d)
+instr fetch_nop, op_SET2, store_A ;D7 ;SET 2,(Ix+d),A
+instr fetch_nop, op_SET3, store_B ;D8 ;SET 3,(Ix+d),B
+instr fetch_nop, op_SET3, store_C ;D9 ;SET 3,(Ix+d),C
+instr fetch_nop, op_SET3, store_D ;DA ;SET 3,(Ix+d),D
+instr fetch_nop, op_SET3, store_E ;DB ;SET 3,(Ix+d),E
+instr fetch_nop, op_SET3, store_H ;DC ;SET 3,(Ix+d),H
+instr fetch_nop, op_SET3, store_L ;DD ;SET 3,(Ix+d),L
+instr fetch_nop, op_SET3, store_nop ;DE ;SET 3,(Ix+d)
+instr fetch_nop, op_SET3, store_A ;DF ;SET 3,(Ix+d),A
+instr fetch_nop, op_SET4, store_B ;E0 ;SET 4,(Ix+d),B
+instr fetch_nop, op_SET4, store_C ;E1 ;SET 4,(Ix+d),C
+instr fetch_nop, op_SET4, store_D ;E2 ;SET 4,(Ix+d),D
+instr fetch_nop, op_SET4, store_E ;E3 ;SET 4,(Ix+d),E
+instr fetch_nop, op_SET4, store_H ;E4 ;SET 4,(Ix+d),H
+instr fetch_nop, op_SET4, store_L ;E5 ;SET 4,(Ix+d),L
+instr fetch_nop, op_SET4, store_nop ;E6 ;SET 4,(Ix+d)
+instr fetch_nop, op_SET4, store_A ;E7 ;SET 4,(Ix+d),A
+instr fetch_nop, op_SET5, store_B ;E8 ;SET 5,(Ix+d),B
+instr fetch_nop, op_SET5, store_C ;E9 ;SET 5,(Ix+d),C
+instr fetch_nop, op_SET5, store_D ;EA ;SET 5,(Ix+d),D
+instr fetch_nop, op_SET5, store_E ;EB ;SET 5,(Ix+d),E
+instr fetch_nop, op_SET5, store_H ;EC ;SET 5,(Ix+d),H
+instr fetch_nop, op_SET5, store_L ;ED ;SET 5,(Ix+d),L
+instr fetch_nop, op_SET5, store_nop ;EE ;SET 5,(Ix+d)
+instr fetch_nop, op_SET5, store_A ;EF ;SET 5,(Ix+d),A
+instr fetch_nop, op_SET6, store_B ;F0 ;SET 6,(Ix+d),B
+instr fetch_nop, op_SET6, store_C ;F1 ;SET 6,(Ix+d),C
+instr fetch_nop, op_SET6, store_D ;F2 ;SET 6,(Ix+d),D
+instr fetch_nop, op_SET6, store_E ;F3 ;SET 6,(Ix+d),E
+instr fetch_nop, op_SET6, store_H ;F4 ;SET 6,(Ix+d),H
+instr fetch_nop, op_SET6, store_L ;F5 ;SET 6,(Ix+d),L
+instr fetch_nop, op_SET6, store_nop ;F6 ;SET 6,(Ix+d)
+instr fetch_nop, op_SET6, store_A ;F7 ;SET 6,(Ix+d),A
+instr fetch_nop, op_SET7, store_B ;F8 ;SET 7,(Ix+d),B
+instr fetch_nop, op_SET7, store_C ;F9 ;SET 7,(Ix+d),C
+instr fetch_nop, op_SET7, store_D ;FA ;SET 7,(Ix+d),D
+instr fetch_nop, op_SET7, store_E ;FB ;SET 7,(Ix+d),E
+instr fetch_nop, op_SET7, store_H ;FC ;SET 7,(Ix+d),H
+instr fetch_nop, op_SET7, store_L ;FD ;SET 7,(Ix+d),L
+instr fetch_nop, op_SET7, store_nop ;FE ;SET 7,(Ix+d)
+instr fetch_nop, op_SET7, store_A ;FF ;SET 7,(Ix+d),A
#endif
; .org (PC+255) & 0xff00
; .org opcjmp + 256
-; .org sz53p_table_pos
- .org FLASHEND & 0xff00
+ .org sz53p_table_pos
+; .org FLASHEND & 0xff00
; .org 0x1fff & 0xff00
sz53p_tab: