about summary refs log tree commit diff stats
path: root/miasm2/arch/x86/sem.py
diff options
context:
space:
mode:
authorw4kfu <gw4kfu@gmail.com>2018-11-08 17:31:29 -0500
committerw4kfu <gw4kfu@gmail.com>2018-11-10 09:14:20 -0500
commit5c53563db1b912628a67d4972ea2a3e8b2c983ff (patch)
treed0e833986112d533225ca56df9c298879b3de463 /miasm2/arch/x86/sem.py
parent26e81f4a6d0efaacb5ada2adf02134f348daf3b0 (diff)
downloadmiasm-5c53563db1b912628a67d4972ea2a3e8b2c983ff.tar.gz
miasm-5c53563db1b912628a67d4972ea2a3e8b2c983ff.zip
add zeroextent if destination size is 32
Diffstat (limited to '')
-rw-r--r--miasm2/arch/x86/sem.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index a3589344..565f7571 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -636,17 +636,18 @@ def _rotate_tpl(ir, instr, dst, src, op, left=False):
             m2_expr.ExprAssign(of, new_of),
             m2_expr.ExprAssign(dst, res)
             ]
+    e = []
+    if dst.size == 32 and dst in replace_regs[64]:
+        e.append(m2_expr.ExprAssign(dst[:dst.size], dst))
     # Don't generate conditional shifter on constant
     if isinstance(shifter, m2_expr.ExprInt):
         if int(shifter) != 0:
             return (e_do, [])
         else:
-            return ([], [])
-    e = []
+            return (e, [])
     loc_do, loc_do_expr = ir.gen_loc_key_and_expr(ir.IRDst.size)
     loc_skip = ir.get_next_loc_key(instr)
     loc_skip_expr = m2_expr.ExprLoc(loc_skip, ir.IRDst.size)
-
     e_do.append(m2_expr.ExprAssign(ir.IRDst, loc_skip_expr))
     e.append(m2_expr.ExprAssign(
         ir.IRDst, m2_expr.ExprCond(shifter, loc_do_expr, loc_skip_expr)))
@@ -685,17 +686,18 @@ def rotate_with_carry_tpl(ir, instr, op, dst, src):
             m2_expr.ExprAssign(of, new_of),
             m2_expr.ExprAssign(dst, new_dst)
             ]
+    e = []
+    if dst.size == 32 and dst in replace_regs[64]:
+        e.append(m2_expr.ExprAssign(dst[:dst.size], dst))
     # Don't generate conditional shifter on constant
     if isinstance(shifter, m2_expr.ExprInt):
         if int(shifter) != 0:
             return (e_do, [])
         else:
-            return ([], [])
-    e = []
+            return (e, [])
     loc_do, loc_do_expr = ir.gen_loc_key_and_expr(ir.IRDst.size)
     loc_skip = ir.get_next_loc_key(instr)
     loc_skip_expr = m2_expr.ExprLoc(loc_skip, ir.IRDst.size)
-
     e_do.append(m2_expr.ExprAssign(ir.IRDst, loc_skip_expr))
     e.append(m2_expr.ExprAssign(
         ir.IRDst, m2_expr.ExprCond(shifter, loc_do_expr, loc_skip_expr)))
@@ -772,15 +774,15 @@ def _shift_tpl(op, ir, instr, a, b, c=None, op_inv=None, left=False,
         m2_expr.ExprAssign(a, res),
     ]
     e_do += update_flag_znp(res)
-
+    e = []
+    if a.size == 32 and a in replace_regs[64]:
+        e.append(m2_expr.ExprAssign(a[:a.size], a))
     # Don't generate conditional shifter on constant
     if isinstance(shifter, m2_expr.ExprInt):
         if int(shifter) != 0:
-            return e_do, []
+            return (e_do, [])
         else:
-            return [], []
-
-    e = []
+            return (e, [])
     loc_do, loc_do_expr = ir.gen_loc_key_and_expr(ir.IRDst.size)
     loc_skip = ir.get_next_loc_key(instr)
     loc_skip_expr = m2_expr.ExprLoc(loc_skip, ir.IRDst.size)