Mercurial > lcfOS
view python/target/armtarget.py @ 322:44f336460c2a
Half of use of burg spec for arm
author | Windel Bouwman |
---|---|
date | Mon, 27 Jan 2014 19:58:07 +0100 |
parents | 534b94b40aa8 |
children | 6f4753202b9a |
line wrap: on
line source
import struct from .basetarget import Register, Instruction, Target, Label, LabelRef from .basetarget import Imm32, Imm8, Imm7, Imm3 from .arminstructions import allins, Reg8Op, ArmRegister from .arminstructions import Dcd, B from .arminstructions import R0, R1, R2, R3, R4, R5, R6, R7, LR, PC, SP from .armframe import ArmFrame from .arminstructionselector import ArmInstructionSelector """ ARM target description. """ # TODO: encode this in DSL (domain specific language) # TBD: is this required? # TODO: make a difference between armv7 and armv5? class ArmTarget(Target): def __init__(self): super().__init__('arm') for i in allins: self.addInstruction(i) # TODO: fix this nicer? #setattr(self, i.__name__, i) self.check() self.ins_sel = ArmInstructionSelector() self.FrameClass = ArmFrame def startCode(self, outs): """ Emit some startup code in the output stream """ outs.selectSection('code') # assembly glue to make it work: # TODO: this must be in source code, not in compiler outs.emit(Dcd(Imm32(0x20000678))) # initial SP outs.emit(Dcd(Imm32(0x08000009))) # reset vector outs.emit(B(LabelRef('main')))