diff options
| author | Ajax <commial@gmail.com> | 2015-11-16 15:52:25 +0100 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2015-11-16 15:54:35 +0100 |
| commit | 1cc7b090c18ce3ed73ddf79bc478fdb7572cee1f (patch) | |
| tree | ed1087679f15db93cf592529612a11c87149aaff /miasm2/arch/x86/sem.py | |
| parent | a7cc8f8a392e6211b23a1778791f7d120d7e09f7 (diff) | |
| download | miasm-1cc7b090c18ce3ed73ddf79bc478fdb7572cee1f.tar.gz miasm-1cc7b090c18ce3ed73ddf79bc478fdb7572cee1f.zip | |
x86/sem: fix cmpxchg using a sembuilder
Diffstat (limited to '')
| -rw-r--r-- | miasm2/arch/x86/sem.py | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py index f1784692..0bcc8953 100644 --- a/miasm2/arch/x86/sem.py +++ b/miasm2/arch/x86/sem.py @@ -22,9 +22,17 @@ from miasm2.arch.x86.regs import * from miasm2.arch.x86.arch import mn_x86, repeat_mn, replace_regs from miasm2.expression.expression_helper import expr_cmps, expr_cmpu from miasm2.ir.ir import ir, irbloc +from miasm2.core.sembuilder import SemBuilder import math import struct + +# SemBuilder context +ctx = {'mRAX': mRAX, + 'zf': zf, + } +sbuild = SemBuilder(ctx) + # interrupt with eip update after instr EXCEPT_SOFT_BP = (1 << 1) EXCEPT_INT_XX = (1 << 2) @@ -2948,25 +2956,15 @@ def l_in(ir, instr, a, b): return e, [] -def cmpxchg(ir, instr, a, b): - e = [] - - c = mRAX[instr.mode][:a.size] - cond = c - a - e.append( - m2_expr.ExprAff(zf, - m2_expr.ExprCond(cond, - m2_expr.ExprInt_from(zf, 0), - m2_expr.ExprInt_from(zf, 1)))) - e.append(m2_expr.ExprAff(a, m2_expr.ExprCond(cond, - b, - a) - )) - e.append(m2_expr.ExprAff(c, m2_expr.ExprCond(cond, - a, - c) - )) - return e, [] +@sbuild.parse +def cmpxchg(arg1, arg2): + accumulator = mRAX[instr.mode][:arg1.size] + if (accumulator - arg1): + zf = i1(0) + accumulator = arg1 + else: + zf = i1(1) + arg1 = arg2 def lds(ir, instr, a, b): |