<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><blockquote type="cite"><div class="WordSection1" style="page: WordSection1;"><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';">I’m using the MCDisassembler for x86, and I’m having a really hard time handling instruction prefixes properly.<o:p></o:p></span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';"> </span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';">Here’s a concise example of the types of problems I am having:<o:p></o:p></span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';"> </span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';">66 F2 AF REPNE SCASW WORD PTR ES:[EDI]<o:p></o:p></span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';">F2 66 AF REPNE SCASW WORD PTR ES:[EDI]<o:p></o:p></span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';"> </span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';">llvm-mc does fine when the REPNE prefix is first, but gives incorrect disassembly when it follows the OPSIZE override.<o:p></o:p></span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';"> </span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';">With ToT, this is what I get:<br><br><o:p></o:p></span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';"> scasl %es:(%edi), %eax <-- incorrect (ignored osz)<o:p></o:p></span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';"> repne<o:p></o:p></span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';"> scasw %es:(%edi), %ax <-- correct<o:p></o:p></span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';"> </span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';">From my take, these should be equivalent instructions.<o:p></o:p></span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';"> </span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';">I have followed through the getID function, where it uses the attrMask of ATTR_XD, and then ands in the ATTR_OPSIZE to see if there is an equivalent.<o:p></o:p></span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';"> </span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';">However, that second call to getIDWithAttrMask returns PHI. For some reason there isn’t a way I’ve found to indicate that certain instructions are allowed in that IC_XD_OPSIZE context.<o:p></o:p></span></p><p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0.0001pt;"><span style="font-family: 'Courier New';"> </span></p><p class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><span style="color: rgb(0, 0, 0); font-family: 'Courier New'; font-size: 11pt;">I’ve tried a couple different things to change this, but it seems to break things all over the place. </span><font face="Courier New"><span style="font-size: 15px;">I’</span></font><font face="Courier New" size="3">m currently pretty much stymied by this, but</font><font face="Courier New">I’m willing to put in effort to make this better if someone can help me point in the right direction.</font></p><p class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><font face="Courier New"><br></font></p><p class="MsoNormal" style="margin: 0in 0in 0.0001pt;">Thanks,</p><p class="MsoNormal" style="margin: 0in 0in 0.0001pt;">Aaron</p></div></blockquote></div><div style="color: rgb(0, 0, 0); font-family: Calibri, sans-serif; font-size: 14px;"><div><p class="MsoNormal" style="margin: 0in 0in 6pt; font-size: 11pt;"><b><span style="font-size: 10pt; font-family: Arial, sans-serif; color: navy;">_____________________________________________________________________</span></b><span style="font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0in 0in 0.0001pt; font-size: 11pt;"><b><span style="font-size: 16pt; font-family: 'Courier New'; color: navy;">Aaron Lint</span></b><b><span style="font-size: 9pt; font-family: Verdana, sans-serif; color: navy;"><br></span></b><span style="font-family: 'Courier New'; color: navy;">Director of Product Development, GuardIT<br>Arxan Technologies, Inc.</span><span style="font-size: 8pt; font-family: 'Courier New'; color: navy;"><br></span><span style="font-size: 10pt; font-family: 'Courier New'; color: navy;">w:765-889-4756 x81 m:330-327-7524</span><span style="font-size: 8pt; font-family: Verdana, sans-serif; color: navy;"><br></span><span style="font-size: 8pt; font-family: 'Courier New'; color: rgb(255, 87, 6);"><a href="mailto:alint@arxan.com" title="mailto:dzakharov@arxan.com" style="color: rgb(149, 79, 114);"><span style="color: blue;">alint@arxan.com</span></a> </span><span style="font-size: 12pt; font-family: 'Courier New';"> <a href="http://www.arxan.com/" title="http://www.arxan.com/" style="color: rgb(149, 79, 114);"><span style="font-size: 8pt; color: rgb(255, 87, 6);">www.arxan.com</span></a><br></span><span style="font-size: 10pt; font-family: 'Courier New'; color: gray;">Protecting the App Economy™.</span></p></div><br></div></body></html>