diff --git a/test/test_emulation.c b/test/test_emulation.c index 060ccf8..4801fdd 100644 --- a/test/test_emulation.c +++ b/test/test_emulation.c @@ -1203,6 +1203,28 @@ ATF_TC_BODY(emul_adc_bcd, tc) } +ATF_TC_WITHOUT_HEAD(emul_sbc_bcd); +ATF_TC_BODY(emul_sbc_bcd, tc) +{ + rk65c02emu_t e; + bus_t b; + + b = bus_init(); + e = rk65c02_init(&b); + + ATF_REQUIRE(rom_start(&e, "test_emulation_sbc_bcd.rom", tc)); + + ATF_CHECK(bus_read_1(&b, 0x10) == 0x34); + ATF_CHECK(bus_read_1(&b, 0x11) & P_CARRY); + ATF_CHECK(bus_read_1(&b, 0x20) == 0x27); + ATF_CHECK(bus_read_1(&b, 0x21) & P_CARRY); + ATF_CHECK(bus_read_1(&b, 0x30) == 0x29); + ATF_CHECK(bus_read_1(&b, 0x31) & P_CARRY); + + rk65c02_dump_regs(&e); + +} + ATF_TC_WITHOUT_HEAD(emul_adc_16bit); ATF_TC_BODY(emul_adc_16bit, tc) { @@ -1277,6 +1299,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, emul_sta); ATF_TP_ADD_TC(tp, emul_sbc); ATF_TP_ADD_TC(tp, emul_sbc_16bit); + ATF_TP_ADD_TC(tp, emul_sbc_bcd); ATF_TP_ADD_TC(tp, emul_sign_overflow_basic); ATF_TP_ADD_TC(tp, emul_sign_overflow_thorough); diff --git a/test/test_emulation_sbc_bcd.s b/test/test_emulation_sbc_bcd.s new file mode 100644 index 0000000..ae925de --- /dev/null +++ b/test/test_emulation_sbc_bcd.s @@ -0,0 +1,30 @@ +; somewhat inspired by http://www.6502.org/tutorials/decimal_mode.html +start: sed + sec + lda #0x46 + sbc #0x12 + sta 0x10 + php + plx + stx 0x11 + + sed + sec + lda #0x40 + sbc #0x13 + sta 0x20 + php + plx + stx 0x21 + + sed + clc + lda #0x32 + sbc #0x02 + sta 0x30 + php + plx + stx 0x31 + + stp +