From adb70b62c34cdf97c37a29cb1094eeec82ab4851 Mon Sep 17 00:00:00 2001 From: jborza Date: Wed, 1 May 2019 21:10:12 +0200 Subject: [PATCH] fixed status register handling in PLP (bit 4 now not read) --- cpu.c | 2 ++ test6502.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cpu.c b/cpu.c index e6f8f22..b44672d 100644 --- a/cpu.c +++ b/cpu.c @@ -342,6 +342,8 @@ void PLA_(State6502* state) { void PLP_(State6502* state) { byte value = pop_byte_from_stack(state); + //we don't read the BRK flag + value ^= 1 << 4; memset(&state->flags, value, sizeof(Flags)); } diff --git a/test6502.c b/test6502.c index 881ce17..5c3e33a 100644 --- a/test6502.c +++ b/test6502.c @@ -1957,7 +1957,7 @@ void test_PLP() { assert_sp(&state, 0xFF); assert_flag_c(&state, 1); assert_flag_d(&state, 1); - assert_flag_b(&state, 1); + assert_flag_b(&state, 0); assert_flag_z(&state, 1); assert_flag_v(&state, 1); assert_flag_n(&state, 1);