about summary refs log tree commit diff stats
path: root/miasm2/arch/x86/sem.py
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2016-08-03 20:56:57 +0200
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2016-08-04 09:17:09 +0200
commitb7f546211a5c79a3045ea7c94a6ad2bde6eda5df (patch)
treecb179a63e5e4da4ed2b9406ab1a6cbd3999a16ba /miasm2/arch/x86/sem.py
parent7004f9fff425b8faf6e156889f07eafd3fb5f61f (diff)
downloadmiasm-b7f546211a5c79a3045ea7c94a6ad2bde6eda5df.tar.gz
miasm-b7f546211a5c79a3045ea7c94a6ad2bde6eda5df.zip
X86: fix pextrw
Diffstat (limited to '')
-rw-r--r--miasm2/arch/x86/sem.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index d3e976c2..11da1e8b 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -3606,19 +3606,25 @@ def ps_rl_ll(ir, instr, a, b, op, size):
     mask = {16: 0xF,
             32: 0x1F,
             64: 0x3F}[size]
-    test = count & m2_expr.ExprInt(((1 << a.size) - 1) ^ mask, a.size)
+    test = expr_simp(count & m2_expr.ExprInt(((1 << a.size) - 1) ^ mask, a.size))
     e = [m2_expr.ExprAff(ir.IRDst, m2_expr.ExprCond(test,
                                                     lbl_zero,
                                                     lbl_do))]
 
-    e_zero = [m2_expr.ExprAff(a, m2_expr.ExprInt(0, a.size)),
-              m2_expr.ExprAff(ir.IRDst, lbl_next)]
-
-    e_do = []
     slices = []
     for i in xrange(0, a.size, size):
         slices.append((m2_expr.ExprOp(op, a[i:i + size], count[:size]),
                        i, i + size))
+
+    if isinstance(test, m2_expr.ExprInt):
+        if int(test.arg) == 0:
+            return [m2_expr.ExprAff(a[0:a.size], m2_expr.ExprCompose(slices))], []
+        else:
+            return [m2_expr.ExprAff(a, m2_expr.ExprInt(0, a.size))], []
+
+    e_zero = [m2_expr.ExprAff(a, m2_expr.ExprInt(0, a.size)),
+              m2_expr.ExprAff(ir.IRDst, lbl_next)]
+    e_do = []
     e.append(m2_expr.ExprAff(a[0:a.size], m2_expr.ExprCompose(slices)))
     e_do.append(m2_expr.ExprAff(ir.IRDst, lbl_next))
     return e, [irbloc(lbl_do.name, [e_do]), irbloc(lbl_zero.name, [e_zero])]