adiw z_pcl,1
ret
+do_fetch_dir8_2:
+ movw xl,z_pcl
+ adiw xl,1
+ mem_read_d opl
+ ret
+
do_fetch_dir16:
mem_read_ds opl, z_pc
adiw z_pcl,1
mem_write_s opl ;store operand
ret
+do_store_mxx_2:
+ sbic flags,prefixfd
+ rjmp storemxx2_fd
+ ldd xh,y+oz_xh
+ ldd xl,y+oz_xl
+ rjmp storemxx21
+storemxx2_fd:
+ ldd xh,y+oz_yh
+ ldd xl,y+oz_yl
+storemxx21:
+ mem_read_s z_pc ;get displacement
+ adiw z_pcl,1
+ adiw z_pcl,1
+ clr temp2 ;sign extend
+ tst temp
+ brpl storemxx22
+ com temp2
+storemxx22:
+ add xl,temp ;add displacement
+ adc xh,temp2
+ mem_write_s opl ;store operand
+ ret
+
do_store_xx:
sbic flags,prefixfd
rjmp storexx_fd
ret
+;----------------------------------------------------------------
+;|Mnemonic |SZHPNC|Description |Notes |
+;----------------------------------------------------------------
+;|RLC m |**0P0*|Rotate Left Circular |m=m<- |
+;|RRC m |**0P0*|Rotate Right Circular|m=->m |
+;|RL m |**0P0*|Rotate Left |m={CY,m}<- |
+;|RR m |**0P0*|Rotate Right |m=->{CY,m} |
+;|SLA m |**0P0*|Shift Left Arithmetic|m=m*2 |
+;|SRA m |**0P0*|Shift Right Arith. |m=m/2 |
+;|SLL m |**0P0*|Shift Right Logical |
+;|SRL m |**0P0*|Shift Right Logical |m=->{0,m,CY} |
+
+
+do_op_rlc:
+ ;Rotate Left Cyclical. All bits move 1 to the
+ ;left, the msb becomes c and lsb.
+ clr temp
+ lsl opl
+ adc temp,_0
+ or opl,temp
+ ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
+ or z_flags,temp
+ ret
+
+do_op_rrc:
+ ;Rotate Right Cyclical. All bits move 1 to the
+ ;right, the lsb becomes c and msb.
+ lsr opl
+ brcc PC+2
+ ori opl,0x80
+ ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
+ bmov z_flags,ZFL_C, opl,7
+ ret
+
+
+do_op_rl:
+ ;Rotate Left. All bits move 1 to the left, the msb
+ ;becomes c, c becomes lsb.
+ clc
+ sbrc z_flags,ZFL_C
+ sec
+ rol opl
+ in temp,sreg
+ ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
+ bmov z_flags,ZFL_C, temp,AVR_C
+ ret
+
+
+do_op_rr:
+ ;Rotate Right. All bits move 1 to the right, the lsb
+ ;becomes c, c becomes msb.
+
+ ror opl
+ in temp,sreg ;CY
+ bmov opl,7, z_flags,ZFL_C ;old CY --> Bit 7
+ ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
+ bmov z_flags,ZFL_C, temp,AVR_C ;
+ ret
+
+do_op_sla:
+ lsl opl
+ in temp,sreg
+ ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
+ bmov z_flags,ZFL_C, temp,AVR_C ;
+ ret
+
+do_op_sra:
+ lsr opl
+ in temp,sreg
+ bmov opl,7, opl,6 ;old CY --> Bit 7
+ ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
+ bmov z_flags,ZFL_C, temp,AVR_C ;
+ ret
+
+do_op_sll:
+ sec
+ rol opl
+ in temp,sreg
+ ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
+ bmov z_flags,ZFL_C, temp,AVR_C ;
+ ret
+
+do_op_srl:
+ lsr opl
+ in temp,sreg
+ ldpmx z_flags,sz53p_tab,opl ;S,Z,H,P,N
+ bmov z_flags,ZFL_C, temp,AVR_C ;
+ ret
+
;----------------------------------------------------------------
;|Mnemonic |SZHPNC|Description |Notes |
;----------------------------------------------------------------
;|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:
ldi temp,0x80
and temp,opl
in temp,sreg
ori z_flags,(1<<ZFL_H)
- andi z_flags,~((1<<ZFL_N) | (1<<ZFL_Z))
+ andi z_flags,~(1<<ZFL_N)
bmov z_flags,ZFL_Z, temp,AVR_Z
ret
instr fetch_BC, op_SBCHL, store_nop ;42 ;SBC HL,BC
instr fetch_DIR16, op_STBC, store_nop ;43 ;LD (nn),BC
instr fetch_nop, op_NEG, store_nop ;44 ;NEG
-instr fetch_nop, op_retn, store_nop ;45 ;RETN
+instr fetch_nop, op_RETN, store_nop ;45 ;RETN
instr fetch_nop, op_IM0, store_nop ;46 ;IM 0
instr fetch_nop, op_ldia, store_nop ;47 ;LD I,A
instr fetch_C, op_IN, store_C ;48 ;IN C,(C)
instr fetch_BC, op_ADCHL, store_nop ;4A ;ADC HL,BC
instr fetch_DIR16, op_RMEM16, store_BC ;4B nn nn ;LD BC,(nn)
instr fetch_nop, op_NEG, store_nop ;4C ;NEG
-instr fetch_nop, op_reti, store_nop ;4D ;RETI
+instr fetch_nop, op_RETI, store_nop ;4D ;RETI
instr fetch_nop, op_IM0, store_nop ;4E ;IM 0
instr fetch_nop, op_ldra, store_nop ;4F ;LD R,A
instr fetch_C, op_IN, store_D ;50 ;IN D,(C)
instr fetch_DE, op_SBCHL, store_nop ;52 ;SBC HL,DE
instr fetch_DIR16, op_STDE, store_nop ;53 nn nn ;LD (nn),DE
instr fetch_nop, op_NEG, store_nop ;54 ;NEG
-instr fetch_nop, op_retn, store_nop ;55 ;RETN
+instr fetch_nop, op_RETN, store_nop ;55 ;RETN
instr fetch_nop, op_IM1, store_nop ;56 ;IM 1
instr fetch_nop, op_ldai, store_nop ;57 ;LD A,I
instr fetch_C, op_IN, store_E ;58 ;IN E,(C)
instr fetch_DE, op_ADCHL, store_nop ;5A ;ADC HL,DE
instr fetch_DIR16, op_RMEM16, store_DE ;5B nn nn ;LD DE,(nn)
instr fetch_nop, op_NEG, store_nop ;5C ;NEG
-instr fetch_nop, op_retn, store_nop ;5D ;RETN
+instr fetch_nop, op_RETN, store_nop ;5D ;RETN
instr fetch_nop, op_IM2, store_nop ;5E ;IM 2
instr fetch_nop, op_ldar, store_nop ;5F ;LD A,R
instr fetch_C, op_IN, store_H ;60 ;IN H,(C)
instr fetch_HL, op_SBCHL, store_nop ;62 ;SBC HL,HL
instr fetch_DIR16, op_STHL, store_nop ;63 nn nn ;LD (nn),HL
instr fetch_nop, op_NEG, store_nop ;64 ;NEG
-instr fetch_nop, op_retn, store_nop ;65 ;RETN
+instr fetch_nop, op_RETN, store_nop ;65 ;RETN
instr fetch_nop, op_IM0, store_nop ;66 ;IM 0
instr fetch_mhl, op_RRD, store_mhl ;67 ;RRD
instr fetch_C, op_IN, store_L ;68 ;IN L,(C)
instr fetch_HL, op_ADCHL, store_nop ;6A ;ADC HL,HL
instr fetch_DIR16, op_RMEM16, store_HL ;6B nn nn ;LD HL,(nn)
instr fetch_nop, op_NEG, store_nop ;6C ;NEG
-instr fetch_nop, op_retn, store_nop ;6D ;RETN
+instr fetch_nop, op_RETN, store_nop ;6D ;RETN
instr fetch_nop, op_IM0, store_nop ;6E ;IM 0
instr fetch_mhl, op_RLD, store_mhl ;6F ;RLD
instr fetch_C, op_IN, store_nop ;70 ;IN (C)
instr fetch_SP, op_SBCHL, store_nop ;72 ;SBC HL,SP
instr fetch_DIR16, op_STSP, store_nop ;73 nn nn ;LD (nn),SP
instr fetch_nop, op_NEG, store_nop ;74 ;NEG
-instr fetch_nop, op_retn, store_nop ;75 ;RETN
+instr fetch_nop, op_RETN, store_nop ;75 ;RETN
instr fetch_nop, op_IM1, store_nop ;76 ;IM 1
instr fetch_nop, op_nop, store_nop ;77 ;NOP
instr fetch_C, op_IN, store_A ;78 ;IN A,(C)
instr fetch_SP, op_ADCHL, store_nop ;7A ;ADC HL,SP
instr fetch_DIR16, op_RMEM16, store_SP ;7B nn nn ;LD SP,(nn)
instr fetch_nop, op_NEG, store_nop ;7C ;NEG
-instr fetch_nop, op_retn, store_nop ;7D ;RETN
+instr fetch_nop, op_RETN, store_nop ;7D ;RETN
instr fetch_nop, op_IM2, store_nop ;7E ;IM 2
instr fetch_nop, op_nop, store_nop ;7F ;NOP
instr fetch_nop, op_nop, store_nop ;80 ;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 ;
+instr fetch_nop, op_nop, store_nop ;B3 ; TODO:
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 ;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_DIR8_2, op_nop, store_MXX_2 ;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
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 ;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_nop, op_nop, store_nop ;09 ;NOP
-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_nop, op_nop, store_nop ;19 ;NOP
-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 ;29 ;NOP
-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_nop, op_nop, store_nop ;39 ;NOP
-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_B, op_RLC, store_B ;00 ;RLC B
+instr fetch_C, op_RLC, store_C ;01 ;RLC C
+instr fetch_D, op_RLC, store_D ;02 ;RLC D
+instr fetch_E, op_RLC, store_E ;03 ;RLC E
+instr fetch_H, op_RLC, store_H ;04 ;RLC H
+instr fetch_L, op_RLC, store_L ;05 ;RLC L
+instr fetch_MHL, op_RLC, store_MHL ;06 ;RLC (HL)
+instr fetch_A, op_RLC, store_A ;07 ;RLC A
+instr fetch_B, op_RRC, store_B ;08 ;RRC B
+instr fetch_C, op_RRC, store_C ;09 ;RRC C
+instr fetch_D, op_RRC, store_D ;0A ;RRC D
+instr fetch_E, op_RRC, store_E ;0B ;RRC E
+instr fetch_H, op_RRC, store_H ;0C ;RRC H
+instr fetch_L, op_RRC, store_L ;0D ;RRC L
+instr fetch_MHL, op_RRC, store_MHL ;0E ;RRC (HL)
+instr fetch_A, op_RRC, store_A ;0F ;RRC A
+instr fetch_B, op_RL, store_B ;10 ;RL B
+instr fetch_C, op_RL, store_C ;11 ;RL C
+instr fetch_D, op_RL, store_D ;12 ;RL D
+instr fetch_E, op_RL, store_E ;13 ;RL E
+instr fetch_H, op_RL, store_H ;14 ;RL H
+instr fetch_L, op_RL, store_L ;15 ;RL L
+instr fetch_MHL, op_RL, store_MHL ;16 ;RL (HL)
+instr fetch_A, op_RL, store_A ;17 ;RL A
+instr fetch_B, op_RR, store_B ;18 ;RR B
+instr fetch_C, op_RR, store_C ;19 ;RR C
+instr fetch_D, op_RR, store_D ;1A ;RR D
+instr fetch_E, op_RR, store_E ;1B ;RR E
+instr fetch_H, op_RR, store_H ;1C ;RR H
+instr fetch_L, op_RR, store_L ;1D ;RR L
+instr fetch_MHL, op_RR, store_MHL ;1E ;RR (HL)
+instr fetch_A, op_RR, store_A ;1F ;RR A
+instr fetch_B, op_SLA, store_B ;20 ;SLA B
+instr fetch_C, op_SLA, store_C ;21 ;SLA C
+instr fetch_D, op_SLA, store_D ;22 ;SLA D
+instr fetch_E, op_SLA, store_E ;23 ;SLA E
+instr fetch_H, op_SLA, store_H ;24 ;SLA H
+instr fetch_L, op_SLA, store_L ;25 ;SLA L
+instr fetch_MHL, op_SLA, store_MHL ;26 ;SLA (HL)
+instr fetch_A, op_SLA, store_A ;27 ;SLA A
+instr fetch_B, op_SRA, store_B ;28 ;SRA B
+instr fetch_C, op_SRA, store_C ;29 ;SRA C
+instr fetch_D, op_SRA, store_D ;2A ;SRA D
+instr fetch_E, op_SRA, store_E ;2B ;SRA E
+instr fetch_H, op_SRA, store_H ;2C ;SRA H
+instr fetch_L, op_SRA, store_L ;2D ;SRA L
+instr fetch_MHL, op_SRA, store_MHL ;2E ;SRA (HL)
+instr fetch_A, op_SRA, store_A ;2F ;SRA A
+instr fetch_B, op_SLL, store_B ;30 ;SLL B
+instr fetch_C, op_SLL, store_C ;31 ;SLL C
+instr fetch_D, op_SLL, store_D ;32 ;SLL D
+instr fetch_E, op_SLL, store_E ;33 ;SLL E
+instr fetch_H, op_SLL, store_H ;34 ;SLL H
+instr fetch_L, op_SLL, store_L ;35 ;SLL L
+instr fetch_MHL, op_SLL, store_MHL ;36 ;SLL (HL)
+instr fetch_A, op_SLL, store_A ;37 ;SLL A
+instr fetch_B, op_SRL, store_B ;38 ;SRL B
+instr fetch_C, op_SRL, store_C ;39 ;SRL C
+instr fetch_D, op_SRL, store_D ;3A ;SRL D
+instr fetch_E, op_SRL, store_E ;3B ;SRL E
+instr fetch_H, op_SRL, store_H ;3C ;SRL H
+instr fetch_L, op_SRL, store_L ;3D ;SRL L
+instr fetch_MHL, op_SRL, store_MHL ;3E ;SRL (HL)
+instr fetch_A, op_SRL, store_A ;3F ;SRL A
instr fetch_B, op_BIT0, store_nop ;40 ;BIT 0,B
instr fetch_C, op_BIT0, store_nop ;41 ;BIT 0,C
instr fetch_D, op_BIT0, store_nop ;42 ;BIT 0,D