about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--miasm2/arch/x86/arch.py5
-rw-r--r--miasm2/arch/x86/sem.py16
-rw-r--r--test/arch/x86/arch.py3
3 files changed, 15 insertions, 9 deletions
diff --git a/miasm2/arch/x86/arch.py b/miasm2/arch/x86/arch.py
index a3b3bb95..ff7dc1ee 100644
--- a/miasm2/arch/x86/arch.py
+++ b/miasm2/arch/x86/arch.py
@@ -4315,10 +4315,7 @@ addop("pextrq", [bs8(0x0f), bs8(0x3a), bs8(0x16), pref_66] +
 
 
 addop("pextrw", [bs8(0x0f), bs8(0x3a), bs8(0x15), pref_66] +
-      rmmod(xmm_reg, rm_arg_m16) + [u08], [rm_arg_m16, xmm_reg, u08])
-#addop("pextrw", [bs8(0x0f), bs8(0x3a), bs8(0x15), no_xmm_pref] +
-#      rmmod(mm_reg, rm_arg_m16) + [u08], [rm_arg_m16, mm_reg, u08])
-
+      rmmod(xmm_reg, rm_arg_reg_m16) + [u08], [rm_arg_reg_m16, xmm_reg, u08])
 addop("pextrw", [bs8(0x0f), bs8(0xc5), no_xmm_pref] +
       rmmod(mm_reg, rm_arg_reg_m16) + [u08], [rm_arg_reg_m16, mm_reg, u08])
 addop("pextrw", [bs8(0x0f), bs8(0xc5), pref_66] +
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])]
diff --git a/test/arch/x86/arch.py b/test/arch/x86/arch.py
index 322635e7..80a8563d 100644
--- a/test/arch/x86/arch.py
+++ b/test/arch/x86/arch.py
@@ -2887,6 +2887,9 @@ reg_tests = [
     (m64, "00000000    PEXTRQ     QWORD PTR [RDX], XMM2, 0x5",
     "66480F3A161205"),
 
+    (m64, "00000000    PEXTRW     RCX, XMM14, 0x5",
+    "664C0F3A15F105"),
+
 
     (m32, "00000000    UNPCKHPS   XMM2, XMMWORD PTR [EDX]",
      "0f1512"),