mirror of
https://github.com/rkujawa/rk65c02.git
synced 2025-08-15 18:27:20 +00:00
Add INX, INY emulation and test cases.
Some comments while here.
This commit is contained in:
@@ -199,7 +199,7 @@ OP_CPY_ZP,"cpy",ZP,2,NULL
|
|||||||
OP_CMP_ZP,"cmp",ZP,2,NULL
|
OP_CMP_ZP,"cmp",ZP,2,NULL
|
||||||
OP_DEC_ZP,"dec",ZP,2,NULL
|
OP_DEC_ZP,"dec",ZP,2,NULL
|
||||||
OP_SMB4_ZP,"smb4",ZP,2,NULL
|
OP_SMB4_ZP,"smb4",ZP,2,NULL
|
||||||
OP_INY,"iny",IMPLIED,1,NULL
|
OP_INY,"iny",IMPLIED,1,emul_iny
|
||||||
OP_CMP_IMM,"cmp",IMMEDIATE,2,NULL
|
OP_CMP_IMM,"cmp",IMMEDIATE,2,NULL
|
||||||
OP_DEX,"dex",IMPLIED,1,NULL
|
OP_DEX,"dex",IMPLIED,1,NULL
|
||||||
OP_WAI,"wai",IMPLIED,1,NULL
|
OP_WAI,"wai",IMPLIED,1,NULL
|
||||||
@@ -231,7 +231,7 @@ OP_CPX_ZP,"cpx",ZP,2,NULL
|
|||||||
OP_SBC_ZP,"sbc",ZP,2,NULL
|
OP_SBC_ZP,"sbc",ZP,2,NULL
|
||||||
OP_INC_ZP,"inc",ZP,2,NULL
|
OP_INC_ZP,"inc",ZP,2,NULL
|
||||||
OP_SMB6_ZP,"smb6",ZP,2,NULL
|
OP_SMB6_ZP,"smb6",ZP,2,NULL
|
||||||
OP_INX,"inx",IMPLIED,1,NULL
|
OP_INX,"inx",IMPLIED,1,emul_inx
|
||||||
OP_SBC_IMM,"sbc",IMMEDIATE,2,NULL
|
OP_SBC_IMM,"sbc",IMMEDIATE,2,NULL
|
||||||
OP_NOP,"nop",IMPLIED,1,emul_nop
|
OP_NOP,"nop",IMPLIED,1,emul_nop
|
||||||
OP_NOPI_EC,"nop",IMPLIED,1,NULL
|
OP_NOPI_EC,"nop",IMPLIED,1,NULL
|
||||||
|
|
@@ -15,6 +15,26 @@ emul_and(rk65c02emu_t *e, void *id, instruction_t *i)
|
|||||||
instruction_status_adjust_negative(e, e->regs.A);
|
instruction_status_adjust_negative(e, e->regs.A);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* INX - increment X */
|
||||||
|
void
|
||||||
|
emul_inx(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* INY - increment Y */
|
||||||
|
void
|
||||||
|
emul_iny(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);
|
||||||
|
}
|
||||||
|
|
||||||
/* LDA - load to accumulator */
|
/* LDA - load to accumulator */
|
||||||
void
|
void
|
||||||
emul_lda(rk65c02emu_t *e, void *id, instruction_t *i)
|
emul_lda(rk65c02emu_t *e, void *id, instruction_t *i)
|
||||||
|
@@ -28,7 +28,11 @@ rk65c02_start(rk65c02emu_t *e) {
|
|||||||
|
|
||||||
e->state = RUNNING;
|
e->state = RUNNING;
|
||||||
while (e->state == RUNNING) {
|
while (e->state == RUNNING) {
|
||||||
|
/* XXX: handle breakpoints and watch points */
|
||||||
|
|
||||||
|
/* if disassembly-when-running enabled */
|
||||||
disassemble(e->bus, e->regs.PC);
|
disassemble(e->bus, e->regs.PC);
|
||||||
|
|
||||||
i = instruction_fetch(e->bus, e->regs.PC);
|
i = instruction_fetch(e->bus, e->regs.PC);
|
||||||
id = instruction_decode(i.opcode);
|
id = instruction_decode(i.opcode);
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@ VASMFLAGS=-Fbin -c02
|
|||||||
|
|
||||||
TESTS=test_bus test_emulation
|
TESTS=test_bus test_emulation
|
||||||
TESTROMS=test_emulation_and_imm.rom \
|
TESTROMS=test_emulation_and_imm.rom \
|
||||||
|
test_emulation_inx.rom test_emulation_iny.rom \
|
||||||
test_emulation_pha.rom test_emulation_pla.rom \
|
test_emulation_pha.rom test_emulation_pla.rom \
|
||||||
test_emulation_nop.rom \
|
test_emulation_nop.rom \
|
||||||
test_emulation_lda_imm.rom test_emulation_lda_zp.rom \
|
test_emulation_lda_imm.rom test_emulation_lda_zp.rom \
|
||||||
|
@@ -22,6 +22,36 @@ rom_start(rk65c02emu_t *e, const char *name)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ATF_TC_WITHOUT_HEAD(emul_inx_iny);
|
||||||
|
ATF_TC_BODY(emul_inx_iny, tc)
|
||||||
|
{
|
||||||
|
rk65c02emu_t e;
|
||||||
|
bus_t b;
|
||||||
|
|
||||||
|
b = bus_init();
|
||||||
|
e = rk65c02_init(&b);
|
||||||
|
|
||||||
|
/* INX */
|
||||||
|
e.regs.X = 0;
|
||||||
|
ATF_REQUIRE(rom_start(&e, "test_emulation_inx.rom"));
|
||||||
|
ATF_CHECK(e.regs.X == 0x1);
|
||||||
|
/* INX overflow */
|
||||||
|
e.regs.X = 0xFF;
|
||||||
|
ATF_REQUIRE(rom_start(&e, "test_emulation_inx.rom"));
|
||||||
|
ATF_CHECK(e.regs.X == 0x0);
|
||||||
|
|
||||||
|
/* INY */
|
||||||
|
e.regs.Y = 0;
|
||||||
|
ATF_REQUIRE(rom_start(&e, "test_emulation_iny.rom"));
|
||||||
|
ATF_CHECK(e.regs.Y == 0x1);
|
||||||
|
/* INY overflow */
|
||||||
|
e.regs.Y = 0xFF;
|
||||||
|
ATF_REQUIRE(rom_start(&e, "test_emulation_iny.rom"));
|
||||||
|
ATF_CHECK(e.regs.Y == 0x0);
|
||||||
|
|
||||||
|
bus_finish(&b);
|
||||||
|
}
|
||||||
|
|
||||||
ATF_TC_WITHOUT_HEAD(emul_lda);
|
ATF_TC_WITHOUT_HEAD(emul_lda);
|
||||||
ATF_TC_BODY(emul_lda, tc)
|
ATF_TC_BODY(emul_lda, tc)
|
||||||
{
|
{
|
||||||
@@ -149,6 +179,7 @@ ATF_TC_BODY(emul_stack, tc)
|
|||||||
ATF_TP_ADD_TCS(tp)
|
ATF_TP_ADD_TCS(tp)
|
||||||
{
|
{
|
||||||
ATF_TP_ADD_TC(tp, emul_and);
|
ATF_TP_ADD_TC(tp, emul_and);
|
||||||
|
ATF_TP_ADD_TC(tp, emul_inx_iny);
|
||||||
ATF_TP_ADD_TC(tp, emul_lda);
|
ATF_TP_ADD_TC(tp, emul_lda);
|
||||||
ATF_TP_ADD_TC(tp, emul_nop);
|
ATF_TP_ADD_TC(tp, emul_nop);
|
||||||
ATF_TP_ADD_TC(tp, emul_stz);
|
ATF_TP_ADD_TC(tp, emul_stz);
|
||||||
|
3
test/test_emulation_inx.s
Normal file
3
test/test_emulation_inx.s
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
start: inx
|
||||||
|
stp
|
||||||
|
|
3
test/test_emulation_iny.s
Normal file
3
test/test_emulation_iny.s
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
start: iny
|
||||||
|
stp
|
||||||
|
|
Reference in New Issue
Block a user