comparison python/ppci/assembler.py @ 337:b00219172a42

Added cool lm3s811 qemu project
author Windel Bouwman
date Thu, 20 Feb 2014 20:04:52 +0100
parents d1ecc493384e
children c7cc54c0dfdf
comparison
equal deleted inserted replaced
336:d1ecc493384e 337:b00219172a42
151 asmParser = Parser() 151 asmParser = Parser()
152 152
153 class Assembler: 153 class Assembler:
154 def __init__(self, target, stream): 154 def __init__(self, target, stream):
155 self.target = target 155 self.target = target
156 assert isinstance(target,Target)
156 self.stream = stream 157 self.stream = stream
157 self.restart() 158 self.restart()
158 self.p = asmParser 159 self.p = asmParser
159 160
160 # Top level interface: 161 # Top level interface:
187 self.parse_line(line) 188 self.parse_line(line)
188 self.assemble_aast() 189 self.assemble_aast()
189 190
190 def assemble_aast(self): 191 def assemble_aast(self):
191 """ Assemble a parsed asm line """ 192 """ Assemble a parsed asm line """
192 if not self.target:
193 raise CompilerError('Cannot assemble without target')
194 while self.stack: 193 while self.stack:
195 vi = self.stack.pop(0) 194 vi = self.stack.pop(0)
196 if type(vi) is AInstruction: 195 if type(vi) is AInstruction:
197 mi = self.target.mapInstruction(vi) 196 mi = self.target.mapInstruction(vi)
198 elif type(vi) is ALabel: 197 elif type(vi) is ALabel: