1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-11-27 20:51:17 +00:00

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.
This commit is contained in:
Peter Evans 2017-12-09 14:50:33 -06:00
parent 96b2542ea6
commit f44b029083
2 changed files with 5 additions and 1 deletions

View File

@ -14,9 +14,9 @@
*/ */
DEFINE_INST(brk) DEFINE_INST(brk)
{ {
cpu->P |= INTERRUPT;
mos6502_push_stack(cpu, cpu->PC); mos6502_push_stack(cpu, cpu->PC);
mos6502_push_stack(cpu, cpu->P); mos6502_push_stack(cpu, cpu->P);
cpu->P |= INTERRUPT;
cpu->PC += 2; cpu->PC += 2;
} }

View File

@ -8,10 +8,14 @@ TestSuite(mos6502_exec, .init = setup, .fini = teardown);
Test(mos6502_exec, brk) Test(mos6502_exec, brk)
{ {
vm_8bit orig_P = cpu->P;
cpu->PC = 123; cpu->PC = 123;
mos6502_handle_brk(cpu, 0); mos6502_handle_brk(cpu, 0);
cr_assert_eq(cpu->PC, 125); cr_assert_eq(cpu->PC, 125);
cr_assert_eq(cpu->P & INTERRUPT, INTERRUPT); cr_assert_eq(cpu->P & INTERRUPT, INTERRUPT);
cr_assert_eq(mos6502_pop_stack(cpu), orig_P);
cr_assert_eq(mos6502_pop_stack(cpu), 123); cr_assert_eq(mos6502_pop_stack(cpu), 123);
} }