changeset 223:85c8105318e7

Fixup of parser
author Windel Bouwman
date Tue, 09 Jul 2013 17:42:52 +0200
parents c3f1ce8b638f
children 5af52987f5bd
files python/cortexm3.py
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/python/cortexm3.py	Tue Jul 09 17:36:31 2013 +0200
+++ b/python/cortexm3.py	Tue Jul 09 17:42:52 2013 +0200
@@ -98,6 +98,25 @@
                 return
             return cls(getRegNum(basereg.num), offset)
 
+class MemSpRel:
+    def __init__(self, offset):
+        assert offset % 4 == 0
+        self.offset = offset
+
+    def __repr__(self):
+        return '[sp, #{}]'.format(self.offset)
+
+    @classmethod
+    def Create(cls, vop):
+        if type(vop) is AUnop and vop.operation == '[]':
+            vop = vop.arg # descent
+            if type(vop) is ABinop and vop.op == '+':
+                if type(vop.arg1) is ASymbol and type(vop.arg2) is ANumber and vop.arg1.name.upper() == 'SP' and vop.arg2.number % 4 == 0:
+                    offset = vop.arg2.number
+                    return cls(offset)
+            elif type(vop) is ASymbol and vop.name.upper() == 'SP':
+                return cls(0)
+
 class MemoryOpReg8Imm5:
     def __init__(self, basereg, offset):
         assert type(basereg) is ArmReg