Mercurial > lcfOS
diff python/codegenarm.py @ 237:81752b0f85a5
Added burn led test program
author | Windel Bouwman |
---|---|
date | Wed, 17 Jul 2013 22:31:54 +0200 |
parents | 8786811a5a59 |
children | 6259856841a0 |
line wrap: on
line diff
--- a/python/codegenarm.py Mon Jul 15 20:15:31 2013 +0200 +++ b/python/codegenarm.py Wed Jul 17 22:31:54 2013 +0200 @@ -28,8 +28,11 @@ # Manually inserted startup code: self.dcd(0x20000678) # initial stack ptr - self.dcd(0x08000401) # reset vector + # TODO: use label here: + #self.emit(arm.dcd_ins(LabelRef('reset'))) # reset vector + self.dcd(0x08000009) # reset vector, lsb indicates thumb mode + self.emit(Label('reset')) for f in ircode.Functions: # Add global variable addresses to immediate list: for gvar in ircode.Variables: @@ -50,6 +53,8 @@ self.emit(Label(l)) self.dcd(v) self.align() + self.outs.backpatch() + self.outs.backpatch() def dcd(self, x): self.emit(arm.dcd_ins(Imm32(x))) @@ -74,8 +79,8 @@ def generateInstruction(self, ins): self.comment(str(ins)) if type(ins) is ir.Branch: - tgt = Label(ins.target.name) - self.emit(arm.jmp_ins(tgt)) + tgt = LabelRef(ins.target.name) + self.emit(arm.b_ins(tgt)) elif type(ins) is ir.ImmLoad: lname = ins.target.name + '_ivalue' self.emit(arm.ldr_pcrel(arm.r0, LabelRef(lname))) @@ -108,7 +113,7 @@ elif ins.operation == '|': self.emit(arm.orrregs_ins(arm.r0, arm.r1)) else: - print('operation not implemented', ins.operation) + raise NotImplementedError('operation {} not implemented'.format(ins.operation)) # Store value back: self.emit(arm.str_sprel(arm.r0, arm.MemSpRel(self.addStack(ins.result)))) elif type(ins) is ir.Return: @@ -121,13 +126,13 @@ if ins.cond == '==': self.emit(arm.beq_ins(tgt_yes)) else: - print('TODO', ins.cond) + raise NotImplementedError('"{}" not covered'.format(ins.cond)) tgt_no = Label(ins.lab2.name) self.emit(arm.jmp_ins(tgt_no)) elif type(ins) is ir.Alloc: # Local variables are added to stack self.addStack(ins.value) else: - raise CompilerError('IR "{}" not covered'.format(ins)) + raise NotImplementedError('IR "{}" not covered'.format(ins))