<div dir="ltr"><div><div><div><div><div><div><div><div>hi,<br><br></div>i think the current X86 disassembler is quite broken and fails badly on handling REX for x86_64 code.<br><br></div>below are some examples:<br><br>$ echo "0x0f,0xeb,0xc3"|./Release+Asserts/bin/llvm-mc -disassemble -triple=x86_64<br>    .text<br>    por    %mm3, %mm0<br><br>$ echo "0x40,0x0f,0xeb,0xc3"|./Release+Asserts/bin/llvm-mc -disassemble -triple=x86_64<br>    .text<br>    por    %mm3, %mm0<br><br>$ echo "0x41,0x0f,0xeb,0xc3"|./Release+Asserts/bin/llvm-mc -disassemble -triple=x86_64<br>    .text<br><stdin>:1:1: warning: invalid instruction encoding<br>0x41,0x0f,0xeb,0xc3<br>^<br><br><br></div>the last example should also return "por %mm3, %mm0", but it fails to understand the input.<br><br>the reason stays with this line in X86DisassemblerDecoder.cpp:<br><br>    rm  |= bFromREX(insn->rexPrefix) << 3;<br><br></div>we can see that we take into account REX.B, but for "por" (0F EB), this should be ignored.<br><br></div>there are quite a lot of other instructions taking into account REX like this, while according to the manual, REX should be ignored.<br><br></div>i dont see any clean solution for this issue without some significant changes into the way we decode ModRM & providing more information to .td files.<br><br>any idea?<br><br></div>thanks.<br></div>Jun<br></div>