def _sub_asm_inst(self, i, tab=0): modified = False if self.gctx.capstone_string == 0: if i.id in LDR_CHECK: self._operand(i, 0) self._add(" = (") self._type(LDR_TYPE[i.id]) self._add(") ") self._operand(i, 1) modified = True elif i.id in STR_CHECK: self._operand(i, 1) self._add(" = (") self._type(STR_TYPE[i.id]) self._add(") ") self._operand(i, 0) modified = True elif i.id in INST_CHECK: self._operand(i, 0) if i.id == ARM_INS_CMP: self._add(" " + inst_symbol(i) + " ") self._operand(i, 1) else: self._add(" = ") self._operand(i, 1) if len(i.operands) == 3: self._add(" " + inst_symbol(i) + " ") self._operand(i, 2) modified = True if not modified: self._add("%s " % i.mnemonic) if len(i.operands) > 0: self._operand(i, 0) k = 1 while k < len(i.operands): self._add(", ") self._operand(i, k) k += 1 if i.update_flags and i.id != ARM_INS_CMP and i.id != ARM_INS_TST: self._add(" ") self._type("(FLAGS)")
def _if_cond(self, cond, fused_inst): if fused_inst is None: self._add(cond_symbol(cond)) if cond in COND_ADD_ZERO: self._add(" 0") return assignment = fused_inst.id in ASSIGNMENT_OPS if assignment: self._add("(") self._add("(") self._operand(fused_inst, 0) self._add(" ") if assignment: self._add(inst_symbol(fused_inst)) self._add(" ") self._operand(fused_inst, 1) self._add(") ") self._add(cond_symbol(jump_cond)) else: self._add(cond_symbol(cond)) self._add(" ") self._operand(fused_inst, 1) if (fused_inst.id != ARM_INS_CMP and \ (cond in COND_ADD_ZERO or assignment)): self._add(" 0") self._add(")")
def _if_cond(self, cond, fused_inst): if fused_inst is None: self._add(cond_symbol(cond)) if cond in COND_ADD_ZERO: self._add(" 0") return assignment = fused_inst.id in ASSIGNMENT_OPS if assignment: self._add("(") self._add("(") self._operand(fused_inst, 0) self._add(" ") if assignment: self._add(inst_symbol(fused_inst)) self._add(" ") self._operand(fused_inst, 1) self._add(") ") self._add(cond_symbol(cond)) else: self._add(cond_symbol(cond)) self._add(" ") self._operand(fused_inst, 1) if (fused_inst.id != ARM_INS_CMP and \ (cond in COND_ADD_ZERO or assignment)): self._add(" 0") self._add(")")
def _sub_asm_inst(self, i, tab=0): modified = False is_imm = i.address in self.gctx.db.immediates if self.gctx.capstone_string == 0: if is_imm: self._section("!") self._operand(i, 0) self._add(" = ") self._imm(self.gctx.db.immediates[i.address], self._dis.wordsize, False) modified = True elif i.id in LDR_CHECK: self._operand(i, 0) self._add(" = (") self._type(LDR_TYPE[i.id]) self._add(") ") self._operand(i, 1) modified = True elif i.id in STR_CHECK: self._operand(i, 1) self._add(" = (") self._type(STR_TYPE[i.id]) self._add(") ") self._operand(i, 0) modified = True elif i.id in INST_CHECK: self._operand(i, 0) if i.id == ARM_INS_CMP: self._add(" " + inst_symbol(i) + " ") self._operand(i, 1) else: self._add(" = ") self._operand(i, 1) if len(i.operands) == 3: self._add(" " + inst_symbol(i) + " ") self._operand(i, 2) modified = True if not modified: if is_imm: self._section("!") self._add("mov ") self._operand(i, 0) self._add(", ") self._imm(self.gctx.db.immediates[i.address], self._dis.wordsize, True) else: self._add("%s " % i.mnemonic) if len(i.operands) > 0: self._operand(i, 0) k = 1 while k < len(i.operands): self._add(", ") self._operand(i, k) k += 1 if i.update_flags and i.id != ARM_INS_CMP and i.id != ARM_INS_TST: self._add(" ") self._type("(FLAGS)")