Mercurial > lcfOS
diff python/ppci/target/arm/frame.py @ 353:b8ad45b3a573
Started with strings
author | Windel Bouwman |
---|---|
date | Sun, 09 Mar 2014 18:49:10 +0100 |
parents | 3bb7dcfe5529 |
children | 5477e499b039 |
line wrap: on
line diff
--- a/python/ppci/target/arm/frame.py Sun Mar 09 11:55:55 2014 +0100 +++ b/python/ppci/target/arm/frame.py Sun Mar 09 18:49:10 2014 +0100 @@ -1,7 +1,7 @@ from ... import ir from ..basetarget import Label, Alignment from ...irmach import AbstractInstruction, Frame -from .instructions import Dcd, Add, Sub, Push, Pop, Mov +from .instructions import Dcd, Add, Sub, Push, Pop, Mov, Db from .registers import R0, R1, R2, R3, R4, R5, R6, R7, R8, R11, LR, PC, SP @@ -51,7 +51,7 @@ self.stacksize = self.stacksize + 4 return self.locVars[lvar] - def addConstant(self, value): + def add_constant(self, value): lab_name = '{}_literal_{}'.format(self.name, len(self.constants)) self.constants.append((lab_name, value)) return lab_name @@ -78,9 +78,18 @@ Pop({PC, R11}), Alignment(4) # Align at 4 bytes ] + # Add constant literals: for ln, v in self.constants: - post.extend([Label(ln), Dcd(v)]) + if isinstance(v, int): + post.extend([Label(ln), Dcd(v)]) + elif isinstance(v, str): + post.extend([Label(ln), Dcd(len(v))]) + for c in v: + post.append(Db(ord(c))) + post.append(Alignment(4)) # Align at 4 bytes + else: + raise Exception() return post def EntryExitGlue3(self):