about summary refs log tree commit diff stats
path: root/miasm2/expression/simplifications_common.py
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2018-02-13 14:24:05 +0100
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2018-02-13 18:42:51 +0100
commit6702a6149c57c54bcece3fb1cd00b8c09af6e74a (patch)
treedc7e4df80fe9ea47ceb0bbecbe964f0fa93262ba /miasm2/expression/simplifications_common.py
parent839b17e1f1753fb1c99506c5810b62afc95bc635 (diff)
downloadmiasm-6702a6149c57c54bcece3fb1cd00b8c09af6e74a.tar.gz
miasm-6702a6149c57c54bcece3fb1cd00b8c09af6e74a.zip
X86: remove c_rez/rcl_rez/rcr_rez special operator
Diffstat (limited to 'miasm2/expression/simplifications_common.py')
-rw-r--r--miasm2/expression/simplifications_common.py40
1 files changed, 4 insertions, 36 deletions
diff --git a/miasm2/expression/simplifications_common.py b/miasm2/expression/simplifications_common.py
index f045830e..ba938db5 100644
--- a/miasm2/expression/simplifications_common.py
+++ b/miasm2/expression/simplifications_common.py
@@ -48,11 +48,11 @@ def simp_cst_propagation(e_s, expr):
                 tmp2 = mod_size2uint[int2.arg.size](int2.arg)
                 out = mod_size2uint[int1.arg.size](tmp1 >> tmp2)
             elif op_name == '>>>':
-                out = (int1.arg >> (int2.arg % int2.size) |
-                     int1.arg << ((int1.size - int2.arg) % int2.size))
+                shifter = int2.arg % int2.size
+                out = (int1.arg >> shifter) | (int1.arg << (int2.size - shifter))
             elif op_name == '<<<':
-                out = (int1.arg << (int2.arg % int2.size) |
-                     int1.arg >> ((int1.size - int2.arg) % int2.size))
+                shifter = int2.arg % int2.size
+                out = (int1.arg << shifter) | (int1.arg >> (int2.size - shifter))
             elif op_name == '/':
                 out = int1.arg / int2.arg
             elif op_name == '%':
@@ -320,38 +320,6 @@ def simp_cst_propagation(e_s, expr):
                 args.append(ExprOp(op_name, *arg))
             return ExprCompose(*args)
 
-    # <<<c_rez, >>>c_rez
-    if op_name in [">>>c_rez", "<<<c_rez"]:
-        assert len(args) == 3
-        dest, rounds, carry_flag = args
-        # Skipped if rounds is 0
-        if rounds.is_int(0):
-            return dest
-        elif all(arg.is_int() for arg in args):
-            # The expression can be resolved
-            tmp = int(dest)
-            carry_flag = int(carry_flag)
-            size = dest.size
-            tmp_count = (int(rounds) &
-                         (0x3f if size == 64 else 0x1f)) % (size + 1)
-            if op_name == ">>>c_rez":
-                while tmp_count != 0:
-                    tmp_cf = tmp & 1;
-                    tmp = (tmp >> 1) + (carry_flag << (size - 1))
-                    carry_flag = tmp_cf
-                    tmp_count -= 1
-                    tmp &= int(dest.mask)
-            elif op_name == "<<<c_rez":
-                while tmp_count != 0:
-                    tmp_cf = (tmp >> (size - 1)) & 1
-                    tmp = (tmp << 1) + carry_flag
-                    carry_flag = tmp_cf
-                    tmp_count -= 1
-                    tmp &= int(dest.mask)
-            else:
-                raise RuntimeError("Unknown operation: %s" % op_name)
-            return ExprInt(tmp, size=dest.size)
-
     return ExprOp(op_name, *args)