about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2015-11-13 11:29:21 +0100
committerAjax <commial@gmail.com>2015-11-13 11:29:21 +0100
commitee74c4a2b6edbb8f0241f3cc9c64333c9d3bcbf7 (patch)
tree4004d6db91172b9f6326bb998a085999ff67f0b1
parent34a23404e492a23d243742e55fd0247a0b7ef592 (diff)
downloadmiasm-ee74c4a2b6edbb8f0241f3cc9c64333c9d3bcbf7.tar.gz
miasm-ee74c4a2b6edbb8f0241f3cc9c64333c9d3bcbf7.zip
x86/sem: use _rotate_tpl for RCR
-rw-r--r--miasm2/arch/x86/sem.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index 9b961de8..d0a18897 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -415,11 +415,12 @@ def get_shift(a, b):
     shift = expr_simp(shift)
     return shift
 
-def _rotate_tpl(ir, instr, a, b, op, op_cf=None):
+def _rotate_tpl(ir, instr, a, b, op, op_cf=None, left=False):
     """Template for generate rotater with operation @op
     A temporary basic block is generated to handle 0-rotate
     @op: operation to execute
     @op_cf (optional): operation to use for carry flag. If not set, use @op
+    @left (optional): indicates a left rotate if set, default is False
     """
     if op_cf is None:
         op_cf = op
@@ -478,21 +479,11 @@ def l_ror(ir, instr, a, b):
 
 
 def rcl(ir, instr, a, b):
-    return _rotate_tpl(ir, instr, a, b, '<<<c_rez', '<<<c_cf')
+    return _rotate_tpl(ir, instr, a, b, '<<<c_rez', '<<<c_cf', left=True)
 
 
 def rcr(ir, instr, a, b):
-    e = []
-    shifter = get_shift(a, b)
-    c = m2_expr.ExprOp('>>>c_rez', a, shifter, cf.zeroExtend(a.size))
-    new_cf = m2_expr.ExprOp('>>>c_cf', a, shifter, cf.zeroExtend(a.size))[:1]
-
-    e.append(m2_expr.ExprAff(cf, new_cf))
-    # hack (only valid if b=1)
-    e.append(m2_expr.ExprAff(of, (a ^ c).msb()))
-    e.append(m2_expr.ExprAff(a, c))
-
-    return e, []
+    return _rotate_tpl(ir, instr, a, b, '>>>c_rez', '>>>c_cf')
 
 
 def _shift_tpl(op, ir, instr, a, b, c=None, op_inv=None, left=False):