diff python/target.py @ 235:ff40407c0240

Fix ALabel to Label
author Windel Bouwman
date Mon, 15 Jul 2013 17:20:37 +0200
parents 83781bd10fdb
children 8786811a5a59
line wrap: on
line diff
--- a/python/target.py	Sun Jul 14 19:29:21 2013 +0200
+++ b/python/target.py	Mon Jul 15 17:20:37 2013 +0200
@@ -1,4 +1,4 @@
-from asmnodes import ASymbol, AInstruction, ALabel, ANumber
+from asmnodes import ASymbol, AInstruction, ANumber
 from ppci import CompilerError
 
 """
@@ -33,6 +33,27 @@
         if type(vop) is ANumber and vop.number < 8:
             return cls(vop.number)
 
+class Imm32:
+    def __init__(self, imm):
+        assert imm < 2**32
+        assert type(imm) is int
+        self.imm = imm
+
+    @classmethod
+    def Create(cls, vop):
+        if type(vop) is ANumber and vop.number < 2**32:
+            return cls(vop.number)
+
+
+class LabelRef:
+    def __init__(self, name):
+        self.name = name
+
+    @classmethod
+    def Create(cls, vop):
+        if type(vop) is ASymbol:
+            return cls(vop.name)
+
 class Instruction:
     def encode(self):
         raise NotImplementedError('Instruction {0} has no encode yet, TODO'.format(type(self)))
@@ -49,25 +70,39 @@
         self.name = name
         self.address = 0
 
+    def __repr__(self):
+        return '{}:'.format(self.name)
+
+    def encode(self):
+        return bytes()
+
     @classmethod
     def Create(cls, vop):
         if type(vop) is ASymbol:
             name = vop.name
             return cls(name)
 
+
 class Comment(PseudoInstruction):
     def __init__(self, txt):
         self.txt = txt
+    def encode(self):
+        return bytes()
     def __repr__(self):
         return '; {}'.format(self.txt)
 
+
 class Alignment(PseudoInstruction):
     def __init__(self, a):
         self.align = a
+
+    def __repr__(self):
+        return 'ALIGN({})'.format(self.align)
+
     def encode(self):
         pad = []
         address = self.address
-        while (address % i.align) != 0:
+        while (address % self.align) != 0:
             address += 1
             pad.append(0)
         return bytes(pad)