2006-04-27 19:11:45 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2006-04-27 19:11:45 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2009-10-15 00:45:29 +04:00
|
|
|
//
|
2011-03-19 23:09:34 +03:00
|
|
|
// Copyright (c) 2005-2011 Stanislav Shwartsman
|
2009-10-15 00:45:29 +04:00
|
|
|
// Written by Stanislav Shwartsman [sshwarts at sourceforge net]
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2006-04-27 19:11:45 +04:00
|
|
|
|
2003-12-24 23:32:59 +03:00
|
|
|
#include <stdio.h>
|
2006-02-11 22:46:03 +03:00
|
|
|
#include <assert.h>
|
2004-01-04 21:53:02 +03:00
|
|
|
#include "disasm.h"
|
2004-10-18 02:05:17 +04:00
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
/*
|
2004-10-18 02:05:17 +04:00
|
|
|
#if BX_DEBUGGER
|
2004-01-04 21:53:02 +03:00
|
|
|
#include "../bx_debug/debug.h"
|
2004-10-18 02:05:17 +04:00
|
|
|
#endif
|
2005-12-23 17:15:13 +03:00
|
|
|
*/
|
2002-08-12 18:39:40 +04:00
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
void disassembler::Apw(const x86_insn *insn)
|
2002-08-12 18:39:40 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
Bit16u imm16 = fetch_word();
|
|
|
|
Bit16u cs_selector = fetch_word();
|
|
|
|
dis_sprintf("%04x:%04x", (unsigned) cs_selector, (unsigned) imm16);
|
2002-08-12 18:39:40 +04:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
void disassembler::Apd(const x86_insn *insn)
|
2002-08-12 18:39:40 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
Bit32u imm32 = fetch_dword();
|
|
|
|
Bit16u cs_selector = fetch_word();
|
|
|
|
dis_sprintf("%04x:%08x", (unsigned) cs_selector, (unsigned) imm32);
|
2002-08-12 18:39:40 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// 8-bit general purpose registers
|
2009-01-19 22:01:03 +03:00
|
|
|
void disassembler::AL_Reg(const x86_insn *insn) { dis_sprintf("%s", general_8bit_regname[rAX_REG]); }
|
|
|
|
void disassembler::CL_Reg(const x86_insn *insn) { dis_sprintf("%s", general_8bit_regname[rCX_REG]); }
|
2002-08-12 18:39:40 +04:00
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// 16-bit general purpose registers
|
2009-01-19 22:01:03 +03:00
|
|
|
void disassembler::AX_Reg(const x86_insn *insn) {
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s", general_16bit_regname[rAX_REG]);
|
2002-09-20 19:34:55 +04:00
|
|
|
}
|
|
|
|
|
2009-01-19 22:01:03 +03:00
|
|
|
void disassembler::DX_Reg(const x86_insn *insn) {
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s", general_16bit_regname[rDX_REG]);
|
2003-08-04 20:03:09 +04:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// 32-bit general purpose registers
|
2009-01-19 22:01:03 +03:00
|
|
|
void disassembler::EAX_Reg(const x86_insn *insn)
|
2003-08-04 20:03:09 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s", general_32bit_regname[rAX_REG]);
|
2003-08-04 20:03:09 +04:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// 64-bit general purpose registers
|
2009-01-19 22:01:03 +03:00
|
|
|
void disassembler::RAX_Reg(const x86_insn *insn)
|
2002-09-20 19:34:55 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s", general_64bit_regname[rAX_REG]);
|
2002-09-20 19:34:55 +04:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// segment registers
|
|
|
|
void disassembler::CS(const x86_insn *insn) { dis_sprintf("%s", segment_name[CS_REG]); }
|
|
|
|
void disassembler::DS(const x86_insn *insn) { dis_sprintf("%s", segment_name[DS_REG]); }
|
|
|
|
void disassembler::ES(const x86_insn *insn) { dis_sprintf("%s", segment_name[ES_REG]); }
|
|
|
|
void disassembler::SS(const x86_insn *insn) { dis_sprintf("%s", segment_name[SS_REG]); }
|
|
|
|
void disassembler::FS(const x86_insn *insn) { dis_sprintf("%s", segment_name[FS_REG]); }
|
|
|
|
void disassembler::GS(const x86_insn *insn) { dis_sprintf("%s", segment_name[GS_REG]); }
|
|
|
|
|
|
|
|
void disassembler::Sw(const x86_insn *insn) { dis_sprintf("%s", segment_name[insn->nnn]); }
|
|
|
|
|
|
|
|
// test registers
|
|
|
|
void disassembler::Td(const x86_insn *insn)
|
2002-09-20 19:34:55 +04:00
|
|
|
{
|
2004-12-08 21:54:15 +03:00
|
|
|
if (intel_mode)
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf ("tr%d", insn->nnn);
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%%tr%d", insn->nnn);
|
2002-09-20 19:34:55 +04:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// control register
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Cd(const x86_insn *insn)
|
|
|
|
{
|
2004-12-08 21:54:15 +03:00
|
|
|
if (intel_mode)
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf ("cr%d", insn->nnn);
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%%cr%d", insn->nnn);
|
2002-09-28 10:29:55 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
void disassembler::Cq(const x86_insn *insn) { Cd(insn); }
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// debug register
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Dd(const x86_insn *insn)
|
2005-12-23 17:15:13 +03:00
|
|
|
{
|
2004-12-08 21:54:15 +03:00
|
|
|
if (intel_mode)
|
2009-05-07 14:19:50 +04:00
|
|
|
dis_sprintf ("dr%d", insn->nnn);
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2009-05-07 14:19:50 +04:00
|
|
|
dis_sprintf("%%dr%d", insn->nnn);
|
2004-12-08 21:54:15 +03:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
void disassembler::Dq(const x86_insn *insn) { Dd(insn); }
|
2004-12-08 21:54:15 +03:00
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// 8-bit general purpose register
|
2009-01-19 22:01:03 +03:00
|
|
|
void disassembler::Reg8(const x86_insn *insn)
|
2008-02-06 01:33:35 +03:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
unsigned reg = (insn->b1 & 7) | insn->rex_b;
|
2008-02-06 01:33:35 +03:00
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
if (reg < 4 || insn->extend8b)
|
|
|
|
dis_sprintf("%s", general_8bit_regname_rex[reg]);
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s", general_8bit_regname[reg]);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// 16-bit general purpose register
|
|
|
|
void disassembler::RX(const x86_insn *insn)
|
2008-02-06 01:33:35 +03:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s", general_16bit_regname[(insn->b1 & 7) | insn->rex_b]);
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// 32-bit general purpose register
|
|
|
|
void disassembler::ERX(const x86_insn *insn)
|
2008-02-06 01:33:35 +03:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s", general_32bit_regname[(insn->b1 & 7) | insn->rex_b]);
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// 64-bit general purpose register
|
|
|
|
void disassembler::RRX(const x86_insn *insn)
|
2008-02-06 01:33:35 +03:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s", general_64bit_regname[(insn->b1 & 7) | insn->rex_b]);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// general purpose register or memory operand
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Eb(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (insn->mod == 3) {
|
|
|
|
if (insn->rm < 4 || insn->extend8b)
|
|
|
|
dis_sprintf("%s", general_8bit_regname_rex[insn->rm]);
|
|
|
|
else
|
|
|
|
dis_sprintf("%s", general_8bit_regname[insn->rm]);
|
2004-11-21 02:26:32 +03:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
(this->*resolve_modrm)(insn, B_SIZE);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Ew(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (insn->mod == 3)
|
|
|
|
dis_sprintf("%s", general_16bit_regname[insn->rm]);
|
2002-09-28 10:29:55 +04:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
(this->*resolve_modrm)(insn, W_SIZE);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Ed(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (insn->mod == 3)
|
|
|
|
dis_sprintf("%s", general_32bit_regname[insn->rm]);
|
2001-04-10 05:04:59 +04:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
(this->*resolve_modrm)(insn, D_SIZE);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Eq(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (insn->mod == 3)
|
|
|
|
dis_sprintf("%s", general_64bit_regname[insn->rm]);
|
2003-12-24 23:32:59 +03:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
(this->*resolve_modrm)(insn, Q_SIZE);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2010-03-07 11:08:40 +03:00
|
|
|
void disassembler::Ey(const x86_insn *insn)
|
|
|
|
{
|
|
|
|
if (insn->os_64) Eq(insn);
|
|
|
|
else Ed(insn);
|
|
|
|
}
|
|
|
|
|
2010-04-02 23:01:17 +04:00
|
|
|
void disassembler::Ebd(const x86_insn *insn)
|
2007-04-19 20:12:21 +04:00
|
|
|
{
|
|
|
|
if (insn->mod == 3)
|
2010-04-02 23:01:17 +04:00
|
|
|
dis_sprintf("%s", general_32bit_regname[insn->rm]);
|
2007-04-19 20:12:21 +04:00
|
|
|
else
|
|
|
|
(this->*resolve_modrm)(insn, B_SIZE);
|
|
|
|
}
|
|
|
|
|
2010-04-02 23:01:17 +04:00
|
|
|
void disassembler::Ewd(const x86_insn *insn)
|
2007-04-19 20:12:21 +04:00
|
|
|
{
|
|
|
|
if (insn->mod == 3)
|
2010-04-02 23:01:17 +04:00
|
|
|
dis_sprintf("%s", general_32bit_regname[insn->rm]);
|
2007-04-19 20:12:21 +04:00
|
|
|
else
|
|
|
|
(this->*resolve_modrm)(insn, W_SIZE);
|
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// general purpose register
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Gb(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (insn->nnn < 4 || insn->extend8b)
|
|
|
|
dis_sprintf("%s", general_8bit_regname_rex[insn->nnn]);
|
2001-04-10 05:04:59 +04:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s", general_8bit_regname[insn->nnn]);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Gw(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s", general_16bit_regname[insn->nnn]);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Gd(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s", general_32bit_regname[insn->nnn]);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Gq(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s", general_64bit_regname[insn->nnn]);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2010-03-26 13:39:40 +03:00
|
|
|
void disassembler::Gy(const x86_insn *insn)
|
|
|
|
{
|
|
|
|
if (insn->os_64) Gq(insn);
|
|
|
|
else Gd(insn);
|
|
|
|
}
|
|
|
|
|
2011-08-27 17:47:16 +04:00
|
|
|
// vex encoded general purpose register
|
|
|
|
void disassembler::By(const x86_insn *insn)
|
|
|
|
{
|
|
|
|
if (insn->os_64)
|
|
|
|
dis_sprintf("%s", general_64bit_regname[insn->vex_vvv]);
|
|
|
|
else
|
|
|
|
dis_sprintf("%s", general_32bit_regname[insn->vex_vvv]);
|
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// immediate
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::I1(const x86_insn *insn)
|
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (! intel_mode) dis_putc('$');
|
|
|
|
dis_putc ('1');
|
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Ib(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (! intel_mode) dis_putc('$');
|
|
|
|
dis_sprintf("0x%02x", (unsigned) fetch_byte());
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Iw(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (! intel_mode) dis_putc('$');
|
|
|
|
dis_sprintf("0x%04x", (unsigned) fetch_word());
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::IbIb(const x86_insn *insn)
|
2007-09-19 23:38:10 +04:00
|
|
|
{
|
|
|
|
Bit8u ib1 = fetch_byte();
|
|
|
|
Bit8u ib2 = fetch_byte();
|
|
|
|
|
|
|
|
if (intel_mode) {
|
|
|
|
dis_sprintf("0x%02x, 0x%02x", ib1, ib2);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dis_sprintf("$0x%02x, $0x%02x", ib2, ib1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::IwIb(const x86_insn *insn)
|
2006-03-23 20:43:39 +03:00
|
|
|
{
|
|
|
|
Bit16u iw = fetch_word();
|
|
|
|
Bit8u ib = fetch_byte();
|
|
|
|
|
|
|
|
if (intel_mode) {
|
|
|
|
dis_sprintf("0x%04x, 0x%02x", iw, ib);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dis_sprintf("$0x%02x, $0x%04x", ib, iw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Id(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (! intel_mode) dis_putc('$');
|
|
|
|
dis_sprintf("0x%08x", (unsigned) fetch_dword());
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::Iq(const x86_insn *insn)
|
2005-12-23 17:15:13 +03:00
|
|
|
{
|
|
|
|
Bit64u value = fetch_qword();
|
|
|
|
|
|
|
|
if (! intel_mode) dis_putc('$');
|
2007-01-13 13:43:31 +03:00
|
|
|
dis_sprintf("0x%08x%08x", GET32H(value), GET32L(value));
|
2005-12-23 17:15:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// sign extended immediate
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::sIbw(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (! intel_mode) dis_putc('$');
|
|
|
|
Bit16u imm16 = (Bit8s) fetch_byte();
|
|
|
|
dis_sprintf("0x%04x", (unsigned) imm16);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// sign extended immediate
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::sIbd(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (! intel_mode) dis_putc('$');
|
|
|
|
Bit32u imm32 = (Bit8s) fetch_byte();
|
|
|
|
dis_sprintf ("0x%08x", (unsigned) imm32);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// sign extended immediate
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::sIbq(const x86_insn *insn)
|
2005-12-23 17:15:13 +03:00
|
|
|
{
|
2004-12-15 20:15:43 +03:00
|
|
|
if (! intel_mode) dis_putc('$');
|
2005-12-23 17:15:13 +03:00
|
|
|
Bit64u imm64 = (Bit8s) fetch_byte();
|
2007-01-13 13:43:31 +03:00
|
|
|
dis_sprintf ("0x%08x%08x", GET32H(imm64), GET32L(imm64));
|
2004-12-08 21:54:15 +03:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// sign extended immediate
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::sIdq(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (! intel_mode) dis_putc('$');
|
|
|
|
Bit64u imm64 = (Bit32s) fetch_dword();
|
2007-01-13 13:43:31 +03:00
|
|
|
dis_sprintf ("0x%08x%08x", GET32H(imm64), GET32L(imm64));
|
2005-12-23 17:15:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// floating point
|
|
|
|
void disassembler::ST0(const x86_insn *insn)
|
2008-02-06 01:33:35 +03:00
|
|
|
{
|
2004-12-08 21:54:15 +03:00
|
|
|
if (intel_mode)
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf ("st(0)");
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%%st(0)");
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-06 01:33:35 +03:00
|
|
|
void disassembler::STi(const x86_insn *insn)
|
|
|
|
{
|
2004-12-08 21:54:15 +03:00
|
|
|
if (intel_mode)
|
2010-11-23 18:42:26 +03:00
|
|
|
dis_sprintf ("st(%d)", insn->rm & 7);
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2010-11-23 18:42:26 +03:00
|
|
|
dis_sprintf("%%st(%d)", insn->rm & 7);
|
2005-12-23 17:15:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// 16-bit general purpose register
|
|
|
|
void disassembler::Rw(const x86_insn *insn)
|
|
|
|
{
|
|
|
|
dis_sprintf("%s", general_16bit_regname[insn->rm]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 32-bit general purpose register
|
|
|
|
void disassembler::Rd(const x86_insn *insn)
|
|
|
|
{
|
|
|
|
dis_sprintf("%s", general_32bit_regname[insn->rm]);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// 64-bit general purpose register
|
|
|
|
void disassembler::Rq(const x86_insn *insn)
|
|
|
|
{
|
|
|
|
dis_sprintf("%s", general_64bit_regname[insn->rm]);
|
|
|
|
}
|
|
|
|
|
2010-07-22 19:12:08 +04:00
|
|
|
void disassembler::Ry(const x86_insn *insn)
|
|
|
|
{
|
|
|
|
if (insn->os_64) Rq(insn);
|
|
|
|
else Rd(insn);
|
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// mmx register
|
|
|
|
void disassembler::Pq(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2004-12-08 21:54:15 +03:00
|
|
|
if (intel_mode)
|
2010-11-23 18:42:26 +03:00
|
|
|
dis_sprintf ("mm%d", insn->nnn & 0x7);
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2010-11-23 18:42:26 +03:00
|
|
|
dis_sprintf("%%mm%d", insn->nnn & 0x7);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-02-17 16:33:05 +03:00
|
|
|
void disassembler::Nq(const x86_insn *insn)
|
|
|
|
{
|
|
|
|
if (intel_mode)
|
2010-11-23 18:42:26 +03:00
|
|
|
dis_sprintf ("mm%d", insn->rm & 0x7);
|
2006-02-17 16:33:05 +03:00
|
|
|
else
|
2010-11-23 18:42:26 +03:00
|
|
|
dis_sprintf("%%mm%d", insn->rm & 0x7);
|
2006-02-17 16:33:05 +03:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
void disassembler::Qd(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (insn->mod == 3)
|
|
|
|
{
|
|
|
|
if (intel_mode)
|
2010-11-23 18:42:26 +03:00
|
|
|
dis_sprintf ("mm%d", insn->rm & 0x7);
|
2005-12-23 17:15:13 +03:00
|
|
|
else
|
2010-11-23 18:42:26 +03:00
|
|
|
dis_sprintf("%%mm%d", insn->rm & 0x7);
|
2005-12-23 17:15:13 +03:00
|
|
|
}
|
2003-12-24 23:32:59 +03:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
(this->*resolve_modrm)(insn, D_SIZE);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
void disassembler::Qq(const x86_insn *insn)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
if (insn->mod == 3)
|
2003-12-24 23:32:59 +03:00
|
|
|
{
|
2004-12-08 21:54:15 +03:00
|
|
|
if (intel_mode)
|
2010-11-23 18:42:26 +03:00
|
|
|
dis_sprintf ("mm%d", insn->rm & 0x7);
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2010-11-23 18:42:26 +03:00
|
|
|
dis_sprintf("%%mm%d", insn->rm & 0x7);
|
2003-12-24 23:32:59 +03:00
|
|
|
}
|
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
(this->*resolve_modrm)(insn, Q_SIZE);
|
|
|
|
}
|
|
|
|
|
2011-03-19 23:09:34 +03:00
|
|
|
// xmm/ymm register
|
2006-02-17 16:33:05 +03:00
|
|
|
void disassembler::Udq(const x86_insn *insn)
|
|
|
|
{
|
2011-08-25 00:55:23 +04:00
|
|
|
dis_sprintf("%s%d", vector_reg_name[insn->vex_l], insn->rm);
|
2006-02-17 16:33:05 +03:00
|
|
|
}
|
|
|
|
|
2010-03-19 17:43:13 +03:00
|
|
|
void disassembler::Ups(const x86_insn *insn) { Udq(insn); }
|
|
|
|
void disassembler::Upd(const x86_insn *insn) { Udq(insn); }
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
void disassembler::Vq(const x86_insn *insn)
|
|
|
|
{
|
2011-08-25 00:55:23 +04:00
|
|
|
dis_sprintf("%s%d", vector_reg_name[insn->vex_l], insn->nnn);
|
2005-12-23 17:15:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void disassembler::Vdq(const x86_insn *insn) { Vq(insn); }
|
|
|
|
void disassembler::Vss(const x86_insn *insn) { Vq(insn); }
|
|
|
|
void disassembler::Vsd(const x86_insn *insn) { Vq(insn); }
|
|
|
|
void disassembler::Vps(const x86_insn *insn) { Vq(insn); }
|
|
|
|
void disassembler::Vpd(const x86_insn *insn) { Vq(insn); }
|
|
|
|
|
2011-03-19 23:09:34 +03:00
|
|
|
void disassembler::VIb(const x86_insn *insn)
|
|
|
|
{
|
|
|
|
unsigned vreg = fetch_byte() >> 4;
|
|
|
|
if (! insn->is_64) vreg &= 7;
|
2011-08-25 00:55:23 +04:00
|
|
|
dis_sprintf("%s%d", vector_reg_name[insn->vex_l], vreg);
|
2011-03-19 23:09:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void disassembler::Hdq(const x86_insn *insn)
|
|
|
|
{
|
2011-08-25 00:55:23 +04:00
|
|
|
dis_sprintf("%s%d", vector_reg_name[insn->vex_l], insn->vex_vvv);
|
2011-03-19 23:09:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void disassembler::Hps(const x86_insn *insn) { Hdq(insn); }
|
|
|
|
void disassembler::Hpd(const x86_insn *insn) { Hdq(insn); }
|
|
|
|
|
2011-08-25 00:55:23 +04:00
|
|
|
void disassembler::Wb(const x86_insn *insn)
|
|
|
|
{
|
|
|
|
if (insn->mod == 3) Udq(insn);
|
|
|
|
else
|
|
|
|
(this->*resolve_modrm)(insn, B_SIZE);
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
void disassembler::Ww(const x86_insn *insn)
|
2005-12-23 17:15:13 +03:00
|
|
|
{
|
2010-02-09 23:28:12 +03:00
|
|
|
if (insn->mod == 3) Udq(insn);
|
2005-12-23 17:15:13 +03:00
|
|
|
else
|
2007-04-19 20:12:21 +04:00
|
|
|
(this->*resolve_modrm)(insn, W_SIZE);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2002-11-19 08:47:45 +03:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
void disassembler::Wd(const x86_insn *insn)
|
2005-12-23 17:15:13 +03:00
|
|
|
{
|
2010-02-09 22:44:25 +03:00
|
|
|
if (insn->mod == 3) Udq(insn);
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2007-04-19 20:12:21 +04:00
|
|
|
(this->*resolve_modrm)(insn, D_SIZE);
|
2004-12-08 21:54:15 +03:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
void disassembler::Wq(const x86_insn *insn)
|
|
|
|
{
|
2010-02-09 22:44:25 +03:00
|
|
|
if (insn->mod == 3) Udq(insn);
|
2007-04-19 20:12:21 +04:00
|
|
|
else
|
|
|
|
(this->*resolve_modrm)(insn, Q_SIZE);
|
|
|
|
}
|
2006-02-17 16:33:05 +03:00
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
void disassembler::Wdq(const x86_insn *insn)
|
|
|
|
{
|
2010-02-09 22:44:25 +03:00
|
|
|
if (insn->mod == 3) Udq(insn);
|
2006-02-17 16:33:05 +03:00
|
|
|
else
|
2011-08-25 00:55:23 +04:00
|
|
|
(this->*resolve_modrm)(insn, XMM_SIZE + insn->vex_l);
|
2006-02-17 16:33:05 +03:00
|
|
|
}
|
|
|
|
|
2007-04-19 20:12:21 +04:00
|
|
|
void disassembler::Wsd(const x86_insn *insn) { Wq(insn); }
|
|
|
|
void disassembler::Wss(const x86_insn *insn) { Wd(insn); }
|
2005-12-23 17:15:13 +03:00
|
|
|
void disassembler::Wpd(const x86_insn *insn) { Wdq(insn); }
|
2006-02-17 16:33:05 +03:00
|
|
|
void disassembler::Wps(const x86_insn *insn) { Wdq(insn); }
|
2005-12-23 17:15:13 +03:00
|
|
|
|
|
|
|
// direct memory access
|
|
|
|
void disassembler::OP_O(const x86_insn *insn, unsigned size)
|
|
|
|
{
|
|
|
|
const char *seg;
|
|
|
|
|
2006-01-31 20:42:31 +03:00
|
|
|
if (insn->is_seg_override())
|
2005-12-23 17:15:13 +03:00
|
|
|
seg = segment_name[insn->seg_override];
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
seg = segment_name[DS_REG];
|
|
|
|
|
|
|
|
print_datasize(size);
|
|
|
|
|
2006-08-13 13:40:07 +04:00
|
|
|
if (insn->as_64) {
|
|
|
|
Bit64u imm64 = fetch_qword();
|
2007-01-13 13:43:31 +03:00
|
|
|
dis_sprintf("%s:0x%08x%08x", seg, GET32H(imm64), GET32L(imm64));
|
2006-08-13 13:40:07 +04:00
|
|
|
}
|
|
|
|
else if (insn->as_32) {
|
2005-12-23 17:15:13 +03:00
|
|
|
Bit32u imm32 = fetch_dword();
|
|
|
|
dis_sprintf("%s:0x%x", seg, (unsigned) imm32);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Bit16u imm16 = fetch_word();
|
|
|
|
dis_sprintf("%s:0x%x", seg, (unsigned) imm16);
|
|
|
|
}
|
2004-12-08 21:54:15 +03:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
void disassembler::Ob(const x86_insn *insn) { OP_O(insn, B_SIZE); }
|
|
|
|
void disassembler::Ow(const x86_insn *insn) { OP_O(insn, W_SIZE); }
|
|
|
|
void disassembler::Od(const x86_insn *insn) { OP_O(insn, D_SIZE); }
|
|
|
|
void disassembler::Oq(const x86_insn *insn) { OP_O(insn, Q_SIZE); }
|
|
|
|
|
|
|
|
// memory operand
|
|
|
|
void disassembler::OP_M(const x86_insn *insn, unsigned size)
|
|
|
|
{
|
|
|
|
if(insn->mod == 3)
|
|
|
|
dis_sprintf("(bad)");
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
(this->*resolve_modrm)(insn, size);
|
2004-12-08 21:54:15 +03:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
void disassembler::Ma(const x86_insn *insn) { OP_M(insn, X_SIZE); }
|
|
|
|
void disassembler::Mp(const x86_insn *insn) { OP_M(insn, X_SIZE); }
|
|
|
|
void disassembler::Ms(const x86_insn *insn) { OP_M(insn, X_SIZE); }
|
|
|
|
void disassembler::Mx(const x86_insn *insn) { OP_M(insn, X_SIZE); }
|
|
|
|
|
|
|
|
void disassembler::Mb(const x86_insn *insn) { OP_M(insn, B_SIZE); }
|
|
|
|
void disassembler::Mw(const x86_insn *insn) { OP_M(insn, W_SIZE); }
|
|
|
|
void disassembler::Md(const x86_insn *insn) { OP_M(insn, D_SIZE); }
|
|
|
|
void disassembler::Mq(const x86_insn *insn) { OP_M(insn, Q_SIZE); }
|
|
|
|
void disassembler::Mt(const x86_insn *insn) { OP_M(insn, T_SIZE); }
|
|
|
|
|
2011-08-25 00:55:23 +04:00
|
|
|
void disassembler::Mdq(const x86_insn *insn) { OP_M(insn, XMM_SIZE + insn->vex_l); }
|
|
|
|
void disassembler::Mps(const x86_insn *insn) { OP_M(insn, XMM_SIZE + insn->vex_l); }
|
|
|
|
void disassembler::Mpd(const x86_insn *insn) { OP_M(insn, XMM_SIZE + insn->vex_l); }
|
2007-08-31 22:09:34 +04:00
|
|
|
void disassembler::Mss(const x86_insn *insn) { OP_M(insn, D_SIZE); }
|
|
|
|
void disassembler::Msd(const x86_insn *insn) { OP_M(insn, Q_SIZE); }
|
2005-12-23 17:15:13 +03:00
|
|
|
|
|
|
|
// string instructions
|
|
|
|
void disassembler::OP_X(const x86_insn *insn, unsigned size)
|
2004-12-08 21:54:15 +03:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
const char *rsi, *seg;
|
|
|
|
|
|
|
|
if (insn->as_64) {
|
|
|
|
rsi = general_64bit_regname[rSI_REG];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (insn->as_32)
|
|
|
|
rsi = general_32bit_regname[rSI_REG];
|
|
|
|
else
|
|
|
|
rsi = general_16bit_regname[rSI_REG];
|
|
|
|
}
|
2008-02-06 01:33:35 +03:00
|
|
|
|
2006-01-31 20:42:31 +03:00
|
|
|
if (insn->is_seg_override())
|
2005-12-23 17:15:13 +03:00
|
|
|
seg = segment_name[insn->seg_override];
|
|
|
|
else
|
|
|
|
seg = segment_name[DS_REG];
|
|
|
|
|
|
|
|
print_datasize(size);
|
|
|
|
|
2004-12-08 21:54:15 +03:00
|
|
|
if (intel_mode)
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s:[%s]", seg, rsi);
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s:(%s)", seg, rsi);
|
2004-12-08 21:54:15 +03:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
void disassembler::Xb(const x86_insn *insn) { OP_X(insn, B_SIZE); }
|
|
|
|
void disassembler::Xw(const x86_insn *insn) { OP_X(insn, W_SIZE); }
|
|
|
|
void disassembler::Xd(const x86_insn *insn) { OP_X(insn, D_SIZE); }
|
|
|
|
void disassembler::Xq(const x86_insn *insn) { OP_X(insn, Q_SIZE); }
|
|
|
|
|
|
|
|
void disassembler::OP_Y(const x86_insn *insn, unsigned size)
|
2004-12-08 21:54:15 +03:00
|
|
|
{
|
2005-12-23 17:15:13 +03:00
|
|
|
const char *rdi;
|
|
|
|
|
|
|
|
if (insn->as_64) {
|
|
|
|
rdi = general_64bit_regname[rDI_REG];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (insn->as_32)
|
|
|
|
rdi = general_32bit_regname[rDI_REG];
|
|
|
|
else
|
|
|
|
rdi = general_16bit_regname[rDI_REG];
|
|
|
|
}
|
2008-02-06 01:33:35 +03:00
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
print_datasize(size);
|
|
|
|
|
2004-12-08 21:54:15 +03:00
|
|
|
if (intel_mode)
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s:[%s]", segment_name[ES_REG], rdi);
|
2004-12-08 21:54:15 +03:00
|
|
|
else
|
2005-12-23 17:15:13 +03:00
|
|
|
dis_sprintf("%s:(%s)", segment_name[ES_REG], rdi);
|
|
|
|
}
|
|
|
|
|
|
|
|
void disassembler::Yb(const x86_insn *insn) { OP_Y(insn, B_SIZE); }
|
|
|
|
void disassembler::Yw(const x86_insn *insn) { OP_Y(insn, W_SIZE); }
|
|
|
|
void disassembler::Yd(const x86_insn *insn) { OP_Y(insn, D_SIZE); }
|
|
|
|
void disassembler::Yq(const x86_insn *insn) { OP_Y(insn, Q_SIZE); }
|
|
|
|
|
2009-08-21 17:45:38 +04:00
|
|
|
void disassembler::OP_sY(const x86_insn *insn, unsigned size)
|
|
|
|
{
|
|
|
|
const char *rdi, *seg;
|
|
|
|
|
|
|
|
if (insn->as_64) {
|
|
|
|
rdi = general_64bit_regname[rDI_REG];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (insn->as_32)
|
|
|
|
rdi = general_32bit_regname[rDI_REG];
|
|
|
|
else
|
|
|
|
rdi = general_16bit_regname[rDI_REG];
|
|
|
|
}
|
|
|
|
|
|
|
|
print_datasize(size);
|
|
|
|
|
|
|
|
if (insn->is_seg_override())
|
|
|
|
seg = segment_name[insn->seg_override];
|
|
|
|
else
|
|
|
|
seg = segment_name[DS_REG];
|
|
|
|
|
|
|
|
if (intel_mode)
|
|
|
|
dis_sprintf("%s:[%s]", seg, rdi);
|
|
|
|
else
|
|
|
|
dis_sprintf("%s:(%s)", seg, rdi);
|
|
|
|
}
|
|
|
|
|
|
|
|
void disassembler::sYq(const x86_insn *insn) { OP_sY(insn, Q_SIZE); }
|
2011-08-25 00:55:23 +04:00
|
|
|
void disassembler::sYdq(const x86_insn *insn) { OP_sY(insn, XMM_SIZE + insn->vex_l); }
|
2009-08-21 17:45:38 +04:00
|
|
|
|
2006-02-11 22:46:03 +03:00
|
|
|
#define BX_JUMP_TARGET_NOT_REQ ((bx_address)(-1))
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
// jump offset
|
|
|
|
void disassembler::Jb(const x86_insn *insn)
|
|
|
|
{
|
|
|
|
Bit8s imm8 = (Bit8s) fetch_byte();
|
|
|
|
|
|
|
|
if (insn->is_64) {
|
2007-12-30 21:02:22 +03:00
|
|
|
Bit64u imm64 = (Bit8s) imm8;
|
2009-12-28 16:44:32 +03:00
|
|
|
|
|
|
|
if (offset_mode_hex) {
|
|
|
|
dis_sprintf(".+0x%08x%08x", GET32H(imm64), GET32L(imm64));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dis_sprintf(".%+d", (int) imm8);
|
|
|
|
}
|
2006-02-11 22:46:03 +03:00
|
|
|
|
|
|
|
if (db_base != BX_JUMP_TARGET_NOT_REQ) {
|
2007-12-30 21:02:22 +03:00
|
|
|
Bit64u target = db_eip + imm64;
|
|
|
|
target += db_base;
|
2007-01-13 13:43:31 +03:00
|
|
|
dis_sprintf(" (0x%08x%08x)", GET32H(target), GET32L(target));
|
2006-02-11 22:46:03 +03:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (insn->os_32) {
|
2007-12-30 21:02:22 +03:00
|
|
|
Bit32u imm32 = (Bit8s) imm8;
|
2009-12-28 16:44:32 +03:00
|
|
|
|
|
|
|
if (offset_mode_hex) {
|
|
|
|
dis_sprintf(".+0x%08x", (unsigned) imm32);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dis_sprintf(".%+d", (int) imm8);
|
|
|
|
}
|
2006-02-11 22:46:03 +03:00
|
|
|
|
|
|
|
if (db_base != BX_JUMP_TARGET_NOT_REQ) {
|
2010-11-23 17:59:36 +03:00
|
|
|
Bit32u target = (Bit32u)(db_base + db_eip + (Bit32s) imm32);
|
2006-02-11 22:46:03 +03:00
|
|
|
dis_sprintf(" (0x%08x)", target);
|
|
|
|
}
|
2005-12-23 17:15:13 +03:00
|
|
|
}
|
|
|
|
else {
|
2007-12-30 21:02:22 +03:00
|
|
|
Bit16u imm16 = (Bit8s) imm8;
|
2009-12-28 16:44:32 +03:00
|
|
|
|
|
|
|
if (offset_mode_hex) {
|
|
|
|
dis_sprintf(".+0x%04x", (unsigned) imm16);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dis_sprintf(".%+d", (int) imm8);
|
|
|
|
}
|
2006-02-11 22:46:03 +03:00
|
|
|
|
|
|
|
if (db_base != BX_JUMP_TARGET_NOT_REQ) {
|
2007-12-30 21:02:22 +03:00
|
|
|
Bit16u target = (Bit16u)((db_eip + (Bit16s) imm16) & 0xffff);
|
2006-02-11 22:46:03 +03:00
|
|
|
dis_sprintf(" (0x%08x)", target + db_base);
|
|
|
|
}
|
2005-12-23 17:15:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void disassembler::Jw(const x86_insn *insn)
|
|
|
|
{
|
2006-02-11 22:46:03 +03:00
|
|
|
// Jw supported in 16-bit mode only
|
|
|
|
assert(! insn->is_64);
|
2005-12-23 17:15:13 +03:00
|
|
|
|
2009-12-28 16:44:32 +03:00
|
|
|
Bit16s imm16 = (Bit16s) fetch_word();
|
|
|
|
|
|
|
|
if (offset_mode_hex) {
|
|
|
|
dis_sprintf(".+0x%04x", (unsigned) (Bit16u) imm16);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dis_sprintf(".%+d", (int) imm16);
|
|
|
|
}
|
2005-12-23 17:15:13 +03:00
|
|
|
|
2006-02-11 22:46:03 +03:00
|
|
|
if (db_base != BX_JUMP_TARGET_NOT_REQ) {
|
2009-12-28 16:44:32 +03:00
|
|
|
Bit16u target = (db_eip + imm16) & 0xffff;
|
2006-02-11 22:46:03 +03:00
|
|
|
dis_sprintf(" (0x%08x)", target + db_base);
|
2005-12-23 17:15:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void disassembler::Jd(const x86_insn *insn)
|
|
|
|
{
|
|
|
|
Bit32s imm32 = (Bit32s) fetch_dword();
|
|
|
|
|
|
|
|
if (insn->is_64) {
|
2007-12-30 21:02:22 +03:00
|
|
|
Bit64u imm64 = (Bit32s) imm32;
|
2009-12-28 16:44:32 +03:00
|
|
|
|
|
|
|
if (offset_mode_hex) {
|
|
|
|
dis_sprintf(".+0x%08x%08x", GET32H(imm64), GET32L(imm64));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dis_sprintf(".%+d", (int) imm32);
|
|
|
|
}
|
2006-02-11 22:46:03 +03:00
|
|
|
|
|
|
|
if (db_base != BX_JUMP_TARGET_NOT_REQ) {
|
2010-11-23 17:59:36 +03:00
|
|
|
Bit64u target = db_base + db_eip + (Bit64s) imm64;
|
2007-01-13 13:43:31 +03:00
|
|
|
dis_sprintf(" (0x%08x%08x)", GET32H(target), GET32L(target));
|
2006-02-11 22:46:03 +03:00
|
|
|
}
|
|
|
|
|
2005-12-23 17:15:13 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-28 16:44:32 +03:00
|
|
|
if (offset_mode_hex) {
|
|
|
|
dis_sprintf(".+0x%08x", (unsigned) imm32);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dis_sprintf(".%+d", (int) imm32);
|
|
|
|
}
|
|
|
|
|
2006-02-11 22:46:03 +03:00
|
|
|
if (db_base != BX_JUMP_TARGET_NOT_REQ) {
|
2010-11-23 17:59:36 +03:00
|
|
|
Bit32u target = (Bit32u)(db_base + db_eip + (Bit32s) imm32);
|
2006-02-11 22:46:03 +03:00
|
|
|
dis_sprintf(" (0x%08x)", target);
|
|
|
|
}
|
2004-12-08 21:54:15 +03:00
|
|
|
}
|