decode: Fix erroneous decoding of high-byte regs

This commit is contained in:
Alexis Engelke
2020-11-28 13:54:19 +01:00
parent 757acf18c3
commit 8976c7141a
2 changed files with 13 additions and 4 deletions

View File

@@ -605,12 +605,20 @@ prefix_end:
break; break;
operand->size = operand_sizes[(desc->operand_sizes >> 2 * i) & 3]; operand->size = operand_sizes[(desc->operand_sizes >> 2 * i) & 3];
}
// if (operand->type == FD_OT_REG && operand->misc == FD_RT_GPL && if (UNLIKELY(op_size == 1 || instr->type == FDI_MOVSX || instr->type == FDI_MOVZX)) {
// !(prefixes & PREFIX_REX) && operand->size == 1 && operand->reg >= 4) if (!(prefix_rex & PREFIX_REX)) {
if (!(prefix_rex & PREFIX_REX) && (LOAD_LE_4(operand) & 0xfffcffff) == 0x01040101) for (int i = 0; i < 2; i++) {
FdOp* operand = &instr->operands[i];
if (operand->type == FD_OT_NONE)
break;
if (operand->type == FD_OT_REG && operand->misc == FD_RT_GPL &&
operand->size == 1 && operand->reg >= 4)
operand->misc = FD_RT_GPH; operand->misc = FD_RT_GPH;
} }
}
}
instr->size = off; instr->size = off;
instr->operandsz = DESC_INSTR_WIDTH(desc) ? op_size : 0; instr->operandsz = DESC_INSTR_WIDTH(desc) ? op_size : 0;

View File

@@ -280,6 +280,7 @@ main(int argc, char** argv)
TEST64("\x66\x0f\x50\xc1", "[SSE_MOVMSKPD reg8:r0 reg16:r1]"); TEST64("\x66\x0f\x50\xc1", "[SSE_MOVMSKPD reg8:r0 reg16:r1]");
TEST("\x66\x0f\xc6\xc0\x01", "[SSE_SHUFPD reg16:r0 reg16:r0 imm1:0x1]"); TEST("\x66\x0f\xc6\xc0\x01", "[SSE_SHUFPD reg16:r0 reg16:r0 imm1:0x1]");
TEST("\x66\x0f\x71\xd0\x01", "[SSE_PSRLW reg16:r0 imm1:0x1]"); TEST("\x66\x0f\x71\xd0\x01", "[SSE_PSRLW reg16:r0 imm1:0x1]");
TEST("\x66\x0f\x3a\x20\xc4\x01", "[SSE_PINSRB reg16:r0 reg1:r4 imm1:0x1]");
TEST("\x66\x0f\x71\x10\x01", "UD"); TEST("\x66\x0f\x71\x10\x01", "UD");
TEST32("\xc4\x00", "[LES reg4:r0 mem0:r0]"); TEST32("\xc4\x00", "[LES reg4:r0 mem0:r0]");