diff options
| author | serpilliere <devnull@localhost> | 2014-07-09 11:17:36 +0200 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2014-07-09 11:17:36 +0200 |
| commit | 92d3b2d51df594d9bc921262138c9255e4bf586b (patch) | |
| tree | 9f9d259ce7a28064346e20b4acd78e50ef506cd6 /miasm2/core/cpu.py | |
| parent | 1f5c7d7fa7308589b9aa2fe1f441a010e2d57f37 (diff) | |
| download | miasm-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.py | 8 |
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: |