From f8594b23a7e6c31dc56ae285a165dcbc1dfae0aa Mon Sep 17 00:00:00 2001 From: Sour Date: Mon, 24 Feb 2020 22:00:29 -0500 Subject: [PATCH] CX4: Fixed PB register missing upper 8 bits when pulling from stack --- Core/Cx4.Instructions.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/Cx4.Instructions.cpp b/Core/Cx4.Instructions.cpp index a52d648..d266699 100644 --- a/Core/Cx4.Instructions.cpp +++ b/Core/Cx4.Instructions.cpp @@ -291,8 +291,8 @@ void Cx4::PushPC() void Cx4::PullPC() { _state.SP = (_state.SP - 1) & 0x07; - uint16_t value = _state.Stack[_state.SP]; - _state.PB = value >> 8; + uint32_t value = _state.Stack[_state.SP]; + _state.PB = (value >> 8) & 0x7FFF; _state.PC = value & 0xFF; } @@ -365,7 +365,7 @@ void Cx4::Load(uint8_t dest, uint8_t src) case 0: _state.A = GetSourceValue(src); break; case 1: _state.MemoryDataReg = GetSourceValue(src); break; case 2: _state.MemoryAddressReg = GetSourceValue(src); break; - case 3: _state.P = GetSourceValue(src); break; + case 3: _state.P = GetSourceValue(src) & 0x7FFF; break; } }