diff options
author | Andreas Gampe <agampe@google.com> | 2015-02-02 15:57:09 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-02-02 15:57:10 +0000 |
commit | 5d718dcd46a0a3c65b3635449d80947f342b1d2f (patch) | |
tree | cd7ab915520775c8ab7ea2563c0b6badc066c494 /disassembler | |
parent | e5deafe9cdd81238c3916b04301ea884c93f46b5 (diff) | |
parent | 031b00dc87cca699f02ce4206a9ecd99d59090dd (diff) | |
download | art-5d718dcd46a0a3c65b3635449d80947f342b1d2f.zip art-5d718dcd46a0a3c65b3635449d80947f342b1d2f.tar.gz art-5d718dcd46a0a3c65b3635449d80947f342b1d2f.tar.bz2 |
Merge "ART: Fix x86 disassembler"
Diffstat (limited to 'disassembler')
-rw-r--r-- | disassembler/disassembler_x86.cc | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/disassembler/disassembler_x86.cc b/disassembler/disassembler_x86.cc index 1a768c8..203488d 100644 --- a/disassembler/disassembler_x86.cc +++ b/disassembler/disassembler_x86.cc @@ -119,12 +119,6 @@ static void DumpBaseReg(std::ostream& os, uint8_t rex, uint8_t reg) { DumpAddrReg(os, rex, reg_num); } -static void DumpIndexReg(std::ostream& os, uint8_t rex, uint8_t reg) { - bool rex_x = (rex & REX_X) != 0; - uint8_t reg_num = rex_x ? (reg + 8) : reg; - DumpAddrReg(os, rex, reg_num); -} - static void DumpOpcodeReg(std::ostream& os, uint8_t rex, uint8_t reg, bool byte_operand, uint8_t size_override) { bool rex_b = (rex & REX_B) != 0; @@ -184,18 +178,30 @@ std::string DisassemblerX86::DumpAddress(uint8_t mod, uint8_t rm, uint8_t rex64, uint8_t index = (sib >> 3) & 7; uint8_t base = sib & 7; address << "["; + + // REX.x is bit 3 of index. + if ((rex64 & REX_X) != 0) { + index += 8; + } + + // Mod = 0 && base = 5 (ebp): no base (ignores REX.b). + bool has_base = false; if (base != 5 || mod != 0) { + has_base = true; DumpBaseReg(address, rex64, base); - if (index != 4) { - address << " + "; - } } + + // Index = 4 (esp/rsp) is disallowed. if (index != 4) { - DumpIndexReg(address, rex64, index); + if (has_base) { + address << " + "; + } + DumpAddrReg(address, rex64, index); if (scale != 0) { address << StringPrintf(" * %d", 1 << scale); } } + if (mod == 0) { if (base == 5) { if (index != 4) { |