diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2018-09-08 19:16:21 +0200 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2018-09-10 08:20:48 +0200 |
| commit | 9358bf5ad2113fb2d1c8c11e3da59fe8c0c1be13 (patch) | |
| tree | 21d7ff201f93776c487d12934b0971d86d7797c9 /miasm2/arch/x86/sem.py | |
| parent | 8e6b39d80e9f8db8389bd2a8106d0f64b91c19e9 (diff) | |
| download | miasm-9358bf5ad2113fb2d1c8c11e3da59fe8c0c1be13.tar.gz miasm-9358bf5ad2113fb2d1c8c11e3da59fe8c0c1be13.zip | |
X86: fix aam sem
Diffstat (limited to '')
| -rw-r--r-- | miasm2/arch/x86/sem.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py index 0cb9f3e2..f87c42cf 100644 --- a/miasm2/arch/x86/sem.py +++ b/miasm2/arch/x86/sem.py @@ -3115,15 +3115,28 @@ def das(_, instr): return e, [] -def aam(_, instr, src): +def aam(ir, instr, src): e = [] - tempAL = mRAX[instr.mode][0:8] - newEAX = m2_expr.ExprCompose(m2_expr.ExprOp("umod", tempAL, src), - m2_expr.ExprOp("udiv", tempAL, src), - mRAX[instr.mode][16:]) - e += [m2_expr.ExprAff(mRAX[instr.mode], newEAX)] - e += update_flag_arith(newEAX) - e.append(m2_expr.ExprAff(af, m2_expr.ExprInt(0, 1))) + assert src.is_int() + + value = int(src) + if value: + tempAL = mRAX[instr.mode][0:8] + newEAX = m2_expr.ExprCompose( + m2_expr.ExprOp("umod", tempAL, src), + m2_expr.ExprOp("udiv", tempAL, src), + mRAX[instr.mode][16:] + ) + e += [m2_expr.ExprAff(mRAX[instr.mode], newEAX)] + e += update_flag_arith(newEAX) + e.append(m2_expr.ExprAff(af, m2_expr.ExprInt(0, 1))) + else: + e.append( + m2_expr.ExprAff( + exception_flags, + m2_expr.ExprInt(EXCEPT_DIV_BY_ZERO, exception_flags.size) + ) + ) return e, [] |