about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorserpilliere <devnull@localhost>2012-04-03 08:41:36 +0200
committerserpilliere <devnull@localhost>2012-04-03 08:41:36 +0200
commit0720dbf62ec5e001c10f80b2e19c521d976fdef5 (patch)
tree0129db37e384a9d2e7e2d36884c8d4a9a7774b3b
parent2dc7f3aedd83aa9e30d7a2674bab6e9d2c546c56 (diff)
downloadfocaccia-miasm-0720dbf62ec5e001c10f80b2e19c521d976fdef5.tar.gz
focaccia-miasm-0720dbf62ec5e001c10f80b2e19c521d976fdef5.zip
ia32_arch: add lahf/sahf
-rw-r--r--miasm/arch/ia32_sem.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/miasm/arch/ia32_sem.py b/miasm/arch/ia32_sem.py
index 1b38680c..ac3ce1cf 100644
--- a/miasm/arch/ia32_sem.py
+++ b/miasm/arch/ia32_sem.py
@@ -2115,6 +2115,24 @@ def lss(info, a, b):
                                  size=16)))
     return e
 
+def lahf(info):
+    e = []
+    args = []
+    regs = [cf, ExprInt(uint32(1)), pf, ExprInt(uint32(0)), af, ExprInt(uint32(0)), zf, nf]
+    for i in xrange(len(regs)):
+        args.append(ExprSliceTo(regs[i],i, i+1))
+    e.append(ExprAff(eax[8:16], ExprCompose(args)))
+    return e
+
+def sahf(info):
+    tmp = eax[8:16]
+    e = []
+    e.append(ExprAff(cf, ExprSlice(tmp, 0, 1)))
+    e.append(ExprAff(pf, ExprSlice(tmp, 2, 3)))
+    e.append(ExprAff(af, ExprSlice(tmp, 4, 5)))
+    e.append(ExprAff(zf, ExprSlice(tmp, 6, 7)))
+    e.append(ExprAff(nf, ExprSlice(tmp, 7, 8)))
+    return e
 mnemo_func = {'mov': mov,
               'xchg': xchg,
               'movzx': movzx,
@@ -2288,6 +2306,8 @@ mnemo_func = {'mov': mov,
               "lds": lds,
               "les": les,
               "lss": lss,
+              "lahf": lahf,
+              "sahf": sahf,
               }