diff options
| -rw-r--r-- | miasm2/arch/mips32/arch.py | 6 | ||||
| -rw-r--r-- | miasm2/arch/mips32/sem.py | 17 | ||||
| -rw-r--r-- | test/arch/mips32/arch.py | 4 |
3 files changed, 25 insertions, 2 deletions
diff --git a/miasm2/arch/mips32/arch.py b/miasm2/arch/mips32/arch.py index c6c5a55d..447669ef 100644 --- a/miasm2/arch/mips32/arch.py +++ b/miasm2/arch/mips32/arch.py @@ -52,7 +52,7 @@ class additional_info: self.except_on_instr = False br_flt = ['BC1F'] -br_0 = ['B', 'JR', 'BAL', 'JALR'] +br_0 = ['B', 'JR', 'BAL', 'JAL', 'JALR'] br_1 = ['BGEZ', 'BLTZ', 'BGTZ', 'BLEZ', 'BC1T', 'BC1F'] + br_flt br_2 = ['BEQ', 'BEQL', 'BNE'] @@ -116,7 +116,7 @@ class instruction_mips32(instruction): def breakflow(self): if self.name == 'BREAK': return False - if self.name.startswith('B') or self.name in ['JR', 'J', 'JALR']: + if self.name.startswith('B') or self.name in ['JR', 'J', 'JAL', 'JALR']: return True return False @@ -542,6 +542,7 @@ bs_arith = bs_name(l=6, name={'ADDU':0b100001, 'SUBU':0b100011, 'NOR':0b100111, 'MOVN':0b001011, + 'MOVZ':0b001010, }) bs_shift = bs_name(l=6, name={'SLL':0b000000, @@ -643,6 +644,7 @@ mips32op("sltiu", [bs('001011'), rs, rt, s16imm], [rt, rs, s16imm]) mips32op("j", [bs('000010'), instr_index]) +mips32op("jal", [bs('000011'), instr_index]) mips32op("jalr", [bs('000000'), rs, bs('00000'), rd, hint, bs('001001')]) mips32op("jr", [bs('000000'), rs, bs('0000000000'), hint, bs('001000')]) diff --git a/miasm2/arch/mips32/sem.py b/miasm2/arch/mips32/sem.py index aeb64991..ab2f1c62 100644 --- a/miasm2/arch/mips32/sem.py +++ b/miasm2/arch/mips32/sem.py @@ -18,6 +18,13 @@ def sw(ir, instr, a, b): e.append(ExprAff(b, a)) return None, e, [] +def jal(ir, instr, a): + e = [] + n = ExprId(ir.get_next_break_label(instr)) + e.append(ExprAff(PC, a)) + e.append(ExprAff(RA, n)) + return a, e, [] + def jalr(ir, instr, a, b): e = [] n = ExprId(ir.get_next_break_label(instr)) @@ -149,6 +156,14 @@ def movn(ir, instr, a, b, c): return ExprCond(c, lbl_do, lbl_skip), [], [irbloc(lbl_do.name, lbl_skip, [e_do])] +def movz(ir, instr, a, b, c): + lbl_do = ExprId(ir.gen_label(), instr.mode) + lbl_skip = ExprId(ir.get_next_label(instr), instr.mode) + e_do = [] + e_do.append(ExprAff(a, b)) + + return ExprCond(c, lbl_skip, lbl_do), [], [irbloc(lbl_do.name, lbl_skip, [e_do])] + def srl(ir, instr, a, b, c): e = [] e.append(ExprAff(a, b >> c)) @@ -376,6 +391,7 @@ mnemo_func = { "sh" : sh, "sb" : sb, "jalr" : jalr, + "jal" : jal, "bal" : bal, "b" : l_b, "lbu" : lbu, @@ -402,6 +418,7 @@ mnemo_func = { "sltiu" : sltu, "subu" : l_sub, "movn" : movn, + "movz" : movz, "srl" : srl, "sra" : sra, "srav" : srav, diff --git a/test/arch/mips32/arch.py b/test/arch/mips32/arch.py index d0814a4c..2ec6d2a2 100644 --- a/test/arch/mips32/arch.py +++ b/test/arch/mips32/arch.py @@ -208,6 +208,10 @@ reg_tests_mips32 = [ ("8BA10124 INS A0, A1, 0x0, 0x8", "7CA43804"), + ("XXXXXXXX MOVZ S0, T1, A2", + "0126800a"), + ("XXXXXXXX JAL 0x7C0B0AC", + "0df02c2b"), ] |