Fixes bug in PUSH op with RSP source.

We were modifying RSP to adjust the stack first.
Then if the source used RSP then it was offset by the store size.

`push [rsp]` was broken before this
This commit is contained in:
Ryan Houdek authored and Stefanos Kornilios Mitsis Poiitidis committed 2020-03-06 07:56:00 +02:00
1 parent 2df55d303a
commit 3f06f3e87d
1 file changed
+9 -9
+9 -9
View File
@@ -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);
}