From 26a2f51bc6d58658a47a03b700afdcc1af991b25 Mon Sep 17 00:00:00 2001 From: Sam M W Date: Sat, 15 Apr 2023 21:37:47 +0100 Subject: [PATCH] don't overshoot the stack pointer! (pla and plp) --- src/cpu.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpu.rs b/src/cpu.rs index 53ef685..a9956bc 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -433,13 +433,13 @@ impl CPU { (Instruction::PLA, OpInput::UseImplied) => { // Pull accumulator self.pull_from_stack(); - let val: u8 = self.pull_from_stack(); + let val: u8 = self.fetch_from_stack(); self.registers.accumulator = val as i8; } (Instruction::PLP, OpInput::UseImplied) => { // Pull status self.pull_from_stack(); - let val: u8 = self.pull_from_stack(); + let val: u8 = self.fetch_from_stack(); // The `truncate` here won't do anything because we have a // constant for the single unused flags bit. This probably // corresponds to the behavior of the 6502...? FIXME: verify