about summary refs log tree commit diff stats
path: root/miasm/expression/expression_helper.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--miasm/expression/expression_helper.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/miasm/expression/expression_helper.py b/miasm/expression/expression_helper.py
index c6bcfa8e..99f8331e 100644
--- a/miasm/expression/expression_helper.py
+++ b/miasm/expression/expression_helper.py
@@ -231,6 +231,12 @@ def expr_simp_w(e):
             args0 = args[0].args[0]
             args = [args0, ExprInt(args1)]
 
+        if op in ['+'] and isinstance(args[1], ExprInt) and isinstance(args[0], ExprOp) and args[0].op in ['+', '-'] and isinstance(args[0].args[0], ExprInt):
+            op = args[0].op
+            args1 = args[0].args[0].arg + args[1].arg
+            args0 = args[0].args[1]
+            args = [ExprInt(args1), args0]
+
         #0 - (a-b) => b-a
         if op == '-' and isinstance(args[0], ExprInt) and args[0].arg == 0 and isinstance(args[1], ExprOp) and args[1].op == "-":
             return expr_simp(args[1].args[1] - args[1].args[0])