about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--miasm2/arch/x86/sem.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index d0a18897..d8648644 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -429,11 +429,13 @@ def _rotate_tpl(ir, instr, a, b, op, op_cf=None, left=False):
     res = m2_expr.ExprOp(op, a, shifter, cf.zeroExtend(a.size))
     new_cf = m2_expr.ExprOp(op_cf, a, shifter, cf.zeroExtend(a.size))[:1]
 
+    new_of = m2_expr.ExprCond(b - m2_expr.ExprInt(1, size=b.size),
+                              m2_expr.ExprInt(0, size=of.size),
+                              res.msb() ^ new_cf if left else (a ^ res).msb())
     # Build basic blocks
     e_do = [
         m2_expr.ExprAff(cf, new_cf),
-        # hack (only valid if b=1)
-        m2_expr.ExprAff(of, res.msb() ^ new_cf),
+        m2_expr.ExprAff(of, new_of),
         m2_expr.ExprAff(a, res),
     ]