1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-12-11 18:49:16 +00:00

Add emulation of INC and DEC.

This commit is contained in:
Radosław Kujawa 2017-01-27 00:04:47 +01:00
parent 699d791023
commit b7f1b8095b
2 changed files with 40 additions and 10 deletions

View File

@ -25,7 +25,7 @@ OP_ASL_ZPX,"asl",ZPX,2,NULL
OP_RMB1_ZP,"rmb1",ZP,1,NULL
OP_CLC,"clc",IMPLIED,1,emul_clc
OP_ORA_ABSY,"ora",ABSOLUTEY,3,emul_ora
OP_INC,"inc",ACCUMULATOR,1,NULL
OP_INC,"inc",ACCUMULATOR,1,emul_inc
OP_NOPI_1C,"nop",IMPLIED,1,NULL
OP_TRB_ABS,"trb",ABSOLUTE,3,NULL
OP_ORA_ABSX,"ora",ABSOLUTEX,3,emul_ora
@ -57,7 +57,7 @@ OP_ROL_ZPX,"rol",ZPX,2,emul_rol
OP_RMB3_ZP,"rmb3",ZP,2,NULL
OP_SEC,"sec",IMPLIED,1,emul_sec
OP_AND_ABSY,"and",ABSOLUTEY,3,emul_and
OP_DEC,"dec",ACCUMULATOR,1,NULL
OP_DEC,"dec",ACCUMULATOR,1,emul_dec
OP_NOPI_3C,"nop",IMPLIED,1,NULL
OP_BIT_ABSX,"bit",ABSOLUTEX,3,emul_bit
OP_AND_ABSX,"and",ABSOLUTEX,3,emul_and
@ -197,7 +197,7 @@ OP_NOPI_C3,"nop",IMMEDIATE,2,NULL
OP_NOPI_C4,"nop",IMPLIED,1,NULL
OP_CPY_ZP,"cpy",ZP,2,NULL
OP_CMP_ZP,"cmp",ZP,2,NULL
OP_DEC_ZP,"dec",ZP,2,NULL
OP_DEC_ZP,"dec",ZP,2,emul_dec
OP_SMB4_ZP,"smb4",ZP,2,NULL
OP_INY,"iny",IMPLIED,1,emul_iny
OP_CMP_IMM,"cmp",IMMEDIATE,2,NULL
@ -205,7 +205,7 @@ OP_DEX,"dex",IMPLIED,1,emul_dex
OP_WAI,"wai",IMPLIED,1,NULL
OP_CPY_ABS,"cpy",ABSOLUTE,3,NULL
OP_CMP_ABS,"cmp",ABSOLUTE,3,NULL
OP_DEC_ABS,"dec",ABSOLUTE,3,NULL
OP_DEC_ABS,"dec",ABSOLUTE,3,emul_dec
OP_BBS4_REL,"bbs4",ZPR,2,NULL
OP_BNE_REL,"bne",RELATIVE,2,NULL
OP_CMP_IZPY,"cmp",IZPY,2,NULL
@ -213,7 +213,7 @@ OP_CMP_IZP,"cmp",IZP,2,NULL
OP_NOPI_D4,"nop",IMPLIED,1,NULL
OP_NOPI_D5,"nop",ZPX,2,NULL
OP_CMP_ZPX,"cmp",ZPX,2,NULL
OP_DEC_ZPX,"dec",ZPX,2,NULL
OP_DEC_ZPX,"dec",ZPX,2,emul_dec
OP_SMB5_ZP,"smb5",ZP,2,NULL
OP_CLD,"cld",IMPLIED,1,NULL
OP_CMP_ABSY,"cmp",ABSOLUTEY,3,NULL
@ -221,7 +221,7 @@ OP_PHX,"phx",IMPLIED,1,emul_phx
OP_STP,"stp",IMPLIED,1,emul_stp
OP_NOPI_DD,"nop",ABSOLUTE,3,NULL
OP_CMP_ABSX,"cmp",ABSOLUTEX,3,NULL
OP_DEC_ABSX,"dec",ABSOLUTEX,3,NULL
OP_DEC_ABSX,"dec",ABSOLUTEX,3,emul_dec
OP_BBS5_REL,"bbs5",ZPR,2,NULL
OP_CPX_IMM,"cpx",IMMEDIATE,2,NULL
OP_SBC_IZPX,"sbc",IZPX,2,NULL
@ -229,7 +229,7 @@ OP_NOPI_E3,"nop",IMMEDIATE,2,NULL
OP_NOPI_E4,"nop",IMPLIED,1,NULL
OP_CPX_ZP,"cpx",ZP,2,NULL
OP_SBC_ZP,"sbc",ZP,2,NULL
OP_INC_ZP,"inc",ZP,2,NULL
OP_INC_ZP,"inc",ZP,2,emul_inc
OP_SMB6_ZP,"smb6",ZP,2,NULL
OP_INX,"inx",IMPLIED,1,emul_inx
OP_SBC_IMM,"sbc",IMMEDIATE,2,NULL
@ -237,7 +237,7 @@ OP_NOP,"nop",IMPLIED,1,emul_nop
OP_NOPI_EC,"nop",IMPLIED,1,NULL
OP_CPX_ABS,"cpx",ABSOLUTE,3,NULL
OP_SBC_ABS,"sbc",ABSOLUTE,3,NULL
OP_INC_ABS,"inc",ABSOLUTE,3,NULL
OP_INC_ABS,"inc",ABSOLUTE,3,emul_inc
OP_BBS6_REL,"bbs6",ZPR,2,NULL
OP_BEQ_REL,"beq",RELATIVE,2,NULL
OP_SBC_IZPY,"sbc",IZPY,2,NULL
@ -245,7 +245,7 @@ OP_SBC_IZP,"sbc",IZP,2,NULL
OP_NOPI_F4,"nop",IMPLIED,1,NULL
OP_NOPI_F5,"nop",ZPX,2,NULL
OP_SBC_ZPX,"sbc",ZPX,2,NULL
OP_INC_ZPX,"inc",ZPX,2,NULL
OP_INC_ZPX,"inc",ZPX,2,emul_inc
OP_SMB7_ZP,"smb7",ZP,2,NULL
OP_SED,"sed",IMPLIED,1,NULL
OP_SBC_ABSY,"sbc",ABSOLUTEY,3,NULL
@ -253,5 +253,5 @@ OP_PLX,"plx",IMPLIED,1,emul_plx
OP_NOPI_FC,"nop",IMPLIED,1,NULL
OP_NOPI_FD,"nop",ABSOLUTE,3,NULL
OP_SBC_ABSX,"sbc",ABSOLUTEX,3,NULL
OP_INC_ABSX,"inc",ABSOLUTEX,3,NULL
OP_INC_ABSX,"inc",ABSOLUTEX,3,emul_inc
OP_BBS7_REL,"bbs7",ZPR,2,NULL

