disasm: Id form in 32-bit should be sign-extended to 64-bit

This commit is contained in:
Stanislav Shwartsman 2013-10-06 18:10:58 +00:00
parent a392612b03
commit f1f35a236c
3 changed files with 38 additions and 34 deletions

View File

@ -294,6 +294,9 @@ char* disasm(char *disbufptr, const bxInstruction_c *i, bx_address cs_base, bx_a
disbufptr = dis_sprintf(disbufptr, "0x%08x", i->Id());
break;
#if BX_SUPPORT_X86_64
case BX_IMMD_SE:
disbufptr = dis_sprintf(disbufptr, "0x" FMT_ADDRX64, (Bit64u) (Bit32s) i->Id());
break;
case BX_IMMQ:
disbufptr = dis_sprintf(disbufptr, "0x" FMT_ADDRX64, i->Iq());
break;

View File

@ -103,17 +103,18 @@ enum {
BX_IMMB = 0x10,
BX_IMMW = 0x11,
BX_IMMD = 0x12,
BX_IMMQ = 0x13,
BX_IMMB2 = 0x14,
BX_IMM_BrOff16 = 0x15,
BX_IMM_BrOff32 = 0x16,
BX_RSIREF = 0x17,
BX_RDIREF = 0x18,
BX_USECL = 0x19,
BX_USEDX = 0x1A,
BX_DIRECT_PTR = 0x1B,
BX_DIRECT_MEMREF32 = 0x1C,
BX_DIRECT_MEMREF64 = 0x1D,
BX_IMMD_SE = 0x13,
BX_IMMQ = 0x14,
BX_IMMB2 = 0x15,
BX_IMM_BrOff16 = 0x16,
BX_IMM_BrOff32 = 0x17,
BX_RSIREF = 0x18,
BX_RDIREF = 0x19,
BX_USECL = 0x1A,
BX_USEDX = 0x1B,
BX_DIRECT_PTR = 0x1C,
BX_DIRECT_MEMREF32 = 0x1D,
BX_DIRECT_MEMREF64 = 0x1E,
};
#define BX_FORM_SRC(type, src) (((type) << 3) | (src))
@ -143,8 +144,8 @@ const Bit8u OP_DXReg = BX_FORM_SRC(BX_USEDX, BX_SRC_NONE);
const Bit8u OP_Ib = BX_FORM_SRC(BX_IMMB, BX_SRC_NONE);
const Bit8u OP_Iw = BX_FORM_SRC(BX_IMMW, BX_SRC_NONE);
const Bit8u OP_Id = BX_FORM_SRC(BX_IMMD, BX_SRC_NONE);
const Bit8u OP_sId = BX_FORM_SRC(BX_IMMD_SE, BX_SRC_NONE);
const Bit8u OP_Iq = BX_FORM_SRC(BX_IMMQ, BX_SRC_NONE);
const Bit8u OP_Ib2 = BX_FORM_SRC(BX_IMMB2, BX_SRC_NONE);
const Bit8u OP_Jw = BX_FORM_SRC(BX_IMM_BrOff16, BX_SRC_NONE);

View File

@ -1329,25 +1329,25 @@ bx_define_opcode(BX_IA_XOR_EqGq, &BX_CPU_C::XOR_EqGqM, &BX_CPU_C::XOR_GqEqR, 0,
bx_define_opcode(BX_IA_TEST_EqGq, &BX_CPU_C::TEST_EqGqM, &BX_CPU_C::TEST_EqGqR, 0, OP_Eq, OP_Gq, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_CMP_EqGq, &BX_CPU_C::CMP_EqGqM, &BX_CPU_C::CMP_GqEqR, 0, OP_Eq, OP_Gq, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_ADD_RAXId, NULL, &BX_CPU_C::ADD_EqIdR, 0, OP_RAXReg, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_OR_RAXId, NULL, &BX_CPU_C::OR_EqIdR, 0, OP_RAXReg, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_ADC_RAXId, NULL, &BX_CPU_C::ADC_EqIdR, 0, OP_RAXReg, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_SBB_RAXId, NULL, &BX_CPU_C::SBB_EqIdR, 0, OP_RAXReg, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_AND_RAXId, NULL, &BX_CPU_C::AND_EqIdR, 0, OP_RAXReg, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_SUB_RAXId, NULL, &BX_CPU_C::SUB_EqIdR, 0, OP_RAXReg, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_XOR_RAXId, NULL, &BX_CPU_C::XOR_EqIdR, 0, OP_RAXReg, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_TEST_RAXId, NULL, &BX_CPU_C::TEST_EqIdR, 0, OP_RAXReg, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_CMP_RAXId, NULL, &BX_CPU_C::CMP_EqIdR, 0, OP_RAXReg, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_ADD_RAXId, NULL, &BX_CPU_C::ADD_EqIdR, 0, OP_RAXReg, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_OR_RAXId, NULL, &BX_CPU_C::OR_EqIdR, 0, OP_RAXReg, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_ADC_RAXId, NULL, &BX_CPU_C::ADC_EqIdR, 0, OP_RAXReg, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_SBB_RAXId, NULL, &BX_CPU_C::SBB_EqIdR, 0, OP_RAXReg, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_AND_RAXId, NULL, &BX_CPU_C::AND_EqIdR, 0, OP_RAXReg, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_SUB_RAXId, NULL, &BX_CPU_C::SUB_EqIdR, 0, OP_RAXReg, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_XOR_RAXId, NULL, &BX_CPU_C::XOR_EqIdR, 0, OP_RAXReg, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_TEST_RAXId, NULL, &BX_CPU_C::TEST_EqIdR, 0, OP_RAXReg, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_CMP_RAXId, NULL, &BX_CPU_C::CMP_EqIdR, 0, OP_RAXReg, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_ADD_EqId, &BX_CPU_C::ADD_EqIdM, &BX_CPU_C::ADD_EqIdR, 0, OP_Eq, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_OR_EqId, &BX_CPU_C::OR_EqIdM, &BX_CPU_C::OR_EqIdR, 0, OP_Eq, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_ADC_EqId, &BX_CPU_C::ADC_EqIdM, &BX_CPU_C::ADC_EqIdR, 0, OP_Eq, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_SBB_EqId, &BX_CPU_C::SBB_EqIdM, &BX_CPU_C::SBB_EqIdR, 0, OP_Eq, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_AND_EqId, &BX_CPU_C::AND_EqIdM, &BX_CPU_C::AND_EqIdR, 0, OP_Eq, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_SUB_EqId, &BX_CPU_C::SUB_EqIdM, &BX_CPU_C::SUB_EqIdR, 0, OP_Eq, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_XOR_EqId, &BX_CPU_C::XOR_EqIdM, &BX_CPU_C::XOR_EqIdR, 0, OP_Eq, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_TEST_EqId, &BX_CPU_C::TEST_EqIdM, &BX_CPU_C::TEST_EqIdR, 0, OP_Eq, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_CMP_EqId, &BX_CPU_C::CMP_EqIdM, &BX_CPU_C::CMP_EqIdR, 0, OP_Eq, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_ADD_EqId, &BX_CPU_C::ADD_EqIdM, &BX_CPU_C::ADD_EqIdR, 0, OP_Eq, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_OR_EqId, &BX_CPU_C::OR_EqIdM, &BX_CPU_C::OR_EqIdR, 0, OP_Eq, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_ADC_EqId, &BX_CPU_C::ADC_EqIdM, &BX_CPU_C::ADC_EqIdR, 0, OP_Eq, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_SBB_EqId, &BX_CPU_C::SBB_EqIdM, &BX_CPU_C::SBB_EqIdR, 0, OP_Eq, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_AND_EqId, &BX_CPU_C::AND_EqIdM, &BX_CPU_C::AND_EqIdR, 0, OP_Eq, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_SUB_EqId, &BX_CPU_C::SUB_EqIdM, &BX_CPU_C::SUB_EqIdR, 0, OP_Eq, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_XOR_EqId, &BX_CPU_C::XOR_EqIdM, &BX_CPU_C::XOR_EqIdR, 0, OP_Eq, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_TEST_EqId, &BX_CPU_C::TEST_EqIdM, &BX_CPU_C::TEST_EqIdR, 0, OP_Eq, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_CMP_EqId, &BX_CPU_C::CMP_EqIdM, &BX_CPU_C::CMP_EqIdR, 0, OP_Eq, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_XCHG_EqGq, &BX_CPU_C::XCHG_EqGqM, &BX_CPU_C::XCHG_EqGqR, 0, OP_Eq, OP_Gq, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_LEA_GqM, &BX_CPU_C::LEA_GqM, &BX_CPU_C::BxError, 0, OP_Gq, OP_Mq, OP_NONE, OP_NONE, 0)
@ -1355,7 +1355,7 @@ bx_define_opcode(BX_IA_MOV_Op64_GdEd, &BX_CPU_C::MOV64_GdEdM, &BX_CPU_C::MOV_GdE
bx_define_opcode(BX_IA_MOV_Op64_EdGd, &BX_CPU_C::MOV64_EdGdM, &BX_CPU_C::MOV_GdEdR, 0, OP_Ed, OP_Gd, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_MOV_GqEq, &BX_CPU_C::MOV_GqEqM, &BX_CPU_C::MOV_GqEqR, 0, OP_Gq, OP_Eq, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_MOV_EqGq, &BX_CPU_C::MOV_EqGqM, &BX_CPU_C::MOV_GqEqR, 0, OP_Eq, OP_Gq, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_MOV_EqId, &BX_CPU_C::MOV_EqIdM, &BX_CPU_C::MOV_EqIdR, 0, OP_Eq, OP_Id, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_MOV_EqId, &BX_CPU_C::MOV_EqIdM, &BX_CPU_C::MOV_EqIdR, 0, OP_Eq, OP_sId, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_MOV_RAXOq, NULL, &BX_CPU_C::MOV_RAXOq, 0, OP_RAXReg, OP_Oq, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_MOV_OqRAX, NULL, &BX_CPU_C::MOV_OqRAX, 0, OP_Oq, OP_RAXReg, OP_NONE, OP_NONE, 0)
@ -1402,7 +1402,7 @@ bx_define_opcode(BX_IA_SHRD_EqGq, &BX_CPU_C::SHRD_EqGqM, &BX_CPU_C::SHRD_EqGqR,
bx_define_opcode(BX_IA_SHRD_EqGqIb, &BX_CPU_C::SHRD_EqGqM, &BX_CPU_C::SHRD_EqGqR, 0, OP_Eq, OP_Gq, OP_Ib, OP_NONE, 0)
bx_define_opcode(BX_IA_IMUL_GqEq, &BX_CPU_C::LOAD_Eq, &BX_CPU_C::IMUL_GqEqR, 0, OP_Gq, OP_Eq, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_IMUL_GqEqId, &BX_CPU_C::LOAD_Eq, &BX_CPU_C::IMUL_GqEqIdR, 0, OP_Gq, OP_Eq, OP_Id, OP_NONE, 0)
bx_define_opcode(BX_IA_IMUL_GqEqId, &BX_CPU_C::LOAD_Eq, &BX_CPU_C::IMUL_GqEqIdR, 0, OP_Gq, OP_Eq, OP_sId, OP_NONE, 0)
bx_define_opcode(BX_IA_MOVZX_GqEb, &BX_CPU_C::MOVZX_GqEbM, &BX_CPU_C::MOVZX_GqEbR, 0, OP_Gq, OP_Eb, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_MOVZX_GqEw, &BX_CPU_C::MOVZX_GqEwM, &BX_CPU_C::MOVZX_GqEwR, 0, OP_Gq, OP_Ew, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_MOVSX_GqEb, &BX_CPU_C::MOVSX_GqEbM, &BX_CPU_C::MOVSX_GqEbR, 0, OP_Gq, OP_Eb, OP_NONE, OP_NONE, 0)
@ -1485,7 +1485,7 @@ bx_define_opcode(BX_IA_CMOVNLE_GqEq, &BX_CPU_C::LOAD_Eq, &BX_CPU_C::CMOVNLE_GqEq
bx_define_opcode(BX_IA_PUSH_Eq, &BX_CPU_C::PUSH_EqM, &BX_CPU_C::PUSH_EqR, 0, OP_Eq, OP_NONE, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_POP_Eq, &BX_CPU_C::POP_EqM, &BX_CPU_C::POP_EqR, 0, OP_Eq, OP_NONE, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_PUSH_Op64_Id, NULL, &BX_CPU_C::PUSH64_Id, 0, OP_Id, OP_NONE, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_PUSH_Op64_Id, NULL, &BX_CPU_C::PUSH64_Id, 0, OP_sId, OP_NONE, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_PUSH_Op64_Sw, NULL, &BX_CPU_C::PUSH64_Sw, 0, OP_NONE, OP_Sw, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_POP_Op64_Sw, NULL, &BX_CPU_C::POP64_Sw, 0, OP_Sw, OP_NONE, OP_NONE, OP_NONE, 0)
@ -2358,7 +2358,7 @@ bx_define_opcode(BX_IA_BLSIC_BdEd, &BX_CPU_C::LOAD_Ed, &BX_CPU_C::BLSIC_BdEdR, B
bx_define_opcode(BX_IA_T1MSKC_BdEd, &BX_CPU_C::LOAD_Ed, &BX_CPU_C::T1MSKC_BdEdR, BX_ISA_TBM, OP_Bd, OP_Ed, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_TZMSK_BdEd, &BX_CPU_C::LOAD_Ed, &BX_CPU_C::TZMSK_BdEdR, BX_ISA_TBM, OP_Bd, OP_Ed, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_BEXTR_GqEqId, &BX_CPU_C::LOAD_Eq, &BX_CPU_C::BEXTR_GqEqIdR, BX_ISA_TBM, OP_Gq, OP_Eq, OP_Id, OP_NONE, 0)
bx_define_opcode(BX_IA_BEXTR_GqEqId, &BX_CPU_C::LOAD_Eq, &BX_CPU_C::BEXTR_GqEqIdR, BX_ISA_TBM, OP_Gq, OP_Eq, OP_sId, OP_NONE, 0)
bx_define_opcode(BX_IA_BLCFILL_BqEq, &BX_CPU_C::LOAD_Eq, &BX_CPU_C::BLCFILL_BqEqR, BX_ISA_TBM, OP_Bq, OP_Eq, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_BLCI_BqEq, &BX_CPU_C::LOAD_Eq, &BX_CPU_C::BLCI_BqEqR, BX_ISA_TBM, OP_Bq, OP_Eq, OP_NONE, OP_NONE, 0)
bx_define_opcode(BX_IA_BLCIC_BqEq, &BX_CPU_C::LOAD_Eq, &BX_CPU_C::BLCIC_BqEqR, BX_ISA_TBM, OP_Bq, OP_Eq, OP_NONE, OP_NONE, 0)