Mercurial > lcfOS
comparison python/ppci/target/arm/frame.py @ 354:5477e499b039
Added some sort of string functionality
author | Windel Bouwman |
---|---|
date | Thu, 13 Mar 2014 18:59:06 +0100 |
parents | b8ad45b3a573 |
children | c49459768aaa |
comparison
equal
deleted
inserted
replaced
353:b8ad45b3a573 | 354:5477e499b039 |
---|---|
50 self.locVars[lvar] = self.stacksize | 50 self.locVars[lvar] = self.stacksize |
51 self.stacksize = self.stacksize + 4 | 51 self.stacksize = self.stacksize + 4 |
52 return self.locVars[lvar] | 52 return self.locVars[lvar] |
53 | 53 |
54 def add_constant(self, value): | 54 def add_constant(self, value): |
55 assert type(value) in [int, bytes] | |
55 lab_name = '{}_literal_{}'.format(self.name, len(self.constants)) | 56 lab_name = '{}_literal_{}'.format(self.name, len(self.constants)) |
56 self.constants.append((lab_name, value)) | 57 self.constants.append((lab_name, value)) |
57 return lab_name | 58 return lab_name |
58 | 59 |
59 def prologue(self): | 60 def prologue(self): |
81 | 82 |
82 # Add constant literals: | 83 # Add constant literals: |
83 for ln, v in self.constants: | 84 for ln, v in self.constants: |
84 if isinstance(v, int): | 85 if isinstance(v, int): |
85 post.extend([Label(ln), Dcd(v)]) | 86 post.extend([Label(ln), Dcd(v)]) |
86 elif isinstance(v, str): | 87 elif isinstance(v, bytes): |
87 post.extend([Label(ln), Dcd(len(v))]) | 88 post.append(Label(ln)) |
88 for c in v: | 89 for c in v: |
89 post.append(Db(ord(c))) | 90 post.append(Db(c)) |
90 post.append(Alignment(4)) # Align at 4 bytes | 91 post.append(Alignment(4)) # Align at 4 bytes |
91 else: | 92 else: |
92 raise Exception() | 93 raise Exception('Constant of type {} not supported'.format(v)) |
93 return post | 94 return post |
94 | 95 |
95 def EntryExitGlue3(self): | 96 def EntryExitGlue3(self): |
96 """ | 97 """ |
97 Add code for the prologue and the epilogue. Add a label, the | 98 Add code for the prologue and the epilogue. Add a label, the |