diff python/ppci/target/arm/instructions.py @ 364:c49459768aaa

Work on globals
author Windel Bouwman
date Wed, 19 Mar 2014 20:24:03 +0100
parents c05ab629976a
children 98ff43cfdd36
line wrap: on
line diff
--- a/python/ppci/target/arm/instructions.py	Sun Mar 16 11:28:47 2014 +0100
+++ b/python/ppci/target/arm/instructions.py	Wed Mar 19 20:24:03 2014 +0100
@@ -1,5 +1,5 @@
 
-from ..basetarget import Instruction
+from ..basetarget import Instruction, LabelAddress
 from ...bitfun import rotate_left
 
 from .token import ArmToken
@@ -31,17 +31,30 @@
         assert isinstance(v, int)
         self.v = v
 
-    def __repr__(self):
-        return 'DCD {}'.format(hex(self.v))
-
 
-class Dcd(ConstantData):
+class Dcd(ArmInstruction):
+    def __init__(self, v):
+        super().__init__()
+        assert isinstance(v, int) or isinstance(v, LabelAddress)
+        self.v = v
+
     def encode(self):
-        self.token[0:32] = self.v
+        if type(self.v) is int:
+            self.token[0:32] = self.v
+        else:
+            self.token[0:32] = 0
         return self.token.encode()
 
+    def relocations(self):
+        if type(self.v) is LabelAddress:
+            return [(self.v.name, 'absaddr32')]
+        return []
+
     def __repr__(self):
-        return 'DCD {}'.format(hex(self.v))
+        if type(self.v) is int:
+            return 'DCD {}'.format(hex(self.v))
+        else:
+            return 'DCD ={}'.format(self.v.name)
 
 
 class Db(ConstantData):