1 opcode_id mnemonic addressing size emulation
25 OP_RMB1_ZP rmb1 ZP 1 NULL
26 OP_CLC clc IMPLIED 1 emul_clc
27 OP_ORA_ABSY ora ABSOLUTEY 3 emul_ora
28 OP_INC inc ACCUMULATOR 1 NULL emul_inc
29 OP_NOPI_1C nop IMPLIED 1 NULL
30 OP_TRB_ABS trb ABSOLUTE 3 NULL
31 OP_ORA_ABSX ora ABSOLUTEX 3 emul_ora
57 OP_RMB3_ZP rmb3 ZP 2 NULL
58 OP_SEC sec IMPLIED 1 emul_sec
59 OP_AND_ABSY and ABSOLUTEY 3 emul_and
60 OP_DEC dec ACCUMULATOR 1 NULL emul_dec
61 OP_NOPI_3C nop IMPLIED 1 NULL
62 OP_BIT_ABSX bit ABSOLUTEX 3 emul_bit
63 OP_AND_ABSX and ABSOLUTEX 3 emul_and
197 OP_NOPI_C4 nop IMPLIED 1 NULL
198 OP_CPY_ZP cpy ZP 2 NULL
199 OP_CMP_ZP cmp ZP 2 NULL
200 OP_DEC_ZP dec ZP 2 NULL emul_dec
201 OP_SMB4_ZP smb4 ZP 2 NULL
202 OP_INY iny IMPLIED 1 emul_iny
203 OP_CMP_IMM cmp IMMEDIATE 2 NULL
205 OP_WAI wai IMPLIED 1 NULL
206 OP_CPY_ABS cpy ABSOLUTE 3 NULL
207 OP_CMP_ABS cmp ABSOLUTE 3 NULL
208 OP_DEC_ABS dec ABSOLUTE 3 NULL emul_dec
209 OP_BBS4_REL bbs4 ZPR 2 NULL
210 OP_BNE_REL bne RELATIVE 2 NULL
211 OP_CMP_IZPY cmp IZPY 2 NULL
213 OP_NOPI_D4 nop IMPLIED 1 NULL
214 OP_NOPI_D5 nop ZPX 2 NULL
215 OP_CMP_ZPX cmp ZPX 2 NULL
216 OP_DEC_ZPX dec ZPX 2 NULL emul_dec
217 OP_SMB5_ZP smb5 ZP 2 NULL
218 OP_CLD cld IMPLIED 1 NULL
219 OP_CMP_ABSY cmp ABSOLUTEY 3 NULL
221 OP_STP stp IMPLIED 1 emul_stp
222 OP_NOPI_DD nop ABSOLUTE 3 NULL
223 OP_CMP_ABSX cmp ABSOLUTEX 3 NULL
224 OP_DEC_ABSX dec ABSOLUTEX 3 NULL emul_dec
225 OP_BBS5_REL bbs5 ZPR 2 NULL
226 OP_CPX_IMM cpx IMMEDIATE 2 NULL
227 OP_SBC_IZPX sbc IZPX 2 NULL
229 OP_NOPI_E4 nop IMPLIED 1 NULL
230 OP_CPX_ZP cpx ZP 2 NULL
231 OP_SBC_ZP sbc ZP 2 NULL
232 OP_INC_ZP inc ZP 2 NULL emul_inc
233 OP_SMB6_ZP smb6 ZP 2 NULL
234 OP_INX inx IMPLIED 1 emul_inx
235 OP_SBC_IMM sbc IMMEDIATE 2 NULL
237 OP_NOPI_EC nop IMPLIED 1 NULL
238 OP_CPX_ABS cpx ABSOLUTE 3 NULL
239 OP_SBC_ABS sbc ABSOLUTE 3 NULL
240 OP_INC_ABS inc ABSOLUTE 3 NULL emul_inc
241 OP_BBS6_REL bbs6 ZPR 2 NULL
242 OP_BEQ_REL beq RELATIVE 2 NULL
243 OP_SBC_IZPY sbc IZPY 2 NULL
245 OP_NOPI_F4 nop IMPLIED 1 NULL
246 OP_NOPI_F5 nop ZPX 2 NULL
247 OP_SBC_ZPX sbc ZPX 2 NULL
248 OP_INC_ZPX inc ZPX 2 NULL emul_inc
249 OP_SMB7_ZP smb7 ZP 2 NULL
250 OP_SED sed IMPLIED 1 NULL
251 OP_SBC_ABSY sbc ABSOLUTEY 3 NULL
253 OP_NOPI_FC nop IMPLIED 1 NULL
254 OP_NOPI_FD nop ABSOLUTE 3 NULL
255 OP_SBC_ABSX sbc ABSOLUTEX 3 NULL
256 OP_INC_ABSX inc ABSOLUTEX 3 NULL emul_inc
257 OP_BBS7_REL bbs7 ZPR 2 NULL

