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

Add DEX, DEY emulation and test cases for them.

This commit is contained in:
Radosław Kujawa 2017-01-22 22:35:50 +01:00
parent 52247f0ce4
commit fb7d4b28e7
6 changed files with 58 additions and 2 deletions

View File

@ -135,7 +135,7 @@ OP_STY_ZP,"sty",ZP,2,NULL
OP_STA_ZP,"sta",ZP,2,NULL
OP_STX_ZP,"stx",ZP,2,NULL
OP_SMB0_ZP,"smb0",ZP,2,NULL
OP_DEY,"dey",IMPLIED,1,NULL
OP_DEY,"dey",IMPLIED,1,emul_dey
OP_BIT_IMM,"bit",IMMEDIATE,2,NULL
OP_TXA,"txa",IMPLIED,1,NULL
OP_NOPI_8C,"nop",IMPLIED,1,NULL
@ -201,7 +201,7 @@ OP_DEC_ZP,"dec",ZP,2,NULL
OP_SMB4_ZP,"smb4",ZP,2,NULL
OP_INY,"iny",IMPLIED,1,emul_iny
OP_CMP_IMM,"cmp",IMMEDIATE,2,NULL
OP_DEX,"dex",IMPLIED,1,NULL
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

1 opcode_id mnemonic addressing size emulation
135 OP_STA_ZP sta ZP 2 NULL
136 OP_STX_ZP stx ZP 2 NULL
137 OP_SMB0_ZP smb0 ZP 2 NULL
138 OP_DEY dey IMPLIED 1 NULL emul_dey
139 OP_BIT_IMM bit IMMEDIATE 2 NULL
140 OP_TXA txa IMPLIED 1 NULL
141 OP_NOPI_8C nop IMPLIED 1 NULL
201 OP_SMB4_ZP smb4 ZP 2 NULL
202 OP_INY iny IMPLIED 1 emul_iny
203 OP_CMP_IMM cmp IMMEDIATE 2 NULL
204 OP_DEX dex IMPLIED 1 NULL emul_dex
205 OP_WAI wai IMPLIED 1 NULL
206 OP_CPY_ABS cpy ABSOLUTE 3 NULL
207 OP_CMP_ABS cmp ABSOLUTE 3 NULL

View File

@ -22,6 +22,26 @@ emul_clc(rk65c02emu_t *e, void *id, instruction_t *i)
e->regs.P &= ~P_CARRY;
}
/* DNX - decrement X */
void
emul_dex(rk65c02emu_t *e, void *id, instruction_t *i)
{
e->regs.X--;
instruction_status_adjust_zero(e, e->regs.X);
instruction_status_adjust_negative(e, e->regs.X);
}
/* DNY - decrement Y */
void
emul_dey(rk65c02emu_t *e, void *id, instruction_t *i)
{
e->regs.Y--;
instruction_status_adjust_zero(e, e->regs.Y);
instruction_status_adjust_negative(e, e->regs.Y);
}
/* INX - increment X */
void
emul_inx(rk65c02emu_t *e, void *id, instruction_t *i)

View File

@ -7,6 +7,7 @@ VASMFLAGS=-Fbin -c02
TESTS=test_bus test_emulation
TESTROMS=test_emulation_and_imm.rom \
test_emulation_clc.rom test_emulation_sec.rom \
test_emulation_dex.rom test_emulation_dey.rom \
test_emulation_inx.rom test_emulation_iny.rom \
test_emulation_pha.rom test_emulation_pla.rom \
test_emulation_nop.rom \

View File

@ -22,6 +22,34 @@ rom_start(rk65c02emu_t *e, const char *name)
return true;
}
ATF_TC_WITHOUT_HEAD(emul_dex_dey);
ATF_TC_BODY(emul_dex_dey, tc)
{
rk65c02emu_t e;
bus_t b;
b = bus_init();
e = rk65c02_init(&b);
/* DEX */
e.regs.X = 0x1;
ATF_REQUIRE(rom_start(&e, "test_emulation_dex.rom"));
ATF_CHECK(e.regs.X == 0x0);
/* DEX underflow */
ATF_REQUIRE(rom_start(&e, "test_emulation_dex.rom"));
ATF_CHECK(e.regs.X == 0xFF);
/* DEY */
e.regs.Y = 0x1;
ATF_REQUIRE(rom_start(&e, "test_emulation_dey.rom"));
ATF_CHECK(e.regs.Y == 0x0);
/* DEY underflow */
ATF_REQUIRE(rom_start(&e, "test_emulation_dey.rom"));
ATF_CHECK(e.regs.Y == 0xFF);
bus_finish(&b);
}
ATF_TC_WITHOUT_HEAD(emul_inx_iny);
ATF_TC_BODY(emul_inx_iny, tc)
{
@ -199,6 +227,7 @@ ATF_TC_BODY(emul_stack, tc)
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, emul_and);
ATF_TP_ADD_TC(tp, emul_dex_dey);
ATF_TP_ADD_TC(tp, emul_clc_sec);
ATF_TP_ADD_TC(tp, emul_inx_iny);
ATF_TP_ADD_TC(tp, emul_lda);

View File

@ -0,0 +1,3 @@
start: dex
stp

View File

@ -0,0 +1,3 @@
start: dey
stp