From 578955e4a145a4f273e40469eca1f35e81caebbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kujawa?= Date: Thu, 12 Apr 2018 11:40:33 +0200 Subject: [PATCH] Add test case for invalid opcode handling. --- test/test_emulation.c | 33 ++++++++++++++++++++++++++++ test/test_emulation_invalid_opcode.s | 11 ++++++++++ 2 files changed, 44 insertions(+) create mode 100644 test/test_emulation_invalid_opcode.s diff --git a/test/test_emulation.c b/test/test_emulation.c index ddbb617..8e2b696 100644 --- a/test/test_emulation.c +++ b/test/test_emulation.c @@ -1474,6 +1474,37 @@ ATF_TC_BODY(emul_wrap_zpx, tc) } } +ATF_TC_WITHOUT_HEAD(emul_invalid_opcode); +ATF_TC_BODY(emul_invalid_opcode, tc) +{ + rk65c02emu_t e; + bus_t b; + + struct reg_state rorig; + + rk65c02_loglevel_set(LOG_DEBUG); + + b = bus_init_with_default_devs(); + e = rk65c02_init(&b); + + e.runtime_disassembly = true; + rorig = e.regs; + + ATF_REQUIRE(rom_start(&e, "test_emulation_invalid_opcode.rom", tc)); + + ATF_CHECK(e.regs.A == rorig.A); + ATF_CHECK(e.regs.X == rorig.X); + ATF_CHECK(e.regs.Y == rorig.Y); + ATF_CHECK(e.regs.SP == rorig.SP); + ATF_CHECK(e.regs.P == rorig.P); + + ATF_CHECK(e.regs.PC == 0xC007); + + rk65c02_log(LOG_INFO, "PC: %x", e.regs.PC); + +} + + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, emul_and); @@ -1518,6 +1549,8 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, emul_wrap_zpx); ATF_TP_ADD_TC(tp, emul_wrap_izpx); + ATF_TP_ADD_TC(tp, emul_invalid_opcode); + return (atf_no_error()); } diff --git a/test/test_emulation_invalid_opcode.s b/test/test_emulation_invalid_opcode.s new file mode 100644 index 0000000..fafe31f --- /dev/null +++ b/test/test_emulation_invalid_opcode.s @@ -0,0 +1,11 @@ +.byte 0x42 +.byte 0xFF +.byte 0x43 +.byte 0x44 +.byte 0xFF +.byte 0x4B +.byte 0xFC +.byte 0xFF +.byte 0xFF + stp +