about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2015-11-16 17:39:05 +0100
committerAjax <commial@gmail.com>2015-11-17 10:39:42 +0100
commit2c8a9bf7e51d6c320f711c7b2ba245ab4e922575 (patch)
tree6147c5e58bcfbfae7c3b7e456967bbe620109f78
parent3defdfa9bfcd0ed80bdafe7de640da78bd4b8693 (diff)
downloadmiasm-2c8a9bf7e51d6c320f711c7b2ba245ab4e922575.tar.gz
miasm-2c8a9bf7e51d6c320f711c7b2ba245ab4e922575.zip
x86/sem: add cmpxchg8b
Diffstat (limited to '')
-rw-r--r--miasm2/arch/x86/sem.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index 0bcc8953..c6a4c23c 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -29,6 +29,9 @@ import struct
 
 # SemBuilder context
 ctx = {'mRAX': mRAX,
+       'mRBX': mRBX,
+       'mRCX': mRCX,
+       'mRDX': mRDX,
        'zf': zf,
        }
 sbuild = SemBuilder(ctx)
@@ -2967,6 +2970,18 @@ def cmpxchg(arg1, arg2):
         arg1 = arg2
 
 
+@sbuild.parse
+def cmpxchg8b(arg1):
+    accumulator = {mRAX[instr.mode], mRDX[instr.mode]}
+    if accumulator - arg1:
+        zf = i1(0)
+        mRAX[instr.mode] = arg1[:instr.mode]
+        mRDX[instr.mode] = arg1[instr.mode:]
+    else:
+        zf = i1(1)
+        arg1 = {mRBX[instr.mode], mRCX[instr.mode]}
+
+
 def lds(ir, instr, a, b):
     e = []
     e.append(m2_expr.ExprAff(a, m2_expr.ExprMem(b.arg, size=a.size)))
@@ -3698,6 +3713,7 @@ mnemo_func = {'mov': mov,
               'out': l_out,
               "sysenter": l_sysenter,
               "cmpxchg": cmpxchg,
+              "cmpxchg8b": cmpxchg8b,
               "lds": lds,
               "les": les,
               "lss": lss,