harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r584828 - /harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp
Date Mon, 15 Oct 2007 17:25:50 GMT
Author: gshimansky
Date: Mon Oct 15 10:25:49 2007
New Revision: 584828

URL: http://svn.apache.org/viewvc?rev=584828&view=rev
Log:
Make disassembler match instructions with various REX prefixes


Modified:
    harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp?rev=584828&r1=584827&r2=584828&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp Mon Oct 15 10:25:49
2007
@@ -233,14 +233,28 @@
 bool DecoderBase::try_mn(Mnemonic mn, const unsigned char ** pbuf, Inst * pinst) {
     const unsigned char * save_pbuf = *pbuf;
     EncoderBase::OpcodeDesc * opcodes = EncoderBase::opcodes[mn];
+
     for (unsigned i=0; !opcodes[i].last; i++) {
         const EncoderBase::OpcodeDesc& odesc = opcodes[i];
+        char *opcode_ptr = const_cast<char *>(odesc.opcode);
+        int opcode_len = odesc.opcode_len;
+
         *pbuf = save_pbuf;
-        if (odesc.opcode_len != 0) {
-            if (memcmp(*pbuf, odesc.opcode, odesc.opcode_len)) {
+        if (opcode_len != 0) {
+#ifdef _EM64T_
+            // Match REX prefixes
+            if (((*pbuf)[0] & 0xf0) == 0x40 && opcode_ptr[0] == 0x48)
+            {
+                (*pbuf)++;
+                opcode_ptr++;
+                opcode_len--;
+            }
+#endif
+
+            if (memcmp(*pbuf, opcode_ptr, opcode_len)) {
                 continue;
             }
-            *pbuf += odesc.opcode_len;
+            *pbuf += opcode_len;
         }
         if (odesc.aux0 != 0) {
             
@@ -257,7 +271,7 @@
         }
         else {
             // Can't have empty opcode
-            assert(odesc.opcode_len != 0);
+            assert(opcode_len != 0);
             pinst->odesc = &opcodes[i];
             return true;
         }



Mime
View raw message