about summary refs log tree commit diff stats
path: root/test/expression/simplifications.py
diff options
context:
space:
mode:
authorserpilliere <devnull@localhost>2014-06-12 22:14:26 +0200
committerserpilliere <devnull@localhost>2014-06-12 22:14:26 +0200
commit24b677448d875d408c1fff038bed27d2b223a3da (patch)
tree06e95a70a7ae014fde33364ae67c3f785d3c48a3 /test/expression/simplifications.py
parent1b69d0f86c340febf781d9284a87e447b40ee3ba (diff)
parenta635b0185b9fe26453ceedb5d56aa9d59503b695 (diff)
downloadmiasm-24b677448d875d408c1fff038bed27d2b223a3da.tar.gz
miasm-24b677448d875d408c1fff038bed27d2b223a3da.zip
merge; fix x86 ror/rol
rol ror mask shifter in semantic instead of in expr_simpl
Diffstat (limited to 'test/expression/simplifications.py')
-rw-r--r--test/expression/simplifications.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/test/expression/simplifications.py b/test/expression/simplifications.py
index 19f43d6e..ac6b796d 100644
--- a/test/expression/simplifications.py
+++ b/test/expression/simplifications.py
@@ -3,7 +3,8 @@
 #
 from pdb import pm
 from miasm2.expression.expression import *
-from miasm2.expression.simplifications import expr_simp
+from miasm2.expression.simplifications import expr_simp, ExpressionSimplifier
+from miasm2.expression.simplifications_cond import ExprOp_inf_signed, ExprOp_inf_unsigned
 
 # Define example objects
 a = ExprId('a')
@@ -173,6 +174,36 @@ for e, e_check in to_test[:]:
         raise ValueError(
             'bug in expr_simp simp(%s) is %s and should be %s' % (e, e_new, e_check))
 
+# Test conds
+
+to_test = [
+    (((a - b) ^ ((a ^ b) & ((a - b) ^ a))).msb(),
+     ExprOp_inf_signed(a, b)),
+    ((((a - b) ^ ((a ^ b) & ((a - b) ^ a))) ^ a ^ b).msb(),
+     ExprOp_inf_unsigned(a, b)),
+    (ExprOp_inf_unsigned(ExprInt32(-1), ExprInt32(3)), ExprInt1(0)),
+    (ExprOp_inf_signed(ExprInt32(-1), ExprInt32(3)), ExprInt1(1)),
+    (ExprOp_inf_unsigned(a, b) ^ (a ^ b).msb(), ExprOp_inf_signed(a, b)),
+    (ExprOp_inf_signed(a, b) ^ (a ^ b).msb(), ExprOp_inf_unsigned(a, b)),
+]
+
+expr_simp_cond = ExpressionSimplifier()
+expr_simp.enable_passes(ExpressionSimplifier.PASS_COND)
+
+
+for e, e_check in to_test[:]:
+    #
+    print "#" * 80
+    e_check = expr_simp(e_check)
+    # print str(e), str(e_check)
+    e_new = expr_simp(e)
+    print "original: ", str(e), "new: ", str(e_new)
+    rez = e_new == e_check
+    if not rez:
+        raise ValueError(
+            'bug in expr_simp simp(%s) is %s and should be %s' % (e, e_new, e_check))
+
+
 
 x = ExprId('x')
 y = ExprId('y')