diff --git a/src/65c02isa.csv b/src/65c02isa.csv index bfa70de..7536420 100644 --- a/src/65c02isa.csv +++ b/src/65c02isa.csv @@ -99,7 +99,7 @@ OP_RTS,"rts",IMPLIED,1,NULL OP_ADC_IZPX,"adc",IZPX,2,NULL OP_NOPI_63,"nop",IMMEDIATE,2,NULL OP_NOPI_64,"nop",IMPLIED,1,NULL -OP_STZ_ZP,"stz",ZP,2,NULL +OP_STZ_ZP,"stz",ZP,2,emul_stz OP_ADC_ZP,"adc",ZP,2,NULL OP_ROR_ZP,"ror",ZP,2,NULL OP_RMB6_ZP,"rmb6",ZP,2,NULL diff --git a/src/emulation.c b/src/emulation.c index b57c4f1..16cae1a 100644 --- a/src/emulation.c +++ b/src/emulation.c @@ -63,3 +63,14 @@ emul_stp(rk65c02emu_t *e, instruction_t *i) e->state = STOPPED; } +/* STZ - store zero */ +void +emul_stz(rk65c02emu_t *e, instruction_t *i) +{ + instrdef_t id; + + id = instruction_decode(i->opcode); + + instruction_data_write_1(e, &id, i, 0); +} + diff --git a/test/Makefile b/test/Makefile index 705586e..e5731f3 100644 --- a/test/Makefile +++ b/test/Makefile @@ -8,7 +8,8 @@ TESTS=test_bus test_emulation TESTROMS=test_emulation_and_imm.rom \ test_emulation_pha.rom test_emulation_pla.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 \ + test_emulation_stz_zp.rom all : $(TESTS) $(TESTROMS) diff --git a/test/test_emulation.c b/test/test_emulation.c index 9e33f65..de645e7 100644 --- a/test/test_emulation.c +++ b/test/test_emulation.c @@ -45,6 +45,23 @@ ATF_TC_BODY(emul_lda, tc) bus_finish(&b); } +ATF_TC_WITHOUT_HEAD(emul_stz); +ATF_TC_BODY(emul_stz, tc) +{ + rk65c02emu_t e; + bus_t b; + + b = bus_init(); + e = rk65c02_init(&b); + + /* STZ zp */ + bus_write_1(&b, 0x10, 0xAA); + ATF_REQUIRE(rom_start(&e, "test_emulation_stz_zp.rom")); + ATF_CHECK(bus_read_1(&b, 0x10) == 0x00); + + bus_finish(&b); +} + ATF_TC_WITHOUT_HEAD(emul_and); ATF_TC_BODY(emul_and, tc) { @@ -134,6 +151,8 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, emul_and); ATF_TP_ADD_TC(tp, emul_lda); ATF_TP_ADD_TC(tp, emul_nop); + ATF_TP_ADD_TC(tp, emul_stz); + ATF_TP_ADD_TC(tp, emul_stack); return (atf_no_error()); diff --git a/test/test_emulation_stz_zp.s b/test/test_emulation_stz_zp.s new file mode 100644 index 0000000..d4d0465 --- /dev/null +++ b/test/test_emulation_stz_zp.s @@ -0,0 +1,3 @@ +start: stz 0x10 + stp +