about summary refs log tree commit diff stats
path: root/miasm2/arch/x86/sem.py
diff options
context:
space:
mode:
Diffstat (limited to 'miasm2/arch/x86/sem.py')
-rw-r--r--miasm2/arch/x86/sem.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index c6a6d783..36d8e618 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -635,7 +635,9 @@ def pop(ir, instr, a):
     if not s in [16, 32, 64]:
         raise ValueError('bad size stacker!')
     new_esp = mRSP[instr.mode][:s] + ExprInt_fromsize(s, off / 8)
-    e.append(ExprAff(mRSP[instr.mode][:s], new_esp))
+    # don't generate ESP incrementation on POP ESP
+    if a != ir.sp:
+        e.append(ExprAff(mRSP[instr.mode][:s], new_esp))
     # XXX FIX XXX for pop [esp]
     if isinstance(a, ExprMem):
         a = a.replace_expr({mRSP[instr.mode]: new_esp})
@@ -2003,6 +2005,9 @@ def fnstenv(ir, instr, a):
                                ])
 
     s = instr.mode
+    # The behaviour in 64bit is identical to 64 bit
+    # This will truncate addresses
+    s = min(32, s)
     ad = ExprMem(a.arg, size=16)
     e.append(ExprAff(ad, float_control))
     ad = ExprMem(a.arg + ExprInt_from(a.arg, s / 8 * 1), size=16)