fix(code): add extrq decoding

This commit is contained in:
boykopovar 2026-08-05 12:41:18 +03:00
parent 1cc102f593
commit fca8b8d7eb
2 changed files with 22 additions and 2 deletions

View File

@ -156,6 +156,8 @@ inline constexpr std::uint8_t TwoBytePextrw = 0xC5;
inline constexpr std::uint8_t TwoByteShufpsImm8 = 0xC2;
inline constexpr std::uint8_t TwoByteShufpdImm8 = 0xC6;
inline constexpr std::uint8_t TwoByteGrp9 = 0xC7;
inline constexpr std::uint8_t TwoByteExtrqInsertqImm8Imm8 = 0x78;
inline constexpr std::uint8_t TwoByteExtrqInsertqModRm = 0x79;
inline constexpr std::uint8_t VexNoModRmMin = 0x77;
inline constexpr std::uint8_t VexNoModRmMax = 0x77;

View File

@ -11,11 +11,18 @@ std::size_t X64InstructionDecoder::Decode(const std::uint8_t* data, std::size_t
bool rexPresent = false;
std::uint8_t rex = 0;
bool operandSizeOverride = false;
bool repnePrefix = false;
while (pos < available) {
const std::uint8_t b = data[pos];
if (b == PrefixLock || b == PrefixRepne || b == PrefixRep ||
if (b == PrefixRepne) {
repnePrefix = true;
pos += 1;
continue;
}
if (b == PrefixLock || b == PrefixRep ||
b == PrefixSegCs || b == PrefixSegSs || b == PrefixSegDs || b == PrefixSegEs ||
b == PrefixSegFs || b == PrefixSegGs) {
pos += 1;
@ -196,7 +203,18 @@ std::size_t X64InstructionDecoder::Decode(const std::uint8_t* data, std::size_t
immediateSize = ImmSize8;
}
} else {
if (opcode >= TwoByteJccRel32Min && opcode <= TwoByteJccRel32Max) {
if (opcode == TwoByteExtrqInsertqImm8Imm8) {
if (!operandSizeOverride && !repnePrefix) {
throw CodegenException("Unsupported 0F 78 opcode without SSE4A prefix");
}
hasModRm = true;
immediateSize = ImmSize16;
} else if (opcode == TwoByteExtrqInsertqModRm) {
if (!operandSizeOverride && !repnePrefix) {
throw CodegenException("Unsupported 0F 79 opcode without SSE4A prefix");
}
hasModRm = true;
} else if (opcode >= TwoByteJccRel32Min && opcode <= TwoByteJccRel32Max) {
immediateSize = ImmSize32;
} else if (opcode == TwoByteMovImm8ModRm) {
hasModRm = true;