Mercurial > lcfOS
view python/ppci/target/arm/__init__.py @ 342:86b02c98a717 devel
Moved target directory
author | Windel Bouwman |
---|---|
date | Sat, 01 Mar 2014 15:40:31 +0100 |
parents | |
children | b4882ff0ed06 |
line wrap: on
line source
from ..basetarget import Target from ..arm.registers import R0, R1, R2, R3, R4, R5, R6, R7, SP, LR, PC from ..arm.registers import register_range from .instructions import Mov class ArmArmTarget(Target): def __init__(self): super().__init__('arm_arm') # Assembly grammar: self.add_keyword('mov') self.add_keyword('r0') self.add_keyword('r1') self.add_keyword('r2') self.add_keyword('r3') self.add_keyword('r4') self.add_keyword('r5') self.add_keyword('r6') self.add_keyword('r7') self.add_rule('reg', ['r0'], lambda rhs: R0) self.add_rule('reg', ['r1'], lambda rhs: R1) self.add_rule('reg', ['r2'], lambda rhs: R2) self.add_rule('reg', ['r3'], lambda rhs: R3) self.add_rule('reg', ['r4'], lambda rhs: R4) self.add_rule('reg', ['r5'], lambda rhs: R5) self.add_rule('reg', ['r6'], lambda rhs: R6) self.add_rule('reg', ['r7'], lambda rhs: R7) self.add_instruction(['mov', 'reg', ',', 'imm8'], lambda rhs: Mov(rhs[1], rhs[3])) self.add_rule('imm32', ['val32'], lambda x: x[0].val) self.add_rule('imm32', ['imm8'], lambda x: x[0]) self.add_rule('imm8', ['val8'], lambda x: x[0].val) self.add_rule('imm8', ['imm5'], lambda x: x[0]) self.add_rule('imm5', ['val5'], lambda x: x[0].val) self.add_rule('imm5', ['imm3'], lambda x: x[0]) self.add_rule('imm3', ['val3'], lambda x: x[0].val)