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);