diff --git a/Source/Interface/Core/OpcodeDispatcher.cpp b/Source/Interface/Core/OpcodeDispatcher.cpp index 2c9e6a31d..663668f6c 100644 --- a/Source/Interface/Core/OpcodeDispatcher.cpp +++ b/Source/Interface/Core/OpcodeDispatcher.cpp @@ -193,15 +193,6 @@ void OpDispatchBuilder::SBBOp(OpcodeArgs) { void OpDispatchBuilder::PUSHOp(OpcodeArgs) { uint8_t Size = GetSrcSize(Op); - auto Constant = _Constant(Size); - - auto OldSP = _LoadContext(8, offsetof(FEXCore::Core::CPUState, gregs[FEXCore::X86State::REG_RSP])); - - auto NewSP = _Sub(OldSP, Constant); - - // Store the new stack pointer - _StoreContext(8, offsetof(FEXCore::Core::CPUState, gregs[FEXCore::X86State::REG_RSP]), NewSP); - OrderedNode *Src; if (Op->OP == 0x68 || Op->OP == 0x6A) { // Immediate Push Src = LoadSource(Op, Op->Src1, Op->Flags, -1); @@ -211,6 +202,15 @@ void OpDispatchBuilder::PUSHOp(OpcodeArgs) { Src = LoadSource(Op, Op->Dest, Op->Flags, -1); } + auto Constant = _Constant(Size); + + auto OldSP = _LoadContext(8, offsetof(FEXCore::Core::CPUState, gregs[FEXCore::X86State::REG_RSP])); + + auto NewSP = _Sub(OldSP, Constant); + + // Store the new stack pointer + _StoreContext(8, offsetof(FEXCore::Core::CPUState, gregs[FEXCore::X86State::REG_RSP]), NewSP); + // Store our value to the new stack location _StoreMem(Size, NewSP, Src, Size); }