about summary refs log tree commit diff stats
path: root/miasm2/core/cpu.py
diff options
context:
space:
mode:
authorserpilliere <devnull@localhost>2014-07-09 11:17:36 +0200
committerserpilliere <devnull@localhost>2014-07-09 11:17:36 +0200
commit92d3b2d51df594d9bc921262138c9255e4bf586b (patch)
tree9f9d259ce7a28064346e20b4acd78e50ef506cd6 /miasm2/core/cpu.py
parent1f5c7d7fa7308589b9aa2fe1f441a010e2d57f37 (diff)
downloadmiasm-92d3b2d51df594d9bc921262138c9255e4bf586b.tar.gz
miasm-92d3b2d51df594d9bc921262138c9255e4bf586b.zip
Core/parse: allow the use of labels in data declaration
Ex:
toto:
.long main - toto
.long main ^ toto + 2
Diffstat (limited to 'miasm2/core/cpu.py')
-rw-r--r--miasm2/core/cpu.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/miasm2/core/cpu.py b/miasm2/core/cpu.py
index b1034327..41e5b4f6 100644
--- a/miasm2/core/cpu.py
+++ b/miasm2/core/cpu.py
@@ -161,10 +161,18 @@ def ast_parse_op(t):
             return ExprOp(t[0], t[1])
     if len(t) == 3:
         args = [t[0], t[2]]
+        if t[1] == '-':
+            # a - b => a + (-b)
+            t[1] = '+'
+            t[2] = - t[2]
         return ExprOp(t[1], t[0], t[2])
     t = t[::-1]
     while len(t) >= 3:
         o1, op, o2 = t.pop(), t.pop(), t.pop()
+        if op == '-':
+            # a - b => a + (-b)
+            op = '+'
+            o2 = - o2
         e = ExprOp(op, o1, o2)
         t.append(e)
     if len(t) != 1: