Skip to content

Commit

Permalink
Extend sign of the branch destination operand
Browse files Browse the repository at this point in the history
  • Loading branch information
kratolp committed Sep 16, 2014
1 parent 87736c1 commit 05d4b83
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions arch/PowerPC/PPCInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ static void printBranchOperand(MCInst *MI, unsigned OpNo, SStream *O)

// Branches can take an immediate operand. This is used by the branch
// selection pass to print .+8, an eight byte displacement from the PC.
SStream_concat0(O, ".+");
//SStream_concat0(O, ".+");
printAbsBranchOperand(MI, OpNo, O);
}

Expand All @@ -442,17 +442,17 @@ static void printAbsBranchOperand(MCInst *MI, unsigned OpNo, SStream *O)
return;
}

imm = (int)MCOperand_getImm(MCInst_getOperand(MI, OpNo)) * 4;
imm = ((int)MCOperand_getImm(MCInst_getOperand(MI, OpNo)) << 18) >> 16;
if (imm >= 0) {
if (imm > HEX_THRESHOLD)
SStream_concat(O, "0x%x", imm);
SStream_concat(O, ".+0x%x", imm);
else
SStream_concat(O, "%u", imm);
SStream_concat(O, ".+%u", imm);
} else {
if (imm < -HEX_THRESHOLD)
SStream_concat(O, "-0x%x", -imm);
SStream_concat(O, ".-0x%x", -imm);
else
SStream_concat(O, "-%u", -imm);
SStream_concat(O, ".-%u", -imm);
}

if (MI->csh->detail) {
Expand Down

0 comments on commit 05d4b83

Please sign in to comment.