decode: Move prefix before other opcode extensions

This commit is contained in:
Alexis Engelke
2020-11-08 10:27:03 +01:00
parent 2e7e396325
commit 01e1587c5c
2 changed files with 15 additions and 15 deletions

View File

@@ -396,15 +396,6 @@ fd_decode(const uint8_t* buffer, size_t len_sz, int mode_int, uintptr_t address,
if (LIKELY(off < len))
ENTRY_UNPACK(table, kind, table[buffer[off++]]);
// Then, walk through ModR/M-encoded opcode extensions.
if ((kind == ENTRY_TABLE8 || kind == ENTRY_TABLE72) && LIKELY(off < len))
{
if (kind == ENTRY_TABLE72 && (buffer[off] & 0xc0) == 0xc0)
ENTRY_UNPACK(table, kind, table[buffer[off++] - 0xb8]);
else
ENTRY_UNPACK(table, kind, table[(buffer[off] >> 3) & 7]);
}
// Handle mandatory prefixes (which behave like an opcode ext.).
if (kind == ENTRY_TABLE_PREFIX)
{
@@ -417,6 +408,15 @@ fd_decode(const uint8_t* buffer, size_t len_sz, int mode_int, uintptr_t address,
ENTRY_UNPACK(table, kind, table[mandatory_prefix]);
}
// Then, walk through ModR/M-encoded opcode extensions.
if ((kind == ENTRY_TABLE8 || kind == ENTRY_TABLE72) && LIKELY(off < len))
{
if (kind == ENTRY_TABLE72 && (buffer[off] & 0xc0) == 0xc0)
ENTRY_UNPACK(table, kind, table[buffer[off++] - 0xb8]);
else
ENTRY_UNPACK(table, kind, table[(buffer[off] >> 3) & 7]);
}
// For VEX prefix, we have to distinguish between VEX.W and VEX.L which may
// be part of the opcode.
if (kind == ENTRY_TABLE_VEX)