arm: alias LDR instruction with operands '[sp], 4' to POP. suggested by Pancake

_v3_old
Nguyen Anh Quynh 10 years ago
parent a2934a7b6a
commit 3caf837c9a
  1. 30
      arch/ARM/ARMInstPrinter.c

@ -469,20 +469,24 @@ void ARM_printInst(MCInst *MI, SStream *O, void *Info)
break; break;
case ARM_LDR_POST_IMM: case ARM_LDR_POST_IMM:
if (MCOperand_getReg(MCInst_getOperand(MI, 2)) == ARM_SP && if (MCOperand_getReg(MCInst_getOperand(MI, 2)) == ARM_SP) {
MCOperand_getImm(MCInst_getOperand(MI, 4)) == 4) { MCOperand *MO2 = MCInst_getOperand(MI, 4);
SStream_concat0(O, "pop"); if ((getAM2Op((unsigned int)MCOperand_getImm(MO2)) == ARM_AM_add &&
MCInst_setOpcodePub(MI, ARM_INS_POP); getAM2Offset((unsigned int)MCOperand_getImm(MO2)) == 4) ||
printPredicateOperand(MI, 5, O); MCOperand_getImm(MO2) == 4) {
SStream_concat0(O, "\t{"); SStream_concat0(O, "pop");
printRegName(MI->csh, O, MCOperand_getReg(MCInst_getOperand(MI, 0))); MCInst_setOpcodePub(MI, ARM_INS_POP);
if (MI->csh->detail) { printPredicateOperand(MI, 5, O);
MI->flat_insn->detail->arm.operands[MI->flat_insn->detail->arm.op_count].type = ARM_OP_REG; SStream_concat0(O, "\t{");
MI->flat_insn->detail->arm.operands[MI->flat_insn->detail->arm.op_count].reg = MCOperand_getReg(MCInst_getOperand(MI, 0)); printRegName(MI->csh, O, MCOperand_getReg(MCInst_getOperand(MI, 0)));
MI->flat_insn->detail->arm.op_count++; if (MI->csh->detail) {
MI->flat_insn->detail->arm.operands[MI->flat_insn->detail->arm.op_count].type = ARM_OP_REG;
MI->flat_insn->detail->arm.operands[MI->flat_insn->detail->arm.op_count].reg = MCOperand_getReg(MCInst_getOperand(MI, 0));
MI->flat_insn->detail->arm.op_count++;
}
SStream_concat0(O, "}");
return;
} }
SStream_concat0(O, "}");
return;
} }
break; break;

Loading…
Cancel
Save