1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2025-04-04 07:29:36 +00:00

Add test case for SBC in decimal mode.

This commit is contained in:
Radosław Kujawa 2017-02-12 23:28:06 +01:00
parent 7f1c27af75
commit f0b1294897
2 changed files with 53 additions and 0 deletions

View File

@ -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);

View File

@ -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