diff options
Diffstat (limited to 'miasm2/expression')
| -rw-r--r-- | miasm2/expression/expression_helper.py | 8 | ||||
| -rw-r--r-- | miasm2/expression/simplifications_common.py | 18 | ||||
| -rw-r--r-- | miasm2/expression/simplifications_cond.py | 8 | ||||
| -rw-r--r-- | miasm2/expression/stp.py | 2 |
4 files changed, 18 insertions, 18 deletions
diff --git a/miasm2/expression/expression_helper.py b/miasm2/expression/expression_helper.py index 09feffc2..0c661c2a 100644 --- a/miasm2/expression/expression_helper.py +++ b/miasm2/expression/expression_helper.py @@ -43,7 +43,7 @@ def merge_sliceto_slice(args): # sources_int[a.start] = a # copy ExprInt because we will inplace modify arg just below # /!\ TODO XXX never ever modify inplace args... - sources_int[a[1]] = (m2_expr.ExprInt(int(a[0].arg), + sources_int[a[1]] = (m2_expr.ExprInt(int(a[0]), a[2] - a[1]), a[1], a[2]) @@ -80,12 +80,12 @@ def merge_sliceto_slice(args): s_start, s_stop = sorted_s[-1][1][1], sorted_s[-1][1][2] size += s_stop - s_start a = m2_expr.mod_size2uint[size]( - (int(out[0].arg) << (out[1] - s_start)) + - int(sorted_s[-1][1][0].arg)) + (int(out[0]) << (out[1] - s_start)) + + int(sorted_s[-1][1][0])) out[0] = m2_expr.ExprInt(a) sorted_s.pop() out[1] = s_start - out[0] = m2_expr.ExprInt(int(out[0].arg), size) + out[0] = m2_expr.ExprInt(int(out[0]), size) final_sources.append((start, out)) final_sources_int = final_sources diff --git a/miasm2/expression/simplifications_common.py b/miasm2/expression/simplifications_common.py index 2d5e4e6b..49dfbcc0 100644 --- a/miasm2/expression/simplifications_common.py +++ b/miasm2/expression/simplifications_common.py @@ -267,7 +267,7 @@ def simp_cst_propagation(e_s, e): # A << int with A ExprCompose => move index if op == "<<" and isinstance(args[0], ExprCompose) and isinstance(args[1], ExprInt): final_size = args[0].size - shift = int(args[1].arg) + shift = int(args[1]) new_args = [] # shift indexes for expr, start, stop in args[0].args: @@ -291,7 +291,7 @@ def simp_cst_propagation(e_s, e): # A >> int with A ExprCompose => move index if op == ">>" and isinstance(args[0], ExprCompose) and isinstance(args[1], ExprInt): final_size = args[0].size - shift = int(args[1].arg) + shift = int(args[1]) new_args = [] # shift indexes for expr, start, stop in args[0].args: @@ -335,14 +335,14 @@ def simp_cst_propagation(e_s, e): dest, rounds, cf = args # Skipped if rounds is 0 if (isinstance(rounds, ExprInt) and - int(rounds.arg) == 0): + int(rounds) == 0): return dest elif all(map(lambda x: isinstance(x, ExprInt), args)): # The expression can be resolved - tmp = int(dest.arg) - cf = int(cf.arg) + tmp = int(dest) + cf = int(cf) size = dest.size - tmp_count = (int(rounds.arg) & + tmp_count = (int(rounds) & (0x3f if size == 64 else 0x1f)) % (size + 1) if op == ">>>c_rez": while (tmp_count != 0): @@ -350,14 +350,14 @@ def simp_cst_propagation(e_s, e): tmp = (tmp >> 1) + (cf << (size - 1)) cf = tmp_cf tmp_count -= 1 - tmp &= int(dest.mask.arg) + tmp &= int(dest.mask) elif op == "<<<c_rez": while (tmp_count != 0): tmp_cf = (tmp >> (size - 1)) & 1 tmp = (tmp << 1) + cf cf = tmp_cf tmp_count -= 1 - tmp &= int(dest.mask.arg) + tmp &= int(dest.mask) else: raise RuntimeError("Unknown operation: %s" % op) return ExprInt(tmp, size=dest.size) @@ -518,7 +518,7 @@ def simp_slice(e_s, e): elif (isinstance(e.arg, ExprOp) and e.arg.op in [">>", "<<"] and isinstance(e.arg.args[1], ExprInt)): arg, shift = e.arg.args - shift = int(shift.arg) + shift = int(shift) if e.arg.op == ">>": if shift + e.stop <= arg.size: return arg[e.start + shift:e.stop + shift] diff --git a/miasm2/expression/simplifications_cond.py b/miasm2/expression/simplifications_cond.py index a5acdba6..03bf6166 100644 --- a/miasm2/expression/simplifications_cond.py +++ b/miasm2/expression/simplifications_cond.py @@ -197,13 +197,13 @@ def __comp_signed(arg1, arg2): """Return ExprInt1(1) if arg1 <s arg2 else ExprInt1(0) @arg1, @arg2: ExprInt""" - val1 = int(arg1.arg) + val1 = int(arg1) if val1 >> (arg1.size - 1) == 1: - val1 = - ((int(arg1.mask.arg) ^ val1) + 1) + val1 = - ((int(arg1.mask) ^ val1) + 1) - val2 = int(arg2.arg) + val2 = int(arg2) if val2 >> (arg2.size - 1) == 1: - val2 = - ((int(arg2.mask.arg) ^ val2) + 1) + val2 = - ((int(arg2.mask) ^ val2) + 1) return m2_expr.ExprInt1(1) if (val1 < val2) else m2_expr.ExprInt1(0) diff --git a/miasm2/expression/stp.py b/miasm2/expression/stp.py index 7ef96166..c9b76e4c 100644 --- a/miasm2/expression/stp.py +++ b/miasm2/expression/stp.py @@ -8,7 +8,7 @@ TODO XXX: finish def ExprInt_strcst(self): - b = bin(int(self.arg))[2::][::-1] + b = bin(int(self))[2::][::-1] b += "0" * self.size b = b[:self.size][::-1] return "0bin" + b |