Index: src/x64/disasm-x64.cc |
diff --git a/src/x64/disasm-x64.cc b/src/x64/disasm-x64.cc |
index dd64d3f5ee4b3a501a850a4b7591c42b7cece2bc..f0f399ec0a73f0a0142f1f4c87e6d19a201bb853 100644 |
--- a/src/x64/disasm-x64.cc |
+++ b/src/x64/disasm-x64.cc |
@@ -485,9 +485,11 @@ int DisassemblerX64::PrintRightOperandHelper( |
} else if (base == 5) { |
// base == rbp means no base register (when mod == 0). |
int32_t disp = *reinterpret_cast<int32_t*>(modrmp + 2); |
- AppendToBuffer("[%s*%d+0x%x]", |
+ AppendToBuffer("[%s*%d%s0x%x]", |
NameOfCPURegister(index), |
- 1 << scale, disp); |
+ 1 << scale, |
+ disp < 0 ? "-" : "+", |
+ disp < 0 ? -disp : disp); |
return 6; |
} else if (index != 4 && base != 5) { |
// [base+index*scale] |
@@ -512,38 +514,29 @@ int DisassemblerX64::PrintRightOperandHelper( |
int scale, index, base; |
get_sib(sib, &scale, &index, &base); |
int disp = (mod == 2) ? *reinterpret_cast<int32_t*>(modrmp + 2) |
- : *reinterpret_cast<char*>(modrmp + 2); |
+ : *reinterpret_cast<int8_t*>(modrmp + 2); |
if (index == 4 && (base & 7) == 4 && scale == 0 /*times_1*/) { |
- if (-disp > 0) { |
- AppendToBuffer("[%s-0x%x]", NameOfCPURegister(base), -disp); |
- } else { |
- AppendToBuffer("[%s+0x%x]", NameOfCPURegister(base), disp); |
- } |
+ AppendToBuffer("[%s%s0x%x]", |
+ NameOfCPURegister(base), |
+ disp < 0 ? "-" : "+", |
+ disp < 0 ? -disp : disp); |
} else { |
- if (-disp > 0) { |
- AppendToBuffer("[%s+%s*%d-0x%x]", |
- NameOfCPURegister(base), |
- NameOfCPURegister(index), |
- 1 << scale, |
- -disp); |
- } else { |
- AppendToBuffer("[%s+%s*%d+0x%x]", |
- NameOfCPURegister(base), |
- NameOfCPURegister(index), |
- 1 << scale, |
- disp); |
- } |
+ AppendToBuffer("[%s+%s*%d%s0x%x]", |
+ NameOfCPURegister(base), |
+ NameOfCPURegister(index), |
+ 1 << scale, |
+ disp < 0 ? "-" : "+", |
+ disp < 0 ? -disp : disp); |
} |
return mod == 2 ? 6 : 3; |
} else { |
// No sib. |
int disp = (mod == 2) ? *reinterpret_cast<int32_t*>(modrmp + 1) |
- : *reinterpret_cast<char*>(modrmp + 1); |
- if (-disp > 0) { |
- AppendToBuffer("[%s-0x%x]", NameOfCPURegister(rm), -disp); |
- } else { |
- AppendToBuffer("[%s+0x%x]", NameOfCPURegister(rm), disp); |
- } |
+ : *reinterpret_cast<int8_t*>(modrmp + 1); |
+ AppendToBuffer("[%s%s0x%x]", |
+ NameOfCPURegister(rm), |
+ disp < 0 ? "-" : "+", |
+ disp < 0 ? -disp : disp); |
return (mod == 2) ? 5 : 2; |
} |
break; |