From b6f0d440b26d73ffc2e0c6d48ad0cd76a5c96974 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Sat, 23 May 2015 23:57:00 +0800 Subject: [PATCH] arm64: print immediate as signed int64 for memory operands. suggested by @pancake --- arch/AArch64/AArch64InstPrinter.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/AArch64/AArch64InstPrinter.c b/arch/AArch64/AArch64InstPrinter.c index b0920546..83069d4a 100644 --- a/arch/AArch64/AArch64InstPrinter.c +++ b/arch/AArch64/AArch64InstPrinter.c @@ -47,11 +47,11 @@ static void printShifter(MCInst *MI, unsigned OpNum, SStream *O); static void set_mem_access(MCInst *MI, bool status) { + MI->csh->doing_mem = status; + if (MI->csh->detail != CS_OPT_ON) return; - MI->csh->doing_mem = status; - if (status) { MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].type = ARM64_OP_MEM; MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.base = ARM64_REG_INVALID; @@ -611,8 +611,13 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O) if (MI->Opcode == AArch64_ADR) { imm += MI->address; printUInt64Bang(O, imm); - } else - printUInt64Bang(O, imm); + } else { + if (MI->csh->doing_mem) + printInt64Bang(O, imm); + else + printUInt64Bang(O, imm); + } + if (MI->csh->detail) { if (MI->csh->doing_mem) { MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].mem.disp = (int32_t)imm;