From 461f710b86925dc9ad9b25929b782bfb0a922637 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Tue, 1 Apr 2014 07:23:39 +0800 Subject: [PATCH] x86: temporarily revert a part of commit 2be9b8791a1bfd820abf526e41091da305481005 due to some broken output --- arch/X86/X86ATTInstPrinter.c | 10 ++++++++-- arch/X86/X86IntelInstPrinter.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/X86/X86ATTInstPrinter.c b/arch/X86/X86ATTInstPrinter.c index c1eb5bc0c0..75ace39771 100644 --- a/arch/X86/X86ATTInstPrinter.c +++ b/arch/X86/X86ATTInstPrinter.c @@ -370,7 +370,10 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O) else SStream_concat(O, "%s$%"PRIu64"%s", markup("")); } else { - SStream_concat(O, "%s$0x%"PRIx64"%s", markup("x86_imm_size] & imm, markup(">")); + if (imm < -HEX_THRESHOLD) + SStream_concat(O, "%s$-0x%"PRIx64"%s", markup("")); + else + SStream_concat(O, "%s$-%"PRIu64"%s", markup("")); } if (MI->csh->detail) { MI->flat_insn.x86.operands[MI->flat_insn.x86.op_count].type = X86_OP_IMM; @@ -390,7 +393,10 @@ static void _printOperand(MCInst *MI, unsigned OpNo, SStream *O) // Print X86 immediates as signed values. int64_t imm = MCOperand_getImm(Op); if (imm < 0) { - SStream_concat(O, "%s$0x%"PRIx64"%s", markup("x86_imm_size] & imm, markup(">")); + if (imm < -HEX_THRESHOLD) + SStream_concat(O, "%s$-0x%"PRIx64"%s", markup("")); + else + SStream_concat(O, "%s$-%"PRIu64"%s", markup("")); } else { if (imm > HEX_THRESHOLD) SStream_concat(O, "%s$0x%"PRIx64"%s", markup("")); diff --git a/arch/X86/X86IntelInstPrinter.c b/arch/X86/X86IntelInstPrinter.c index 88b54db4df..b4bf964dd8 100644 --- a/arch/X86/X86IntelInstPrinter.c +++ b/arch/X86/X86IntelInstPrinter.c @@ -413,7 +413,10 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O) else SStream_concat(O, "%"PRIu64, imm); } else { - SStream_concat(O, "0x%"PRIx64, arch_masks[MI->x86_imm_size] & imm); + if (imm < -HEX_THRESHOLD) + SStream_concat(O, "-0x%"PRIx64, -imm); + else + SStream_concat(O, "-%"PRIu64, -imm); } if (MI->csh->detail) { @@ -433,7 +436,11 @@ static void _printOperand(MCInst *MI, unsigned OpNo, SStream *O) } else if (MCOperand_isImm(Op)) { int64_t imm = MCOperand_getImm(Op); if (imm < 0) { - SStream_concat(O, "0x%"PRIx64, arch_masks[MI->x86_imm_size] & imm); + if (imm < -HEX_THRESHOLD) + SStream_concat(O, "-0x%"PRIx64, -imm); + else + SStream_concat(O, "-%"PRIu64, -imm); + } else { if (imm > HEX_THRESHOLD) SStream_concat(O, "0x%"PRIx64, imm);