Fixes LEA instruction

LEA changes behaviour based on the ordering of the prefixes on the
instruction

eg:
66 48 8d 3d ffffffff: lea rdi, [rip - 1]
48 66 8d 3d ffffffff: lea di, [rip - 1]

So we need to know the order of a few of the prefixes.
In the future this should probably be switched to a three deep stack to
have the ordering but for now this'll do
This commit is contained in:
Ryan Houdek authored and Stefanos Kornilios Mitsis Poiitidis committed 2020-03-06 07:56:17 +02:00
1 parent 64e863a5a0
commit ec5f3a6854
3 files changed
+15 -4

No files matched your search

+3 -3
View File
@@ -66,9 +66,9 @@ void OpDispatchBuilder::SyscallOp(OpcodeArgs) {
}
void OpDispatchBuilder::LEAOp(OpcodeArgs) {
uint32_t DstSize = (Op->Flags & X86Tables::DecodeFlags::FLAG_OPERAND_SIZE) ? 16 :
(Op->Flags & X86Tables::DecodeFlags::FLAG_REX_WIDENING) ? 64 : 32;
uint32_t SrcSize = (Op->Flags & X86Tables::DecodeFlags::FLAG_ADDRESS_SIZE) ? 32 : 64;
uint32_t DstSize = X86Tables::DecodeFlags::GetOpAddr(Op->Flags) == X86Tables::DecodeFlags::FLAG_OPERAND_SIZE_LAST ? 2 :
X86Tables::DecodeFlags::GetOpAddr(Op->Flags) == X86Tables::DecodeFlags::FLAG_WIDENING_SIZE_LAST ? 8 : 4;
uint32_t SrcSize = (Op->Flags & X86Tables::DecodeFlags::FLAG_ADDRESS_SIZE) ? 4 : 8;
OrderedNode *Src = LoadSource_WithOpSize(GPRClass, Op, Op->Src[0], SrcSize, Op->Flags, -1, false);
StoreResult_WithOpSize(GPRClass, Op, Op->Dest, Src, DstSize, -1);