Mercurial > lcfOS
comparison python/ppci/target/arm/registers.py @ 342:86b02c98a717 devel
Moved target directory
author | Windel Bouwman |
---|---|
date | Sat, 01 Mar 2014 15:40:31 +0100 |
parents | python/target/armregisters.py@4d204f6f7d4e |
children |
comparison
equal
deleted
inserted
replaced
341:4d204f6f7d4e | 342:86b02c98a717 |
---|---|
1 | |
2 from ..basetarget import Register | |
3 | |
4 class ArmRegister(Register): | |
5 def __init__(self, num, name): | |
6 super().__init__(name) | |
7 self.num = num | |
8 | |
9 def __repr__(self): | |
10 return self.name | |
11 | |
12 | |
13 class Reg8Op(ArmRegister): | |
14 pass | |
15 | |
16 | |
17 def get_register(n): | |
18 for x in registers: | |
19 if x.num == n: | |
20 return x | |
21 raise Exception('No register found with this number') | |
22 | |
23 def register_range(a, b): | |
24 """ Return set of registers from a to b """ | |
25 assert a.num < b.num | |
26 return {get_register(n) for n in range(a.num, b.num + 1)} | |
27 | |
28 | |
29 R0 = Reg8Op(0, 'r0') | |
30 R1 = Reg8Op(1, 'r1') | |
31 R2 = Reg8Op(2, 'r2') | |
32 R3 = Reg8Op(3, 'r3') | |
33 R4 = Reg8Op(4, 'r4') | |
34 R5 = Reg8Op(5, 'r5') | |
35 R6 = Reg8Op(6, 'r6') | |
36 R7 = Reg8Op(7, 'r7') | |
37 R8 = ArmRegister(8, 'r8') | |
38 R9 = ArmRegister(9, 'r9') | |
39 R10 = ArmRegister(10, 'r10') | |
40 R11 = ArmRegister(11, 'r11') | |
41 R12 = ArmRegister(12, 'r12') | |
42 | |
43 # Other registers: | |
44 # TODO | |
45 SP = ArmRegister(13, 'sp') | |
46 LR = ArmRegister(14, 'lr') | |
47 PC = ArmRegister(15, 'pc') | |
48 | |
49 registers = [R0, R1, R2, R3, R4, R5, R6, R7, SP, LR, PC] |