diff 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
line wrap: on
line diff
--- a/python/ppci/target/arm/frame.py	Sun Mar 09 18:49:10 2014 +0100
+++ b/python/ppci/target/arm/frame.py	Thu Mar 13 18:59:06 2014 +0100
@@ -52,6 +52,7 @@
         return self.locVars[lvar]
 
     def add_constant(self, value):
+        assert type(value) in [int, bytes]
         lab_name = '{}_literal_{}'.format(self.name, len(self.constants))
         self.constants.append((lab_name, value))
         return lab_name
@@ -83,13 +84,13 @@
         for ln, v in self.constants:
             if isinstance(v, int):
                 post.extend([Label(ln), Dcd(v)])
-            elif isinstance(v, str):
-                post.extend([Label(ln), Dcd(len(v))])
+            elif isinstance(v, bytes):
+                post.append(Label(ln))
                 for c in v:
-                    post.append(Db(ord(c)))
+                    post.append(Db(c))
                 post.append(Alignment(4))   # Align at 4 bytes
             else:
-                raise Exception()
+                raise Exception('Constant of type {} not supported'.format(v))
         return post
 
     def EntryExitGlue3(self):