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-01-26 17:40:46 +0100
committerAjax <commial@gmail.com>2018-01-26 17:47:05 +0100
commit343c04ffa9bae64d45d950909f038775963502a9 (patch)
treecb6ef542f1eaf580ba2d71dacd24afefbbf93a9a /miasm2/arch/x86/sem.py
parent185d42afb5a3a596bba05dd0ca79c9c45afc757f (diff)
downloadmiasm-343c04ffa9bae64d45d950909f038775963502a9.tar.gz
miasm-343c04ffa9bae64d45d950909f038775963502a9.zip
Add PALIGNR x86 instruction (asm & semantic)
Diffstat (limited to 'miasm2/arch/x86/sem.py')
-rw-r--r--miasm2/arch/x86/sem.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index 6f2c7947..b2403604 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -4133,6 +4133,26 @@ def bndmov(ir, instr, dst, src):
     # Implemented as a NOP, because BND side effects are not yet supported
     return [], []
 
+def palignr(ir, instr, dst, src, imm):
+    # dst.src >> imm * 8 [:dst.size]
+
+    shift = int(imm) * 8
+    if shift == 0:
+        result = src
+    elif shift == src.size:
+        result = dst
+    elif shift > src.size:
+        result = dst >> m2_expr.ExprInt(shift - src.size, dst.size)
+    else:
+        # shift < src.size
+        result = m2_expr.ExprCompose(
+            src[shift:],
+            dst[:shift],
+        )
+
+    return [m2_expr.ExprAff(dst, result)], []
+
+
 mnemo_func = {'mov': mov,
               'xchg': xchg,
               'movzx': movzx,
@@ -4569,6 +4589,7 @@ mnemo_func = {'mov': mov,
               "pslld": pslld,
               "psllq": psllq,
               "pslldq": pslldq,
+              "palignr": palignr,
 
               "pmaxub": pmaxub,
               "pmaxuw": pmaxuw,