diff --git a/arch/X86/X86ATTInstPrinter.c b/arch/X86/X86ATTInstPrinter.c index 1991457d..3fa0b44a 100644 --- a/arch/X86/X86ATTInstPrinter.c +++ b/arch/X86/X86ATTInstPrinter.c @@ -133,8 +133,12 @@ static void printMemOffset(MCInst *MI, unsigned Op, SStream *O) MI->pub_insn.x86.operands[MI->pub_insn.x86.op_count].mem.disp = imm; if (imm < 0) SStream_concat(O, "-0x%"PRIx64, -imm); - else - SStream_concat(O, "0x%"PRIx64, imm); + else { + if (imm > HEX_THRESHOLD) + SStream_concat(O, "0x%"PRIx64, imm); + else + SStream_concat(O, "%"PRIu64, imm); + } } SStream_concat(O, "%s", markup(">")); @@ -257,8 +261,12 @@ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O) int64_t imm = MCOperand_getImm(Op) + MI->pub_insn.size + MI->pub_insn.address; if (imm < 0) SStream_concat(O, "-0x%"PRIx64, -imm); - else - SStream_concat(O, "0x%"PRIx64, imm); + else { + if (imm > HEX_THRESHOLD) + SStream_concat(O, "0x%"PRIx64, imm); + else + SStream_concat(O, "%"PRIu64, imm); + } MI->pub_insn.x86.operands[MI->pub_insn.x86.op_count].type = X86_OP_IMM; MI->pub_insn.x86.operands[MI->pub_insn.x86.op_count].imm = imm; MI->pub_insn.x86.op_count++; @@ -276,7 +284,10 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O) } else if (MCOperand_isImm(Op)) { // Print X86 immediates as signed values. int64_t imm = MCOperand_getImm(Op); - SStream_concat(O, "%s$0x%"PRIx64"%s", markup("")); + if (imm > HEX_THRESHOLD) + SStream_concat(O, "%s$0x%"PRIx64"%s", markup("")); + else + SStream_concat(O, "%s$%"PRIu64"%s", markup("")); MI->pub_insn.x86.operands[MI->pub_insn.x86.op_count].type = X86_OP_IMM; MI->pub_insn.x86.operands[MI->pub_insn.x86.op_count].imm = imm; MI->pub_insn.x86.op_count++; @@ -294,8 +305,12 @@ static void _printOperand(MCInst *MI, unsigned OpNo, SStream *O) int64_t imm = MCOperand_getImm(Op); if (imm < 0) SStream_concat(O, "%s$-0x%"PRIx64"%s", markup("")); - else - SStream_concat(O, "%s$0x%"PRIx64"%s", markup("")); + else { + if (imm > HEX_THRESHOLD) + SStream_concat(O, "%s$0x%"PRIx64"%s", markup("")); + else + SStream_concat(O, "%s$%"PRIu64"%s", markup("")); + } } } @@ -326,8 +341,12 @@ static void printMemReference(MCInst *MI, unsigned Op, SStream *O) if (DispVal || (!MCOperand_getReg(IndexReg) && !MCOperand_getReg(BaseReg))) { if (DispVal < 0) SStream_concat(O, "-0x%"PRIx64, -DispVal); - else - SStream_concat(O, "0x%"PRIx64, DispVal); + else { + if (DispVal > HEX_THRESHOLD) + SStream_concat(O, "0x%"PRIx64, DispVal); + else + SStream_concat(O, "%"PRIu64, DispVal); + } } } diff --git a/arch/X86/X86IntelInstPrinter.c b/arch/X86/X86IntelInstPrinter.c index 744ec7eb..1e217849 100644 --- a/arch/X86/X86IntelInstPrinter.c +++ b/arch/X86/X86IntelInstPrinter.c @@ -130,8 +130,12 @@ static void printMemOffset(MCInst *MI, unsigned Op, SStream *O) MI->pub_insn.x86.operands[MI->pub_insn.x86.op_count].mem.disp = imm; if (imm < 0) SStream_concat(O, "-0x%"PRIx64, -imm); - else - SStream_concat(O, "0x%"PRIx64, imm); + else { + if (imm > HEX_THRESHOLD) + SStream_concat(O, "0x%"PRIx64, imm); + else + SStream_concat(O, "%"PRIu64, imm); + } } SStream_concat(O, "]"); @@ -315,8 +319,12 @@ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O) int64_t imm = MCOperand_getImm(Op) + MI->pub_insn.size + MI->pub_insn.address; if (imm < 0) SStream_concat(O, "-0x%"PRIx64, -imm); - else - SStream_concat(O, "0x%"PRIx64, imm); + else { + if (imm > HEX_THRESHOLD) + SStream_concat(O, "0x%"PRIx64, imm); + else + SStream_concat(O, "%"PRIu64, imm); + } MI->pub_insn.x86.operands[MI->pub_insn.x86.op_count].type = X86_OP_IMM; MI->pub_insn.x86.operands[MI->pub_insn.x86.op_count].imm = imm; MI->pub_insn.x86.op_count++; @@ -339,7 +347,10 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O) MI->pub_insn.x86.op_count++; } else if (MCOperand_isImm(Op)) { int64_t imm = MCOperand_getImm(Op); - SStream_concat(O, "0x%"PRIx64, imm); + if (imm > HEX_THRESHOLD) + SStream_concat(O, "0x%"PRIx64, imm); + else + SStream_concat(O, "%"PRIu64, imm); MI->pub_insn.x86.operands[MI->pub_insn.x86.op_count].type = X86_OP_IMM; MI->pub_insn.x86.operands[MI->pub_insn.x86.op_count].imm = imm; MI->pub_insn.x86.op_count++; @@ -356,8 +367,12 @@ static void _printOperand(MCInst *MI, unsigned OpNo, SStream *O) int64_t imm = MCOperand_getImm(Op); if (imm < 0) SStream_concat(O, "-0x%"PRIx64, -imm); - else - SStream_concat(O, "0x%"PRIx64, imm); + else { + if (imm > HEX_THRESHOLD) + SStream_concat(O, "0x%"PRIx64, imm); + else + SStream_concat(O, "%"PRIu64, imm); + } } } @@ -414,8 +429,12 @@ static void printMemReference(MCInst *MI, unsigned Op, SStream *O) // qqq } if (DispVal < 0) SStream_concat(O, "-0x%"PRIx64, -DispVal); - else - SStream_concat(O, "0x%"PRIx64, DispVal); + else { + if (DispVal > HEX_THRESHOLD) + SStream_concat(O, "0x%"PRIx64, DispVal); + else + SStream_concat(O, "%"PRIu64, DispVal); + } } }