From affb3f8630773b3679ff2dc3f50fc43729009b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kujawa?= Date: Fri, 25 Jan 2019 11:10:35 +0100 Subject: [PATCH] Test for ADC abs, absx, better test for 16bit adc. --- test/test_emulation.c | 37 ++++++++++++++++++++++++++++++++-- test/test_emulation_adc_abs.s | 3 +++ test/test_emulation_adc_absx.s | 3 +++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 test/test_emulation_adc_abs.s create mode 100644 test/test_emulation_adc_absx.s diff --git a/test/test_emulation.c b/test/test_emulation.c index 748b955..7cb2eb2 100644 --- a/test/test_emulation.c +++ b/test/test_emulation.c @@ -1555,7 +1555,28 @@ ATF_TC_BODY(emul_adc, tc) ATF_CHECK(!(e.regs.P & P_SIGN_OVERFLOW)); ATF_CHECK(!(e.regs.P & P_NEGATIVE)); - /*rk65c02_dump_regs(e.regs);*/ + /* ADC absolute */ + e.regs.A = 0x55; + bus_write_1(&b, 0x2A00, 0xAB); + ATF_REQUIRE(rom_start(&e, "test_emulation_adc_abs.rom", tc)); + ATF_CHECK(e.regs.A == 0x0); + ATF_CHECK(e.regs.P & P_ZERO); + ATF_CHECK(e.regs.P & P_CARRY); + ATF_CHECK(!(e.regs.P & P_SIGN_OVERFLOW)); + ATF_CHECK(!(e.regs.P & P_NEGATIVE)); + + /* ADC absolute X */ + e.regs.A = 0x50; + e.regs.X = 0x10; + bus_write_1(&b, 0x2A10, 0x50); + ATF_REQUIRE(rom_start(&e, "test_emulation_adc_absx.rom", tc)); + ATF_CHECK(e.regs.A == 0xA1); + ATF_CHECK(!(e.regs.P & P_ZERO)); + ATF_CHECK(!(e.regs.P & P_CARRY)); + ATF_CHECK(e.regs.P & P_SIGN_OVERFLOW); + ATF_CHECK(e.regs.P & P_NEGATIVE); + + rk65c02_dump_regs(e.regs); } @@ -1580,7 +1601,6 @@ ATF_TC_BODY(emul_adc_bcd, tc) ATF_CHECK(bus_read_1(&b, 0x41) & P_CARRY); rk65c02_dump_regs(e.regs); - } ATF_TC_WITHOUT_HEAD(emul_sbc_bcd); @@ -1623,6 +1643,19 @@ ATF_TC_BODY(emul_adc_16bit, tc) ATF_CHECK(bus_read_1(&b, 0x66) == 0xFF); ATF_CHECK(bus_read_1(&b, 0x67) == 0xFF); + + e = rk65c02_init(&b); + + bus_write_1(&b, 0x62, 0xFF); + bus_write_1(&b, 0x63, 0xFF); + bus_write_1(&b, 0x64, 0xFF); + bus_write_1(&b, 0x65, 0xFF); + + ATF_REQUIRE(rom_start(&e, "test_emulation_adc_16bit.rom", tc)); + + ATF_CHECK(bus_read_1(&b, 0x66) == 0xFE); + ATF_CHECK(bus_read_1(&b, 0x67) == 0xFF); + rk65c02_dump_regs(e.regs); } diff --git a/test/test_emulation_adc_abs.s b/test/test_emulation_adc_abs.s new file mode 100644 index 0000000..d629498 --- /dev/null +++ b/test/test_emulation_adc_abs.s @@ -0,0 +1,3 @@ +start: adc 0x2A00 + stp + diff --git a/test/test_emulation_adc_absx.s b/test/test_emulation_adc_absx.s new file mode 100644 index 0000000..37966b1 --- /dev/null +++ b/test/test_emulation_adc_absx.s @@ -0,0 +1,3 @@ +start: adc 0x2A00,X + stp +