diff options
| author | serpilliere <fabrice.desclaux@cea.fr> | 2015-10-18 19:03:05 +0200 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2015-10-23 10:53:51 +0200 |
| commit | 04d8224885693f47c3c5cf0e4aa54587bf20f073 (patch) | |
| tree | 065207aa32f18cc90f609d6ee9968bfd42ada2eb /miasm2/arch/x86/sem.py | |
| parent | 6342f13ad2c341f01b1861f1ca8bb1209d5cf59c (diff) | |
| download | miasm-04d8224885693f47c3c5cf0e4aa54587bf20f073.tar.gz miasm-04d8224885693f47c3c5cf0e4aa54587bf20f073.zip | |
Arch/x86/sem: add fcomi/fcomip/fucomi/fucomip; fix fcomp
Diffstat (limited to '')
| -rw-r--r-- | miasm2/arch/x86/sem.py | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py index 6d678bfb..14df7a53 100644 --- a/miasm2/arch/x86/sem.py +++ b/miasm2/arch/x86/sem.py @@ -1886,32 +1886,44 @@ def ficom(ir, instr, a, b = None): -def fcomi(ir, instr, a): - raise NotImplementedError("Invalid emulation") - - -def fcomip(ir, instr, a): - raise NotImplementedError("Invalid emulation") - - -def fucomi(ir, instr, a): - raise NotImplementedError("Invalid emulation") - +def fcomi(ir, instr, a=None, b=None): + # TODO unordered float + if a is None and b is None: + a, b = float_st0, float_st1 + elif b is None: + b = a + a = float_st0 -def fucomip(ir, instr, a, b): e = [] - # XXX TODO add exception on NaN + e.append(m2_expr.ExprAff(cf, m2_expr.ExprOp('fcom_c0', a, b))) - #e.append(m2_expr.ExprAff(float_c1, m2_expr.ExprOp('fcom_c1', a, b))) e.append(m2_expr.ExprAff(pf, m2_expr.ExprOp('fcom_c2', a, b))) e.append(m2_expr.ExprAff(zf, m2_expr.ExprOp('fcom_c3', a, b))) - e += float_pop() + e.append(m2_expr.ExprAff(of, m2_expr.ExprInt1(0))) + e.append(m2_expr.ExprAff(nf, m2_expr.ExprInt1(0))) + e.append(m2_expr.ExprAff(af, m2_expr.ExprInt1(0))) e += set_float_cs_eip(instr) return e, [] +def fcomip(ir, instr, a=None, b=None): + e, extra = fcomi(ir, instr, a, b) + e += float_pop() + e += set_float_cs_eip(instr) + return e, extra + + +def fucomi(ir, instr, a=None, b=None): + # TODO unordered float + return fcomi(ir, instr, a, b) + +def fucomip(ir, instr, a=None, b=None): + # TODO unordered float + return fcomip(ir, instr, a, b) + + def fcomp(ir, instr, a=None, b=None): e, extra = fcom(ir, instr, a, b) e += float_pop() @@ -3667,6 +3679,8 @@ mnemo_func = {'mov': mov, 'fcomp': fcomp, 'fcompp': fcompp, 'ficomp': ficomp, + 'fcomi': fcomi, + 'fcomip': fcomip, 'nop': nop, 'fnop': nop, # XXX 'hlt': hlt, |