diff options
| author | Ajax <commial@gmail.com> | 2015-11-16 13:55:01 +0100 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2015-11-16 14:02:39 +0100 |
| commit | a6c36a2db171f1aba2ea2d6fe9017e68f75cdf3e (patch) | |
| tree | 1d22571284d302ebbfc25771b1a8b35a7857115c /miasm2/arch/x86/sem.py | |
| parent | 733fcb7dc780f23a4cfda4d3ef721b11ee843cfb (diff) | |
| download | miasm-a6c36a2db171f1aba2ea2d6fe9017e68f75cdf3e.tar.gz miasm-a6c36a2db171f1aba2ea2d6fe9017e68f75cdf3e.zip | |
x86/sem: fix 'aas' factor code with 'aaa'
Diffstat (limited to '')
| -rw-r--r-- | miasm2/arch/x86/sem.py | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py index 27b2de82..a5f5d3b2 100644 --- a/miasm2/arch/x86/sem.py +++ b/miasm2/arch/x86/sem.py @@ -2637,7 +2637,10 @@ def aad(ir, instr, a): return e, [] -def aaa(ir, instr): +def _tpl_aaa(ir, instr, op): + """Templating for aaa, aas with operation @op + @op: operation to apply + """ e = [] r_al = mRAX[instr.mode][:8] r_ah = mRAX[instr.mode][8:16] @@ -2650,7 +2653,8 @@ def aaa(ir, instr): cond |= af & i1 to_add = m2_expr.ExprInt(0x106, size=r_ax.size) - new_ax = (r_ax + to_add) & m2_expr.ExprInt(0xff0f, size=r_ax.size) + new_ax = m2_expr.ExprOp(op, r_ax, to_add) & m2_expr.ExprInt(0xff0f, + size=r_ax.size) # set AL e.append(m2_expr.ExprAff(r_ax, m2_expr.ExprCond(cond, new_ax, r_ax))) e.append(m2_expr.ExprAff(af, cond)) @@ -2658,33 +2662,12 @@ def aaa(ir, instr): return e, [] -def aas(ir, instr, ): - e = [] - c = (mRAX[instr.mode][:8] & m2_expr.ExprInt8(0xf)) - m2_expr.ExprInt8(9) +def aaa(ir, instr): + return _tpl_aaa(ir, instr, "+") - c = m2_expr.ExprCond(c.msb(), - m2_expr.ExprInt1(0), - m2_expr.ExprInt1(1)) & \ - m2_expr.ExprCond(c, - m2_expr.ExprInt1(1), - m2_expr.ExprInt1(0)) - c |= af & m2_expr.ExprInt1(1) - # set AL - m_al = m2_expr.ExprCond(c, - (mRAX[instr.mode][:8] - m2_expr.ExprInt8(6)) & \ - m2_expr.ExprInt8(0xF), - mRAX[instr.mode][:8] & m2_expr.ExprInt8(0xF)) - m_ah = m2_expr.ExprCond(c, - mRAX[instr.mode][8:16] - m2_expr.ExprInt8(1), - mRAX[instr.mode][8:16]) - - e.append(m2_expr.ExprAff(mRAX[instr.mode], m2_expr.ExprCompose([ - (m_al, 0, 8), (m_ah, 8, 16), - (mRAX[instr.mode][16:], 16, mRAX[instr.mode].size)]))) - e.append(m2_expr.ExprAff(af, c)) - e.append(m2_expr.ExprAff(cf, c)) - return e, [] +def aas(ir, instr): + return _tpl_aaa(ir, instr, "-") def bsr_bsf(ir, instr, a, b, op_name): |