|
26 | 26 | MIPS_INS_SUBU, MIPS_INS_BGTZ, MIPS_INS_LH, MIPS_INS_LHU, |
27 | 27 | MIPS_INS_SH, MIPS_INS_SD, MIPS_INS_LD, MIPS_GRP_MIPS64, |
28 | 28 | MIPS_INS_BGEZ, MIPS_INS_BNEZ, MIPS_INS_BEQZ, MIPS_INS_BLEZ, |
29 | | - MIPS_INS_BLTZ, MIPS_REG_ZERO, MIPS_REG_GP, MIPS_INS_NEG) |
| 29 | + MIPS_INS_BLTZ, MIPS_REG_ZERO, MIPS_REG_GP, MIPS_INS_NEG, |
| 30 | + MIPS_INS_BEQ, MIPS_INS_BNE) |
30 | 31 |
|
31 | 32 | from plasma.lib.output import OutputAbs |
32 | 33 | from plasma.lib.arch.mips.utils import (inst_symbol, is_call, is_jump, is_ret, |
33 | 34 | is_uncond_jump, cond_symbol) |
34 | 35 | from capstone.mips import (MIPS_INS_SLT, MIPS_INS_SLTI, MIPS_INS_SLTIU, MIPS_INS_SLTU, |
35 | 36 | MIPS_INS_ANDI, MIPS_INS_OR, MIPS_INS_ORI) |
36 | 37 |
|
37 | | -# ASSIGNMENT_OPS = {ARM_INS_EOR, ARM_INS_AND, ARM_INS_ORR} |
38 | | -ASSIGNMENT_OPS = {MIPS_INS_SLT, MIPS_INS_SLTI, MIPS_INS_SLTIU, MIPS_INS_SLTU} |
| 38 | +ASSIGNMENT_OPS = {MIPS_INS_SLT, MIPS_INS_SLTI, MIPS_INS_SLTIU, MIPS_INS_SLTU, MIPS_INS_BEQ, MIPS_INS_BNE} |
39 | 39 |
|
40 | 40 | LD_TYPE = { |
41 | 41 | MIPS_INS_LH: "halfword", |
@@ -148,16 +148,18 @@ def _if_cond(self, cond, fused_inst): |
148 | 148 | self._add(" 0") |
149 | 149 | return |
150 | 150 |
|
151 | | - assignment = fused_inst.id in ASSIGNMENT_OPS |
| 151 | + assignment = fused_inst.id in ASSIGNMENT_OPS or fused_inst.id in COND_ADD_ZERO |
152 | 152 |
|
153 | 153 | if assignment: |
154 | 154 | self._add("(") |
155 | | - self._operand(fused_inst, 1) |
156 | | - if cond == MIPS_INS_BNEZ: |
157 | | - self._add(" < ") |
| 155 | + self._operand(fused_inst, 0) |
| 156 | + self._add(" ") |
| 157 | + self._add(cond_symbol(cond)) |
| 158 | + if cond in COND_ADD_ZERO: |
| 159 | + self._add(" 0") |
158 | 160 | else: |
159 | | - self._add(" >= ") |
160 | | - self._operand(fused_inst, 2) |
| 161 | + self._add(" ") |
| 162 | + self._operand(fused_inst, 1) |
161 | 163 | self._add(")") |
162 | 164 |
|
163 | 165 | def _sub_asm_inst(self, i, tab=0): |
@@ -265,8 +267,11 @@ def _sub_asm_inst(self, i, tab=0): |
265 | 267 | if i.id == MIPS_INS_LUI: |
266 | 268 | self._operand(i, 0) |
267 | 269 | self._add(" = ") |
268 | | - self._operand(i, 1) |
269 | | - self._add(" << 16") |
| 270 | + if str(i.operands[1].value.reg).isdigit: |
| 271 | + self._add(" 0x%x" % (i.operands[1].value.reg << 16)) |
| 272 | + else: |
| 273 | + self._operand(i, 1) |
| 274 | + self._add(" << 16") |
270 | 275 |
|
271 | 276 | elif i.id == MIPS_INS_MOVE: |
272 | 277 | self._operand(i, 0) |
|
0 commit comments