View File

@ -43,6 +43,21 @@ emul_clc(rk65c02emu_t *e, void *id, instruction_t *i)
e->regs.P &= ~P_CARRY;
}
/* DEC - decrement memory location/acumulator */
void
emul_dec(rk65c02emu_t *e, void *id, instruction_t *i)
{
uint8_t val;
/* this is absurdly inefficient */
val = instruction_data_read_1(e, (instrdef_t *) id, i);
val--;
instruction_data_write_1(e, id, i, val);
instruction_status_adjust_zero(e, val);
instruction_status_adjust_negative(e, val);
}
/* DNX - decrement X */
void
emul_dex(rk65c02emu_t *e, void *id, instruction_t *i)
@ -73,6 +88,21 @@ emul_eor(rk65c02emu_t *e, void *id, instruction_t *i)
instruction_status_adjust_negative(e, e->regs.A);
}
/* INC - increment memory location/acumulator */
void
emul_inc(rk65c02emu_t *e, void *id, instruction_t *i)
{
uint8_t val;
/* this is absurdly inefficient */
val = instruction_data_read_1(e, (instrdef_t *) id, i);
val++;
instruction_data_write_1(e, id, i, val);
instruction_status_adjust_zero(e, val);
instruction_status_adjust_negative(e, val);
}
/* INX - increment X */
void
emul_inx(rk65c02emu_t *e, void *id, instruction_t *i)