From 80136e9360bea37a68236b31e67e365dfc3c50fe Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Tue, 23 Jan 2018 20:41:48 -0600 Subject: [PATCH] Most status flags are now set when the CPU is created --- tests/mos6502.branch.c | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/mos6502.branch.c b/tests/mos6502.branch.c index 62dd955..53be7e2 100644 --- a/tests/mos6502.branch.c +++ b/tests/mos6502.branch.c @@ -10,22 +10,22 @@ Test(mos6502_branch, bcc) { cpu->eff_addr = 123; mos6502_handle_bcc(cpu, 0); - cr_assert_eq(cpu->PC, 123); + cr_assert_eq(cpu->PC, 2); - cpu->P |= MOS_CARRY; - cpu->eff_addr = 125; - mos6502_handle_bcc(cpu, 0); - cr_assert_neq(cpu->PC, 127); + cpu->P &= ~MOS_CARRY; + cpu->eff_addr = 128; + mos6502_handle_bcc(cpu, 3); + cr_assert_eq(cpu->PC, 128); } Test(mos6502_branch, bcs) { cpu->eff_addr = 123; mos6502_handle_bcs(cpu, 0); - cr_assert_neq(cpu->PC, 123); + cr_assert_eq(cpu->PC, 123); - cpu->P |= MOS_CARRY; - cpu->eff_addr = 125; + cpu->P &= ~MOS_CARRY; + cpu->eff_addr = 200; mos6502_handle_bcs(cpu, 0); cr_assert_eq(cpu->PC, 125); } @@ -34,69 +34,69 @@ Test(mos6502_branch, beq) { cpu->eff_addr = 123; mos6502_handle_beq(cpu, 0); - cr_assert_neq(cpu->PC, 123); + cr_assert_eq(cpu->PC, 123); - cpu->P |= MOS_ZERO; - cpu->eff_addr = 125; + cpu->P &= ~MOS_ZERO; + cpu->eff_addr = 150; mos6502_handle_beq(cpu, 0); - cr_assert_eq(cpu->PC, 125); + cr_assert_neq(cpu->PC, 150); } Test(mos6502_branch, bmi) { cpu->eff_addr = 123; mos6502_handle_bmi(cpu, 0); - cr_assert_neq(cpu->PC, 123); + cr_assert_eq(cpu->PC, 123); - cpu->P |= MOS_NEGATIVE; - cpu->eff_addr = 125; + cpu->P &= ~MOS_NEGATIVE; + cpu->eff_addr = 150; mos6502_handle_bmi(cpu, 0); - cr_assert_eq(cpu->PC, 125); + cr_assert_neq(cpu->PC, 150); } Test(mos6502_branch, bne) { cpu->eff_addr = 123; mos6502_handle_bne(cpu, 0); - cr_assert_eq(cpu->PC, 123); + cr_assert_neq(cpu->PC, 123); - cpu->P |= MOS_ZERO; + cpu->P &= ~MOS_ZERO; cpu->eff_addr = 125; mos6502_handle_bne(cpu, 0); - cr_assert_neq(cpu->PC, 127); + cr_assert_eq(cpu->PC, 125); } Test(mos6502_branch, bpl) { cpu->eff_addr = 123; mos6502_handle_bpl(cpu, 0); - cr_assert_eq(cpu->PC, 123); + cr_assert_neq(cpu->PC, 123); - cpu->P |= MOS_NEGATIVE; + cpu->P &= ~MOS_NEGATIVE; cpu->eff_addr = 125; mos6502_handle_bpl(cpu, 0); - cr_assert_neq(cpu->PC, 127); + cr_assert_eq(cpu->PC, 125); } Test(mos6502_branch, bvc) { cpu->eff_addr = 123; mos6502_handle_bvc(cpu, 0); - cr_assert_eq(cpu->PC, 123); + cr_assert_neq(cpu->PC, 123); - cpu->P |= MOS_OVERFLOW; + cpu->P &= ~MOS_OVERFLOW; cpu->eff_addr = 125; mos6502_handle_bvc(cpu, 0); - cr_assert_neq(cpu->PC, 127); + cr_assert_eq(cpu->PC, 125); } Test(mos6502_branch, bvs) { cpu->eff_addr = 123; mos6502_handle_bvs(cpu, 0); - cr_assert_neq(cpu->PC, 123); + cr_assert_eq(cpu->PC, 123); - cpu->P |= MOS_OVERFLOW; + cpu->P &= ~MOS_OVERFLOW; cpu->eff_addr = 125; mos6502_handle_bvs(cpu, 0); cr_assert_eq(cpu->PC, 125);