about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2018-02-09 10:43:48 +0100
committerAjax <commial@gmail.com>2018-02-09 17:36:31 +0100
commit4a94e84923d8ac059fc2c41a5876835613204ad2 (patch)
tree88606d70093bf53de06a36ce13bfe8fbcf15aba5
parentb8bd5c0f24b786616b6f372f7f6dfad43438ab01 (diff)
downloadmiasm-4a94e84923d8ac059fc2c41a5876835613204ad2.tar.gz
miasm-4a94e84923d8ac059fc2c41a5876835613204ad2.zip
Add PMADDWD instruction
0F F5 /r 	PMADDWD mm, mm/m64
66 0F F5 /r 	PMADDWD xmm1, xmm2/m128
-rw-r--r--miasm2/arch/x86/arch.py4
-rw-r--r--miasm2/arch/x86/sem.py19
-rw-r--r--test/arch/x86/arch.py5
3 files changed, 28 insertions, 0 deletions
diff --git a/miasm2/arch/x86/arch.py b/miasm2/arch/x86/arch.py
index 839487e8..ae5f3fd7 100644
--- a/miasm2/arch/x86/arch.py
+++ b/miasm2/arch/x86/arch.py
@@ -4529,6 +4529,10 @@ addop("paddsw", [bs8(0x0f), bs8(0xed), no_xmm_pref] +
 addop("paddsw", [bs8(0x0f), bs8(0xed), pref_66] +
       rmmod(xmm_reg, rm_arg_xmm_m128))
 
+addop("pmaddwd", [bs8(0x0f), bs8(0xf5), no_xmm_pref] +
+      rmmod(mm_reg, rm_arg_mm_m64))
+addop("pmaddwd", [bs8(0x0f), bs8(0xf5), pref_66] +
+      rmmod(xmm_reg, rm_arg_xmm_m128))
 
 mn_x86.bintree = factor_one_bit(mn_x86.bintree)
 # mn_x86.bintree = factor_fields_all(mn_x86.bintree)
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index d73eac96..3880ed67 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -3477,6 +3477,22 @@ def pmuludq(ir, instr, dst, src):
         raise RuntimeError("Unsupported size %d" % dst.size)
     return e, []
 
+# Mix
+#
+
+# SSE
+def pmaddwd(ir, instr, dst, src):
+    sizedst = 32
+    sizesrc = 16
+    out = []
+    for start in xrange(0, dst.size, sizedst):
+        base = start
+        mul1 = src[base: base + sizesrc].signExtend(sizedst) * dst[base: base + sizesrc].signExtend(sizedst)
+        base += sizesrc
+        mul2 = src[base: base + sizesrc].signExtend(sizedst) * dst[base: base + sizesrc].signExtend(sizedst)
+        out.append(mul1 + mul2)
+    return [m2_expr.ExprAff(dst, m2_expr.ExprCompose(*out))], []
+
 
 # Comparisons
 #
@@ -4749,6 +4765,9 @@ mnemo_func = {'mov': mov,
               "pmulhq": pmulhq,
               "pmuludq": pmuludq,
 
+              # Mix
+              # SSE
+              "pmaddwd": pmaddwd,
 
               # Arithmetic (floating-point)
               #
diff --git a/test/arch/x86/arch.py b/test/arch/x86/arch.py
index 93ab4a48..3d9fd31f 100644
--- a/test/arch/x86/arch.py
+++ b/test/arch/x86/arch.py
@@ -3049,6 +3049,11 @@ reg_tests = [
      "0ff4d9"),
     (m32, "00000000    PMULUDQ    XMM0, XMM6",
      "660ff4c6"),
+
+    (m32, "00000000    PMADDWD    MM3, MM1",
+     "0ff5d9"),
+    (m32, "00000000    PMADDWD    XMM0, XMM6",
+     "660ff5c6"),
 ]