about summary refs log tree commit diff stats
path: root/miasm2/arch/x86/sem.py
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2018-02-09 09:49:15 +0100
committerAjax <commial@gmail.com>2018-02-09 17:36:31 +0100
commit60a82ffba739af32ffadd56b16e755a5ea410009 (patch)
tree65b27072106a08083f43b681527cd5d8ea3b0de6 /miasm2/arch/x86/sem.py
parentdf4b2904c00bca0d15062493666ce50ff0b56632 (diff)
downloadmiasm-60a82ffba739af32ffadd56b16e755a5ea410009.tar.gz
miasm-60a82ffba739af32ffadd56b16e755a5ea410009.zip
Add PADDSB/PADDSW instruction
NP 0F EC /r PADDSB mm, mm/m64
66 0F EC /r PADDSB xmm1, xmm2/m128
NP 0F ED /r PADDSW mm, mm/m64
66 0F ED /r PADDSW xmm1, xmm2/m128
Diffstat (limited to '')
-rw-r--r--miasm2/arch/x86/sem.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index 97373abf..a30bcdc9 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -4347,6 +4347,16 @@ def _saturation_add(expr):
     return m2_expr.ExprCond((arg1 + arg2).msb(), m2_expr.ExprInt(-1, expr.size),
                             expr)
 
+def _saturation_add_signed(expr):
+    assert expr.is_op("+") and len(expr.args) == 2
+
+    # Compute the substraction on two more bits, see _saturation_add_unsigned
+
+    arg1 = expr.args[0].signExtend(expr.size + 2)
+    arg2 = expr.args[1].signExtend(expr.size + 2)
+
+    return _signed_saturation(arg1 + arg2, expr.size)
+
 
 # Saturate SSE operations
 
@@ -4356,6 +4366,8 @@ paddusb = vec_vertical_instr('+', 8, _saturation_add)
 paddusw = vec_vertical_instr('+', 16, _saturation_add)
 psubsb = vec_vertical_instr('-', 8, _saturation_sub_signed)
 psubsw = vec_vertical_instr('-', 16, _saturation_sub_signed)
+paddsb = vec_vertical_instr('+', 8, _saturation_add_signed)
+paddsw = vec_vertical_instr('+', 16, _saturation_add_signed)
 
 
 mnemo_func = {'mov': mov,
@@ -4881,6 +4893,8 @@ mnemo_func = {'mov': mov,
               "paddusw": paddusw,
               "psubsb": psubsb,
               "psubsw": psubsw,
+              "paddsb": paddsb,
+              "paddsw": paddsw,
 
               "smsw": smsw,