Fixed disasm in 64bit mode, added new accessor for printing 64bit values
This commit is contained in:
parent
9db896d100
commit
dd00bc66d0
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: dbg_main.cc,v 1.88 2007-01-04 20:12:32 sshwarts Exp $
|
||||
// $Id: dbg_main.cc,v 1.89 2007-01-13 10:43:31 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -1085,7 +1085,7 @@ void bx_dbg_print_stack_command(unsigned nwords)
|
||||
#if BX_SUPPORT_X86_64
|
||||
if (len == 8) {
|
||||
dbg_printf(" | STACK 0x%08x%08x [0x%08x:0x%08x]\n",
|
||||
(unsigned)(linear_sp >> 32), (unsigned)(linear_sp & 0xffffffff),
|
||||
GET_32H(linear_sp), GET32L(linear_sp),
|
||||
(unsigned) conv_4xBit8u_to_Bit32u(buf+4),
|
||||
(unsigned) conv_4xBit8u_to_Bit32u(buf));
|
||||
}
|
||||
@ -1796,56 +1796,39 @@ void bx_dbg_info_registers_command(int which_regs_mask)
|
||||
dbg_printf("eip: 0x%08x\n", (unsigned) reg);
|
||||
#else
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_RAX);
|
||||
dbg_printf("rax: 0x%08x:%08x ",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("rax: 0x%08x:%08x ", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_RCX);
|
||||
dbg_printf("rcx: 0x%08x:%08x\n",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("rcx: 0x%08x:%08x\n", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_RDX);
|
||||
dbg_printf("rdx: 0x%08x:%08x ",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("rdx: 0x%08x:%08x ", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_RBX);
|
||||
dbg_printf("rbx: 0x%08x:%08x\n",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("rbx: 0x%08x:%08x\n", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_RSP);
|
||||
dbg_printf("rsp: 0x%08x:%08x ",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("rsp: 0x%08x:%08x ", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_RBP);
|
||||
dbg_printf("rbp: 0x%08x:%08x\n",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("rbp: 0x%08x:%08x\n", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_RSI);
|
||||
dbg_printf("rsi: 0x%08x:%08x ",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("rsi: 0x%08x:%08x ", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_RDI);
|
||||
dbg_printf("rdi: 0x%08x:%08x\n",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("rdi: 0x%08x:%08x\n", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_R8);
|
||||
dbg_printf("r8 : 0x%08x:%08x ",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("r8 : 0x%08x:%08x ", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_R9);
|
||||
dbg_printf("r9 : 0x%08x:%08x\n",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("r9 : 0x%08x:%08x\n", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_R10);
|
||||
dbg_printf("r10: 0x%08x:%08x ",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("r10: 0x%08x:%08x ", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_R11);
|
||||
dbg_printf("r11: 0x%08x:%08x\n",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("r11: 0x%08x:%08x\n", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_R12);
|
||||
dbg_printf("r12: 0x%08x:%08x ",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("r12: 0x%08x:%08x ", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_R13);
|
||||
dbg_printf("r13: 0x%08x:%08x\n",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("r13: 0x%08x:%08x\n", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_R14);
|
||||
dbg_printf("r14: 0x%08x:%08x ",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("r14: 0x%08x:%08x ", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg32(BX_64BIT_REG_R15);
|
||||
dbg_printf("r15: 0x%08x:%08x\n",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("r15: 0x%08x:%08x\n", GET32H(reg), GET32L(reg));
|
||||
reg = bx_dbg_get_instruction_pointer();
|
||||
dbg_printf("rip: 0x%08x:%08x\n",
|
||||
(unsigned)(reg>>32), (unsigned)(reg & 0xffffffff));
|
||||
dbg_printf("rip: 0x%08x:%08x\n", GET32H(reg), GET32L(reg));
|
||||
#endif
|
||||
reg = BX_CPU(dbg_cpu)->read_eflags();
|
||||
dbg_printf("eflags 0x%08x\n", (unsigned) reg);
|
||||
|
@ -1,5 +1,5 @@
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// $Id: call_far.cc,v 1.13 2006-10-04 19:08:39 sshwarts Exp $
|
||||
// $Id: call_far.cc,v 1.14 2007-01-13 10:43:31 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -530,7 +530,7 @@ BX_CPU_C::call_gate64(bx_selector_t *gate_selector)
|
||||
|
||||
if (! IsCanonical(RSP_for_cpl_x)) {
|
||||
BX_ERROR(("call_gate64: canonical address failure %08x%08x",
|
||||
(Bit32u)(RSP_for_cpl_x >> 32), (Bit32u)(RSP_for_cpl_x & 0xffffffff)));
|
||||
GET32H(RSP_for_cpl_x), GET32L(RSP_for_cpl_x)));
|
||||
exception(BX_GP_EXCEPTION, 0, 0);
|
||||
}
|
||||
|
||||
@ -565,8 +565,8 @@ BX_CPU_C::call_gate64(bx_selector_t *gate_selector)
|
||||
|
||||
// make sure that push CS:RIP will not fail
|
||||
if (! IsCanonical(RSP)) {
|
||||
BX_ERROR(("call_gate64: canonical address failure %08x%08x",
|
||||
(Bit32u)(RSP >> 32), (Bit32u)(RSP & 0xffffffff)));
|
||||
BX_ERROR(("call_gate64: canonical address failure %08x%08x",
|
||||
GET32H(RSP), GET32L(RSP)));
|
||||
exception(BX_GP_EXCEPTION, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: exception.cc,v 1.87 2006-10-20 15:38:39 vruppert Exp $
|
||||
// $Id: exception.cc,v 1.88 2007-01-13 10:43:31 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -184,7 +184,7 @@ void BX_CPU_C::long_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error_code
|
||||
|
||||
if (! IsCanonical(RSP_for_cpl_x)) {
|
||||
BX_ERROR(("interrupt(long mode): canonical address failure %08x%08x",
|
||||
(Bit32u)(RSP_for_cpl_x >> 32), (Bit32u)(RSP_for_cpl_x & 0xffffffff)));
|
||||
GET32H(RSP_for_cpl_x), GET32L(RSP_for_cpl_x)));
|
||||
exception(BX_GP_EXCEPTION, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: paging.cc,v 1.80 2006-10-28 12:31:23 sshwarts Exp $
|
||||
// $Id: paging.cc,v 1.81 2007-01-13 10:43:31 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -1022,8 +1022,7 @@ page_fault_not_present:
|
||||
#endif
|
||||
#if BX_SUPPORT_X86_64
|
||||
BX_DEBUG(("page fault for address %08x%08x @ %08x%08x",
|
||||
(Bit32u)(laddr >> 32),(Bit32u)(laddr & 0xffffffff),
|
||||
(Bit32u)(RIP >> 32),(Bit32u)(RIP & 0xffffffff)));
|
||||
GET32H(laddr), GET32L(laddr), GET32H(RIP), GET32L(RIP)));
|
||||
#else
|
||||
BX_DEBUG(("page fault for address %08x @ %08x", laddr, EIP));
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: protect_ctrl.cc,v 1.51 2007-01-12 22:47:21 sshwarts Exp $
|
||||
// $Id: protect_ctrl.cc,v 1.52 2007-01-13 10:43:31 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -445,6 +445,7 @@ void BX_CPU_C::LTR_Ew(bxInstruction_c *i)
|
||||
BX_INFO(("64 bit tss base = 0x%08x%08x",
|
||||
(Bit32u)(descriptor.u.system.base >> 32),
|
||||
(Bit32u) descriptor.u.system.base));
|
||||
BX_CPU_THIS_PTR trace = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: smm.cc,v 1.22 2006-10-03 22:41:02 sshwarts Exp $
|
||||
// $Id: smm.cc,v 1.23 2007-01-13 10:43:31 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2006 Stanislav Shwartsman
|
||||
@ -215,21 +215,21 @@ void BX_CPU_C::smram_save_state(Bit32u *saved_state)
|
||||
{
|
||||
// --- General Purpose Registers --- //
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RAX_HI32) = RAX >> 32;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RAX_LO32) = RAX & 0xffffffff;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RAX_LO32) = EAX;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RCX_HI32) = RCX >> 32;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RCX_LO32) = RCX & 0xffffffff;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RCX_LO32) = ECX;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RDX_HI32) = RDX >> 32;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RDX_LO32) = RDX & 0xffffffff;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RDX_LO32) = EDX;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RBX_HI32) = RBX >> 32;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RBX_LO32) = RBX & 0xffffffff;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RBX_LO32) = EBX;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RSP_HI32) = RSP >> 32;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RSP_LO32) = RSP & 0xffffffff;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RSP_LO32) = ESP;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RBP_HI32) = RBP >> 32;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RBP_LO32) = RBP & 0xffffffff;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RBP_LO32) = EBP;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RSI_HI32) = RSI >> 32;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RSI_LO32) = RSI & 0xffffffff;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RSI_LO32) = ESI;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RDI_HI32) = RDI >> 32;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RDI_LO32) = RDI & 0xffffffff;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_RDI_LO32) = EDI;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_R8_HI32) = R8 >> 32;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_R8_LO32) = R8 & 0xffffffff;
|
||||
SMRAM_FIELD(saved_state, SMRAM_OFFSET_R9_HI32) = R9 >> 32;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: dis_groups.cc,v 1.33 2006-08-13 09:40:07 sshwarts Exp $
|
||||
// $Id: dis_groups.cc,v 1.34 2007-01-13 10:43:31 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdio.h>
|
||||
@ -225,8 +225,7 @@ void disassembler::Iq(const x86_insn *insn)
|
||||
Bit64u value = fetch_qword();
|
||||
|
||||
if (! intel_mode) dis_putc('$');
|
||||
dis_sprintf("0x%08x%08x",
|
||||
(unsigned)(value>>32), (unsigned)(value & 0xffffffff));
|
||||
dis_sprintf("0x%08x%08x", GET32H(value), GET32L(value));
|
||||
}
|
||||
|
||||
// sign extended immediate
|
||||
@ -250,8 +249,7 @@ void disassembler::sIbq(const x86_insn *insn)
|
||||
{
|
||||
if (! intel_mode) dis_putc('$');
|
||||
Bit64u imm64 = (Bit8s) fetch_byte();
|
||||
dis_sprintf ("0x%08x%08x",
|
||||
(unsigned)(imm64>>32), (unsigned)(imm64 & 0xffffffff));
|
||||
dis_sprintf ("0x%08x%08x", GET32H(imm64), GET32L(imm64));
|
||||
}
|
||||
|
||||
// sign extended immediate
|
||||
@ -259,8 +257,7 @@ void disassembler::sIdq(const x86_insn *insn)
|
||||
{
|
||||
if (! intel_mode) dis_putc('$');
|
||||
Bit64u imm64 = (Bit32s) fetch_dword();
|
||||
dis_sprintf ("0x%08x%08x",
|
||||
(unsigned)(imm64>>32), (unsigned)(imm64 & 0xffffffff));
|
||||
dis_sprintf ("0x%08x%08x", GET32H(imm64), GET32L(imm64));
|
||||
}
|
||||
|
||||
// floating point
|
||||
@ -422,8 +419,7 @@ void disassembler::OP_O(const x86_insn *insn, unsigned size)
|
||||
|
||||
if (insn->as_64) {
|
||||
Bit64u imm64 = fetch_qword();
|
||||
dis_sprintf("%s:0x%08x%08x", seg,
|
||||
(unsigned)(imm64>>32), (unsigned)(imm64 & 0xffffffff));
|
||||
dis_sprintf("%s:0x%08x%08x", seg, GET32H(imm64), GET32L(imm64));
|
||||
}
|
||||
else if (insn->as_32) {
|
||||
Bit32u imm32 = fetch_dword();
|
||||
@ -533,13 +529,11 @@ void disassembler::Jb(const x86_insn *insn)
|
||||
|
||||
if (insn->is_64) {
|
||||
Bit64u imm64 = (Bit64s) imm8;
|
||||
dis_sprintf(".+0x%08x%08x",
|
||||
(unsigned)(imm64>>32), (unsigned)(imm64 & 0xffffffff));
|
||||
dis_sprintf(".+0x%08x%08x", GET32H(imm64), GET32L(imm64));
|
||||
|
||||
if (db_base != BX_JUMP_TARGET_NOT_REQ) {
|
||||
Bit64u target = db_eip + (Bit64s) imm64; target += db_base;
|
||||
dis_sprintf(" (0x%08x%08x)",
|
||||
(unsigned)(target>>32), (unsigned)(target & 0xffffffff));
|
||||
dis_sprintf(" (0x%08x%08x)", GET32H(target), GET32L(target));
|
||||
}
|
||||
|
||||
return;
|
||||
@ -586,13 +580,11 @@ void disassembler::Jd(const x86_insn *insn)
|
||||
|
||||
if (insn->is_64) {
|
||||
Bit64u imm64 = (Bit64s) imm32;
|
||||
dis_sprintf(".+0x%08x%08x",
|
||||
(unsigned)(imm64>>32), (unsigned)(imm64 & 0xffffffff));
|
||||
dis_sprintf(".+0x%08x%08x", GET32H(imm64), GET32L(imm64));
|
||||
|
||||
if (db_base != BX_JUMP_TARGET_NOT_REQ) {
|
||||
Bit64u target = db_eip + (Bit64s) imm64; target += db_base;
|
||||
dis_sprintf(" (0x%08x%08x)",
|
||||
(unsigned)(target>>32), (unsigned)(target & 0xffffffff));
|
||||
dis_sprintf(" (0x%08x%08x)", GET32H(target), GET32L(target));
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -273,7 +273,8 @@ private:
|
||||
void print_memory_access16(int datasize,
|
||||
const char *seg, const char *index, Bit16u disp);
|
||||
void print_memory_access (int datasize,
|
||||
const char *seg, const char *base, const char *index, int scale, Bit32u disp);
|
||||
const char *seg, const char *base, const char *index, int scale,
|
||||
Bit32s disp, bx_bool disp64 = 0);
|
||||
|
||||
void print_disassembly_intel(const x86_insn *insn, const BxDisasmOpcodeInfo_t *entry);
|
||||
void print_disassembly_att (const x86_insn *insn, const BxDisasmOpcodeInfo_t *entry);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: resolve.cc,v 1.13 2006-08-11 17:22:43 sshwarts Exp $
|
||||
// $Id: resolve.cc,v 1.14 2007-01-13 10:43:31 sshwarts Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdio.h>
|
||||
@ -244,7 +244,7 @@ void disassembler::resolve64_mod0(const x86_insn *insn, unsigned mode)
|
||||
else rip_regname = "%rip";
|
||||
|
||||
if ((insn->rm & 7) == 5) /* no reg, 32-bit displacement */
|
||||
print_memory_access(mode, seg, rip_regname, NULL, 0, insn->displacement.displ32);
|
||||
print_memory_access(mode, seg, rip_regname, NULL, 0, (Bit32s) insn->displacement.displ32, 1);
|
||||
else
|
||||
print_memory_access(mode, seg, general_64bit_regname[insn->rm], NULL, 0, 0);
|
||||
}
|
||||
@ -259,13 +259,13 @@ void disassembler::resolve64_mod1or2(const x86_insn *insn, unsigned mode)
|
||||
seg = sreg_mod01or10_rm32[insn->rm];
|
||||
|
||||
print_memory_access(mode, seg,
|
||||
general_64bit_regname[insn->rm], NULL, 0, insn->displacement.displ32);
|
||||
general_64bit_regname[insn->rm], NULL, 0, (Bit32s) insn->displacement.displ32, 1);
|
||||
}
|
||||
|
||||
void disassembler::resolve64_mod0_rm4(const x86_insn *insn, unsigned mode)
|
||||
{
|
||||
const char *seg, *base = NULL, *index = NULL;
|
||||
Bit32u disp32 = 0;
|
||||
Bit32s disp32 = 0;
|
||||
|
||||
if (insn->is_seg_override())
|
||||
seg = segment_name[insn->seg_override];
|
||||
@ -275,12 +275,12 @@ void disassembler::resolve64_mod0_rm4(const x86_insn *insn, unsigned mode)
|
||||
if ((insn->base & 7) != 5)
|
||||
base = general_64bit_regname[insn->base];
|
||||
else
|
||||
disp32 = insn->displacement.displ32;
|
||||
disp32 = (Bit32s) insn->displacement.displ32;
|
||||
|
||||
if (insn->index != 4)
|
||||
index = general_64bit_regname[insn->index];
|
||||
|
||||
print_memory_access(mode, seg, base, index, insn->scale, disp32);
|
||||
print_memory_access(mode, seg, base, index, insn->scale, disp32, 1);
|
||||
}
|
||||
|
||||
void disassembler::resolve64_mod1or2_rm4(const x86_insn *insn, unsigned mode)
|
||||
@ -296,7 +296,7 @@ void disassembler::resolve64_mod1or2_rm4(const x86_insn *insn, unsigned mode)
|
||||
index = general_64bit_regname[insn->index];
|
||||
|
||||
print_memory_access(mode, seg,
|
||||
general_64bit_regname[insn->base], index, insn->scale, insn->displacement.displ32);
|
||||
general_64bit_regname[insn->base], index, insn->scale, (Bit32s) insn->displacement.displ32, 1);
|
||||
}
|
||||
|
||||
void disassembler::print_datasize(unsigned size)
|
||||
@ -366,9 +366,11 @@ void disassembler::print_memory_access16(int datasize,
|
||||
}
|
||||
|
||||
void disassembler::print_memory_access(int datasize,
|
||||
const char *seg, const char *base, const char *index, int scale, Bit32u disp)
|
||||
const char *seg, const char *base, const char *index, int scale, Bit32s disp, bx_bool disp64)
|
||||
{
|
||||
print_datasize(datasize);
|
||||
|
||||
scale = 1 << scale;
|
||||
|
||||
if (intel_mode)
|
||||
{
|
||||
@ -380,19 +382,33 @@ void disassembler::print_memory_access(int datasize,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (scale != 0)
|
||||
if (scale != 1)
|
||||
{
|
||||
if (disp != 0)
|
||||
dis_sprintf("%s:[%s*%d+0x%x]", seg, index, 1<<scale, (unsigned) disp);
|
||||
if (disp != 0) {
|
||||
if (disp64) {
|
||||
dis_sprintf("%s:[%s*%d+0x%08x%08x]", seg, index, scale,
|
||||
GET32H(disp), GET32L(disp));
|
||||
}
|
||||
else {
|
||||
dis_sprintf("%s:[%s*%d+0x%x]", seg, index, scale, (unsigned) disp);
|
||||
}
|
||||
}
|
||||
else
|
||||
dis_sprintf("%s:[%s*%d]", seg, index, 1<<scale);
|
||||
dis_sprintf("%s:[%s*%d]", seg, index, scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (disp != 0)
|
||||
dis_sprintf("%s:[%s+0x%x]", seg, index, (unsigned) disp);
|
||||
else
|
||||
if (disp != 0) {
|
||||
if (disp64) {
|
||||
dis_sprintf("%s:[%s+0x%08x%08x]", seg, index, GET32H(disp), GET32L(disp));
|
||||
}
|
||||
else {
|
||||
dis_sprintf("%s:[%s+0x%x]", seg, index, (unsigned) disp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dis_sprintf("%s:[%s]", seg, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -400,24 +416,45 @@ void disassembler::print_memory_access(int datasize,
|
||||
{
|
||||
if (index == NULL)
|
||||
{
|
||||
if (disp != 0)
|
||||
dis_sprintf("%s:[%s+0x%x]", seg, base, (unsigned) disp);
|
||||
else
|
||||
if (disp != 0) {
|
||||
if (disp64) {
|
||||
dis_sprintf("%s:[%s+0x%08x%08x]", seg, base, GET32H(disp), GET32L(disp));
|
||||
}
|
||||
else {
|
||||
dis_sprintf("%s:[%s+0x%x]", seg, base, (unsigned) disp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dis_sprintf("%s:[%s]", seg, base);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (scale != 0)
|
||||
if (scale != 1)
|
||||
{
|
||||
if (disp != 0)
|
||||
dis_sprintf("%s:[%s+%s*%d+0x%x]", seg, base, index, 1<<scale, (unsigned) disp);
|
||||
else
|
||||
dis_sprintf("%s:[%s+%s*%d]", seg, base, index, 1<<scale);
|
||||
if (disp != 0) {
|
||||
if (disp64) {
|
||||
dis_sprintf("%s:[%s+%s*%d+0x%08x%08x]", seg, base, index, scale,
|
||||
GET32H(disp), GET32L(disp));
|
||||
}
|
||||
else {
|
||||
dis_sprintf("%s:[%s+%s*%d+0x%x]", seg, base, index, scale, (unsigned) disp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dis_sprintf("%s:[%s+%s*%d]", seg, base, index, scale);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (disp != 0)
|
||||
dis_sprintf("%s:[%s+%s+0x%x]", seg, base, index, (unsigned) disp);
|
||||
if (disp != 0) {
|
||||
if (disp64) {
|
||||
dis_sprintf("%s:[%s+%s+0x%08x%08x]", seg, base, index, GET32H(disp), GET32L(disp));
|
||||
}
|
||||
else {
|
||||
dis_sprintf("%s:[%s+%s+0x%x]", seg, base, index, (unsigned) disp);
|
||||
}
|
||||
}
|
||||
else
|
||||
dis_sprintf("%s:[%s+%s]", seg, base, index);
|
||||
}
|
||||
@ -430,31 +467,52 @@ void disassembler::print_memory_access(int datasize,
|
||||
{
|
||||
if (index == NULL)
|
||||
{
|
||||
dis_sprintf("%s:0x%x", seg, (unsigned) disp);
|
||||
if (disp64) {
|
||||
dis_sprintf("%s:0x%x", seg, GET32H(disp), GET32L(disp));
|
||||
} else {
|
||||
dis_sprintf("%s:0x%x", seg, (unsigned) disp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (disp != 0)
|
||||
dis_sprintf("%s:0x%x(,%s,%d)", seg, (unsigned) disp, index, 1<<scale);
|
||||
if (disp != 0) {
|
||||
if (disp64) {
|
||||
dis_sprintf("%s:0x%08x%08x(,%s,%d)", seg, GET32H(disp), GET32L(disp), index, scale);
|
||||
} else {
|
||||
dis_sprintf("%s:0x%x(,%s,%d)", seg, (unsigned) disp, index, scale);
|
||||
}
|
||||
}
|
||||
else
|
||||
dis_sprintf("%s:(,%s,%d)", seg, index, 1<<scale);
|
||||
dis_sprintf("%s:(,%s,%d)", seg, index, scale);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (index == NULL)
|
||||
{
|
||||
if (disp != 0)
|
||||
dis_sprintf("%s:0x%x(%s)", seg, (unsigned) disp, base);
|
||||
if (disp != 0) {
|
||||
if (disp64) {
|
||||
dis_sprintf("%s:0x%08x%08x(%s)", seg, GET32H(disp), GET32L(disp), base);
|
||||
}
|
||||
else {
|
||||
dis_sprintf("%s:0x%x(%s)", seg, (unsigned) disp, base);
|
||||
}
|
||||
}
|
||||
else
|
||||
dis_sprintf("%s:(%s)", seg, base);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (disp != 0)
|
||||
dis_sprintf("%s:0x%x(%s,%s,%d)", seg, (unsigned) disp, base, index, 1<<scale);
|
||||
if (disp != 0) {
|
||||
if (disp64) {
|
||||
dis_sprintf("%s:0x%08x%08x(%s,%s,%d)", seg, GET32H(disp), GET32L(disp), base, index, scale);
|
||||
}
|
||||
else {
|
||||
dis_sprintf("%s:0x%x(%s,%s,%d)", seg, (unsigned) disp, base, index, scale);
|
||||
}
|
||||
}
|
||||
else
|
||||
dis_sprintf("%s:(%s,%s,%d)", seg, base, index, 1<<scale);
|
||||
dis_sprintf("%s:(%s,%s,%d)", seg, base, index, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user