about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorserpilliere <serpilliere@users.noreply.github.com>2017-07-24 09:33:16 +0200
committerGitHub <noreply@github.com>2017-07-24 09:33:16 +0200
commitc131b203e3389a652ea14231a4528b6cddb07067 (patch)
treefb4192280244f5c0db940f312c9617f8dfcefd3c
parentdd55c95de47359529a2d9115425b9efdc2233b4b (diff)
parentf01c3f1c6d233c30b3c16deeda4d5b0114ae47e7 (diff)
downloadmiasm-c131b203e3389a652ea14231a4528b6cddb07067.tar.gz
miasm-c131b203e3389a652ea14231a4528b6cddb07067.zip
Merge pull request #587 from commial/fix/x86-movsd
x86: fix MOVSD semantic
-rw-r--r--miasm2/arch/x86/sem.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index b3dfb3ef..12f2ef2a 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -1775,14 +1775,18 @@ def movs(ir, instr, size):
 
 
 def movsd(_, instr, dst, src):
-    e = []
-    if isinstance(dst, m2_expr.ExprId) and isinstance(src, m2_expr.ExprMem):
-        src = m2_expr.ExprMem(src.arg, dst.size)
-    elif isinstance(dst, m2_expr.ExprMem) and isinstance(src, m2_expr.ExprId):
-        dst = m2_expr.ExprMem(dst.arg, src.size)
-
-    e.append(m2_expr.ExprAff(dst, src))
-    return e, []
+    # 64 bits access
+    if dst.is_id() and src.is_id():
+        src = src[:64]
+        dst = dst[:64]
+    elif dst.is_mem() and src.is_id():
+        dst = m2_expr.ExprMem(dst.arg, 64)
+        src = src[:64]
+    else:
+        src = m2_expr.ExprMem(src.arg, 64)
+        # Erase dst high bits
+        src = src.zeroExtend(dst.size)
+    return [m2_expr.ExprAff(dst, src)], []
 
 
 def movsd_dispatch(ir, instr, dst=None, src=None):