Print properly signed displacement in IA32 disassembler.
authormstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 4 Mar 2014 13:07:00 +0000 (13:07 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 4 Mar 2014 13:07:00 +0000 (13:07 +0000)
R=jkummerow@chromium.org
BUG=

Review URL: https://codereview.chromium.org/176993004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19652 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/ia32/disasm-ia32.cc

index 177041de7ac114225bd65097f90feacd4fd8815f..d91dceb0f75ce30d304d0bd5584143c4a0c6481f 100644 (file)
@@ -449,8 +449,12 @@ int DisassemblerIA32::PrintRightOperandHelper(
       } else {
         // No sib.
         int disp =
-            mod == 2 ? *reinterpret_cast<int32_t*>(modrmp + 1) : *(modrmp + 1);
-        AppendToBuffer("[%s+0x%x]", (this->*register_name)(rm), disp);
+            mod == 2 ? *reinterpret_cast<int32_t*>(modrmp + 1) :
+                       *reinterpret_cast<int8_t*>(modrmp + 1);
+        AppendToBuffer("[%s%s0x%x]",
+                       (this->*register_name)(rm),
+                       disp < 0 ? "-" : "+",
+                       disp < 0 ? -disp : disp);
         return mod == 2 ? 5 : 2;
       }
       break;