From 42024c15737d613aa904b771fdb2a87e5be693a5 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 7 Aug 2023 09:19:20 -0400 Subject: [PATCH] Don't allow setting of an invalid S. --- Processors/65816/Implementation/65816Base.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Processors/65816/Implementation/65816Base.cpp b/Processors/65816/Implementation/65816Base.cpp index 3eaf614cd..eeaab17d8 100644 --- a/Processors/65816/Implementation/65816Base.cpp +++ b/Processors/65816/Implementation/65816Base.cpp @@ -30,7 +30,10 @@ uint16_t ProcessorBase::value_of(Register r) const { void ProcessorBase::set_value_of(Register r, uint16_t value) { switch (r) { case Register::ProgramCounter: registers_.pc = value; break; - case Register::StackPointer: registers_.s.full = value; break; + case Register::StackPointer: + registers_.s.full = value; + if(registers_.emulation_flag) registers_.s.halves.high = 1; + break; case Register::Flags: set_flags(uint8_t(value)); break; case Register::A: registers_.a.full = value; break; case Register::X: registers_.x.full = value & registers_.x_mask; break;