From f44b029083da09cab4b9197e2c5a5da71e9f21cc Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Sat, 9 Dec 2017 14:50:33 -0600 Subject: [PATCH] We need to check P's value as well This test broke once we began to (properly) push P onto the stack. However, I'm not _clear_ on whether we should push P before or after we set the INTERRUPT bit... We'll go with things as-is for now. --- src/mos6502.exec.c | 2 +- tests/mos6502.exec.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mos6502.exec.c b/src/mos6502.exec.c index 306e74a..fe20253 100644 --- a/src/mos6502.exec.c +++ b/src/mos6502.exec.c @@ -14,9 +14,9 @@ */ DEFINE_INST(brk) { - cpu->P |= INTERRUPT; mos6502_push_stack(cpu, cpu->PC); mos6502_push_stack(cpu, cpu->P); + cpu->P |= INTERRUPT; cpu->PC += 2; } diff --git a/tests/mos6502.exec.c b/tests/mos6502.exec.c index 25e6631..7732ca2 100644 --- a/tests/mos6502.exec.c +++ b/tests/mos6502.exec.c @@ -8,10 +8,14 @@ TestSuite(mos6502_exec, .init = setup, .fini = teardown); Test(mos6502_exec, brk) { + vm_8bit orig_P = cpu->P; + cpu->PC = 123; mos6502_handle_brk(cpu, 0); cr_assert_eq(cpu->PC, 125); cr_assert_eq(cpu->P & INTERRUPT, INTERRUPT); + + cr_assert_eq(mos6502_pop_stack(cpu), orig_P); cr_assert_eq(mos6502_pop_stack(cpu), 123); }