# HG changeset patch # User Windel Bouwman # Date 1373384572 -7200 # Node ID 85c8105318e766c51fc2bb189855aada7e7c2af1 # Parent c3f1ce8b638fe0621d29e096fd95ee6f1ed42e5e Fixup of parser diff -r c3f1ce8b638f -r 85c8105318e7 python/cortexm3.py --- 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