about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2018-02-09 10:23:14 +0100
committerAjax <commial@gmail.com>2018-02-09 17:36:31 +0100
commitb8bd5c0f24b786616b6f372f7f6dfad43438ab01 (patch)
tree58aef70ebfa87e197836cb739fd32aa3bb12280f
parent950bb44e32c5bed4dba7ef77949db86b4d36c5ca (diff)
downloadmiasm-b8bd5c0f24b786616b6f372f7f6dfad43438ab01.tar.gz
miasm-b8bd5c0f24b786616b6f372f7f6dfad43438ab01.zip
Add PMULUDQ instruction
NP 0F F4 /r PMULUDQ mm1, mm2/m64
66 0F F4 /r PMULUDQ xmm1, xmm2/m128
-rw-r--r--miasm2/arch/x86/arch.py4
-rw-r--r--miasm2/arch/x86/sem.py23
-rw-r--r--test/arch/x86/arch.py5
3 files changed, 32 insertions, 0 deletions
diff --git a/miasm2/arch/x86/arch.py b/miasm2/arch/x86/arch.py
index aaf877fe..839487e8 100644
--- a/miasm2/arch/x86/arch.py
+++ b/miasm2/arch/x86/arch.py
@@ -4488,6 +4488,10 @@ addop("pmulhw", [bs8(0x0f), bs8(0xe5), no_xmm_pref] +
       rmmod(mm_reg, rm_arg_mm_m64))
 addop("pmulhw", [bs8(0x0f), bs8(0xe5), pref_66] +
       rmmod(xmm_reg, rm_arg_xmm_m128))
+addop("pmuludq", [bs8(0x0f), bs8(0xf4), no_xmm_pref] +
+      rmmod(mm_reg, rm_arg_mm_m64))
+addop("pmuludq", [bs8(0x0f), bs8(0xf4), pref_66] +
+      rmmod(xmm_reg, rm_arg_xmm_m128))
 
 
 addop("psubusb", [bs8(0x0f), bs8(0xd8), no_xmm_pref] +
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index 5beedede..d73eac96 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -3418,6 +3418,7 @@ def _min_max(expr, signed):
         expr.args[0],
     )
 
+
 # Integer arithmetic
 #
 
@@ -3456,6 +3457,27 @@ pmulhw = vec_vertical_instr('*', 16, lambda x: _keep_mul_high(x, signed=True))
 pmulhd = vec_vertical_instr('*', 32, lambda x: _keep_mul_high(x, signed=True))
 pmulhq = vec_vertical_instr('*', 64, lambda x: _keep_mul_high(x, signed=True))
 
+def pmuludq(ir, instr, dst, src):
+    e = []
+    if dst.size == 64:
+        e.append(m2_expr.ExprAff(
+            dst,
+            src[:32].zeroExtend(64) * dst[:32].zeroExtend(64)
+        ))
+    elif dst.size == 128:
+        e.append(m2_expr.ExprAff(
+            dst[:64],
+            src[:32].zeroExtend(64) * dst[:32].zeroExtend(64)
+        ))
+        e.append(m2_expr.ExprAff(
+            dst[64:],
+            src[64:96].zeroExtend(64) * dst[64:96].zeroExtend(64)
+        ))
+    else:
+        raise RuntimeError("Unsupported size %d" % dst.size)
+    return e, []
+
+
 # Comparisons
 #
 
@@ -4725,6 +4747,7 @@ mnemo_func = {'mov': mov,
               "pmulhw": pmulhw,
               "pmulhd": pmulhd,
               "pmulhq": pmulhq,
+              "pmuludq": pmuludq,
 
 
               # Arithmetic (floating-point)
diff --git a/test/arch/x86/arch.py b/test/arch/x86/arch.py
index cc0a0a93..93ab4a48 100644
--- a/test/arch/x86/arch.py
+++ b/test/arch/x86/arch.py
@@ -3044,6 +3044,11 @@ reg_tests = [
      "0feed9"),
     (m32, "00000000    PMAXSW     XMM0, XMM6",
      "660feec6"),
+
+    (m32, "00000000    PMULUDQ    MM3, MM1",
+     "0ff4d9"),
+    (m32, "00000000    PMULUDQ    XMM0, XMM6",
+     "660ff4c6"),
 ]