diff options
Diffstat (limited to 'miasm2/arch/arm/sem.py')
| -rw-r--r-- | miasm2/arch/arm/sem.py | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/miasm2/arch/arm/sem.py b/miasm2/arch/arm/sem.py index 8c74aa76..710cdc9f 100644 --- a/miasm2/arch/arm/sem.py +++ b/miasm2/arch/arm/sem.py @@ -13,7 +13,7 @@ EXCEPT_PRIV_INSN = (1 << 17) def update_flag_zf(a): - return [ExprAff(zf, ExprCond(a, ExprInt1(0), ExprInt1(1)))] + return [ExprAff(zf, ExprCond(a, ExprInt(0, 1), ExprInt(1, 1)))] def update_flag_nf(a): @@ -31,7 +31,7 @@ def update_flag_logic(a): e = [] e += update_flag_zn(a) # XXX TODO: set cf if ROT imm in argument - #e.append(ExprAff(cf, ExprInt1(0))) + #e.append(ExprAff(cf, ExprInt(0, 1))) return e @@ -68,7 +68,7 @@ def update_flag_add_of(op1, op2, res): def update_flag_sub_cf(op1, op2, res): "Compote CF in @res = @op1 - @op2" return ExprAff(cf, - ((((op1 ^ op2) ^ res) ^ ((op1 ^ res) & (op1 ^ op2))).msb()) ^ ExprInt1(1)) + ((((op1 ^ op2) ^ res) ^ ((op1 ^ res) & (op1 ^ op2))).msb()) ^ ExprInt(1, 1)) def update_flag_sub_of(op1, op2, res): @@ -227,7 +227,7 @@ def sbc(ir, instr, a, b, c=None): e = [] if c is None: b, c = a, b - r = (b + cf.zeroExtend(32)) - (c + ExprInt32(1)) + r = (b + cf.zeroExtend(32)) - (c + ExprInt(1, 32)) e.append(ExprAff(a, r)) dst = get_dst(a) if dst is not None: @@ -239,7 +239,7 @@ def sbcs(ir, instr, a, b, c=None): e = [] if c is None: b, c = a, b - r = (b + cf.zeroExtend(32)) - (c + ExprInt32(1)) + r = (b + cf.zeroExtend(32)) - (c + ExprInt(1, 32)) e += update_flag_arith(r) e += update_flag_sub(b, c, r) e.append(ExprAff(a, r)) @@ -253,7 +253,7 @@ def rsc(ir, instr, a, b, c=None): e = [] if c is None: b, c = a, b - r = (c + cf.zeroExtend(32)) - (b + ExprInt32(1)) + r = (c + cf.zeroExtend(32)) - (b + ExprInt(1, 32)) e.append(ExprAff(a, r)) dst = get_dst(a) if dst is not None: @@ -265,7 +265,7 @@ def rscs(ir, instr, a, b, c=None): e = [] if c is None: b, c = a, b - r = (c + cf.zeroExtend(32)) - (b + ExprInt32(1)) + r = (c + cf.zeroExtend(32)) - (b + ExprInt(1, 32)) e.append(ExprAff(a, r)) e += update_flag_arith(r) e += update_flag_sub(c, b, r) @@ -348,7 +348,7 @@ def mov(ir, instr, a, b): def movt(ir, instr, a, b): - r = a | b << ExprInt32(16) + r = a | b << ExprInt(16, 32) e = [ExprAff(a, r)] dst = get_dst(a) if dst is not None: @@ -368,7 +368,7 @@ def movs(ir, instr, a, b): def mvn(ir, instr, a, b): - r = b ^ ExprInt32(-1) + r = b ^ ExprInt(-1, 32) e = [ExprAff(a, r)] dst = get_dst(a) if dst is not None: @@ -378,7 +378,7 @@ def mvn(ir, instr, a, b): def mvns(ir, instr, a, b): e = [] - r = b ^ ExprInt32(-1) + r = b ^ ExprInt(-1, 32) e.append(ExprAff(a, r)) # XXX TODO check e += update_flag_logic(r) @@ -405,7 +405,7 @@ def bic(ir, instr, a, b, c=None): e = [] if c is None: b, c = a, b - r = b & (c ^ ExprInt(uint32(-1))) + r = b & (c ^ ExprInt(-1, 32)) e.append(ExprAff(a, r)) dst = get_dst(a) if dst is not None: @@ -417,7 +417,7 @@ def bics(ir, instr, a, b, c=None): e = [] if c is None: b, c = a, b - r = b & (c ^ ExprInt(uint32(-1))) + r = b & (c ^ ExprInt(-1, 32)) e += update_flag_logic(r) e.append(ExprAff(a, r)) dst = get_dst(a) @@ -512,7 +512,7 @@ def b(ir, instr, a): def bl(ir, instr, a): e = [] - l = ExprInt32(instr.offset + instr.l) + l = ExprInt(instr.offset + instr.l, 32) e.append(ExprAff(PC, a)) e.append(ExprAff(ir.IRDst, a)) e.append(ExprAff(LR, l)) @@ -528,7 +528,7 @@ def bx(ir, instr, a): def blx(ir, instr, a): e = [] - l = ExprInt32(instr.offset + instr.l) + l = ExprInt(instr.offset + instr.l, 32) e.append(ExprAff(PC, a)) e.append(ExprAff(ir.IRDst, a)) e.append(ExprAff(LR, l)) @@ -549,9 +549,9 @@ def st_ld_r(ir, instr, a, b, store=False, size=32, s_ext=False, z_ext=False): postinc = True if isinstance(b, ExprOp) and b.op in ["postinc", 'preinc']: # XXX TODO CHECK - base, off = b.args[0], b.args[1] # ExprInt32(size/8) + base, off = b.args[0], b.args[1] # ExprInt(size/8, 32) else: - base, off = b, ExprInt32(0) + base, off = b, ExprInt(0, 32) # print a, wb, base, off, postinc if postinc: ad = base @@ -584,14 +584,14 @@ def st_ld_r(ir, instr, a, b, store=False, size=32, s_ext=False, z_ext=False): if store: e.append(ExprAff(m, a)) if dmem: - e.append(ExprAff(ExprMem(ad + ExprInt32(4), size=size), a2)) + e.append(ExprAff(ExprMem(ad + ExprInt(4, 32), size=size), a2)) else: if a == PC: dst = PC e.append(ExprAff(ir.IRDst, m)) e.append(ExprAff(a, m)) if dmem: - e.append(ExprAff(a2, ExprMem(ad + ExprInt32(4), size=size))) + e.append(ExprAff(a2, ExprMem(ad + ExprInt(4, 32), size=size))) # XXX TODO check multiple write cause by wb if wb or postinc: @@ -668,9 +668,9 @@ def st_ld_m(ir, instr, a, b, store=False, postinc=False, updown=False): if postinc: pass else: - base += ExprInt32(step) + base += ExprInt(step, 32) for i, r in enumerate(regs): - ad = base + ExprInt32(i * step) + ad = base + ExprInt(i * step, 32) if store: e.append(ExprAff(ExprMem(ad), r)) else: @@ -680,9 +680,9 @@ def st_ld_m(ir, instr, a, b, store=False, postinc=False, updown=False): # XXX TODO check multiple write cause by wb if wb: if postinc: - e.append(ExprAff(a, base + ExprInt32(len(regs) * step))) + e.append(ExprAff(a, base + ExprInt(len(regs) * step, 32))) else: - e.append(ExprAff(a, base + ExprInt32((len(regs) - 1) * step))) + e.append(ExprAff(a, base + ExprInt((len(regs) - 1) * step, 32))) if store: pass else: @@ -726,7 +726,7 @@ def stmdb(ir, instr, a, b): def svc(ir, instr, a): # XXX TODO implement e = [ - ExprAff(exception_flags, ExprInt32(EXCEPT_PRIV_INSN))] + ExprAff(exception_flags, ExprInt(EXCEPT_PRIV_INSN, 32))] return e @@ -812,9 +812,9 @@ def push(ir, instr, a): e = [] regs = list(a.args) for i in xrange(len(regs)): - r = SP + ExprInt32(-4 * (i + 1)) + r = SP + ExprInt(-4 * (i + 1), 32) e.append(ExprAff(ExprMem(r), regs[i])) - r = SP + ExprInt32(-4 * len(regs)) + r = SP + ExprInt(-4 * len(regs), 32) e.append(ExprAff(SP, r)) return e @@ -824,11 +824,11 @@ def pop(ir, instr, a): regs = list(a.args) dst = None for i in xrange(len(regs)): - r = SP + ExprInt32(4 * i) + r = SP + ExprInt(4 * i, 32) e.append(ExprAff(regs[i], ExprMem(r))) if regs[i] == ir.pc: dst = ExprMem(r) - r = SP + ExprInt32(4 * len(regs)) + r = SP + ExprInt(4 * len(regs), 32) e.append(ExprAff(SP, r)) if dst is not None: e.append(ExprAff(ir.IRDst, dst)) @@ -913,7 +913,7 @@ def bfc(ir, instr, a, b, c): out.append(a[:start]) last = start if stop - start: - out.append(ExprInt32(0)[last:stop]) + out.append(ExprInt(0, 32)[last:stop]) last = stop if last < 32: out.append(a[last:]) @@ -942,13 +942,13 @@ def clz(ir, instr, a, b): def uxtab(ir, instr, a, b, c): e = [] - e.append(ExprAff(a, b + (c & ExprInt32(0xff)))) + e.append(ExprAff(a, b + (c & ExprInt(0xff, 32)))) return e def bkpt(ir, instr, a): e = [] - e.append(ExprAff(exception_flags, ExprInt32(EXCEPT_SOFT_BP))) + e.append(ExprAff(exception_flags, ExprInt(EXCEPT_SOFT_BP, 32))) e.append(ExprAff(bp_num, a)) return e @@ -1003,26 +1003,26 @@ cond_dct = { tab_cond = {COND_EQ: zf, - COND_NE: ExprCond(zf, ExprInt1(0), ExprInt1(1)), + COND_NE: ExprCond(zf, ExprInt(0, 1), ExprInt(1, 1)), COND_CS: cf, - COND_CC: ExprCond(cf, ExprInt1(0), ExprInt1(1)), + COND_CC: ExprCond(cf, ExprInt(0, 1), ExprInt(1, 1)), COND_MI: nf, - COND_PL: ExprCond(nf, ExprInt1(0), ExprInt1(1)), + COND_PL: ExprCond(nf, ExprInt(0, 1), ExprInt(1, 1)), COND_VS: of, - COND_VC: ExprCond(of, ExprInt1(0), ExprInt1(1)), - COND_HI: cf & ExprCond(zf, ExprInt1(0), ExprInt1(1)), + COND_VC: ExprCond(of, ExprInt(0, 1), ExprInt(1, 1)), + COND_HI: cf & ExprCond(zf, ExprInt(0, 1), ExprInt(1, 1)), # COND_HI: cf, # COND_HI: ExprOp('==', # ExprOp('|', cf, zf), - # ExprInt1(0)), - COND_LS: ExprCond(cf, ExprInt1(0), ExprInt1(1)) | zf, - COND_GE: ExprCond(nf - of, ExprInt1(0), ExprInt1(1)), + # ExprInt(0, 1)), + COND_LS: ExprCond(cf, ExprInt(0, 1), ExprInt(1, 1)) | zf, + COND_GE: ExprCond(nf - of, ExprInt(0, 1), ExprInt(1, 1)), COND_LT: nf ^ of, # COND_GT: ExprOp('|', - # ExprOp('==', zf, ExprInt1(0)) & (nf | of), - # ExprOp('==', nf, ExprInt1(0)) & ExprOp('==', of, ExprInt1(0))), - COND_GT: (ExprCond(zf, ExprInt1(0), ExprInt1(1)) & - ExprCond(nf - of, ExprInt1(0), ExprInt1(1))), + # ExprOp('==', zf, ExprInt(0, 1)) & (nf | of), + # ExprOp('==', nf, ExprInt(0, 1)) & ExprOp('==', of, ExprInt(0, 1))), + COND_GT: (ExprCond(zf, ExprInt(0, 1), ExprInt(1, 1)) & + ExprCond(nf - of, ExprInt(0, 1), ExprInt(1, 1))), COND_LE: zf | (nf ^ of), } @@ -1250,13 +1250,13 @@ class ir_arml(IntermediateRepresentation): # return instr_ir, extra_ir for i, x in enumerate(instr_ir): x = ExprAff(x.dst, x.src.replace_expr( - {self.pc: ExprInt32(instr.offset + 8)})) + {self.pc: ExprInt(instr.offset + 8, 32)})) instr_ir[i] = x for irblock in extra_ir: for irs in irblock.irs: for i, x in enumerate(irs): x = ExprAff(x.dst, x.src.replace_expr( - {self.pc: ExprInt32(instr.offset + 8)})) + {self.pc: ExprInt(instr.offset + 8, 32)})) irs[i] = x # return out_ir, extra_ir return instr_ir, extra_ir |