comparison 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
comparison
equal deleted inserted replaced
341:4d204f6f7d4e 342:86b02c98a717
1
2 from ..basetarget import Target
3 from ..arm.registers import R0, R1, R2, R3, R4, R5, R6, R7, SP, LR, PC
4 from ..arm.registers import register_range
5
6 from .instructions import Mov
7
8 class ArmArmTarget(Target):
9 def __init__(self):
10 super().__init__('arm_arm')
11
12 # Assembly grammar:
13 self.add_keyword('mov')
14 self.add_keyword('r0')
15 self.add_keyword('r1')
16 self.add_keyword('r2')
17 self.add_keyword('r3')
18 self.add_keyword('r4')
19 self.add_keyword('r5')
20 self.add_keyword('r6')
21 self.add_keyword('r7')
22
23 self.add_rule('reg', ['r0'], lambda rhs: R0)
24 self.add_rule('reg', ['r1'], lambda rhs: R1)
25 self.add_rule('reg', ['r2'], lambda rhs: R2)
26 self.add_rule('reg', ['r3'], lambda rhs: R3)
27 self.add_rule('reg', ['r4'], lambda rhs: R4)
28 self.add_rule('reg', ['r5'], lambda rhs: R5)
29 self.add_rule('reg', ['r6'], lambda rhs: R6)
30 self.add_rule('reg', ['r7'], lambda rhs: R7)
31
32
33 self.add_instruction(['mov', 'reg', ',', 'imm8'],
34 lambda rhs: Mov(rhs[1], rhs[3]))
35
36 self.add_rule('imm32', ['val32'], lambda x: x[0].val)
37 self.add_rule('imm32', ['imm8'], lambda x: x[0])
38 self.add_rule('imm8', ['val8'], lambda x: x[0].val)
39 self.add_rule('imm8', ['imm5'], lambda x: x[0])
40 self.add_rule('imm5', ['val5'], lambda x: x[0].val)
41 self.add_rule('imm5', ['imm3'], lambda x: x[0])
42 self.add_rule('imm3', ['val3'], lambda x: x[0].val)