annotate python/ppci/target/msp430/msp430.py @ 346:3bb7dcfe5529

expanded arm target
author Windel Bouwman
date Fri, 07 Mar 2014 17:05:32 +0100
parents b4882ff0ed06
children 6df89163e114
rev   line source
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
1 import struct
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
2 import types
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
3 from ..basetarget import Register, Instruction, Target
201
d5debbfc0200 Added all 27 core instructions of msp430
Windel Bouwman
parents: 200
diff changeset
4 from ppci import CompilerError
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
5 from .registers import r10, r11, r12, r13, r14, r15
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
6 from .instructions import Reti, Mov, Add
201
d5debbfc0200 Added all 27 core instructions of msp430
Windel Bouwman
parents: 200
diff changeset
7
d5debbfc0200 Added all 27 core instructions of msp430
Windel Bouwman
parents: 200
diff changeset
8 # Create the target class (singleton):
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 334
diff changeset
9
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
10 class Msp430Target(Target):
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 334
diff changeset
11 def __init__(self):
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 334
diff changeset
12 super().__init__('msp430')
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
13
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
14 # Registers:
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
15 self.add_keyword('r10')
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
16 self.add_keyword('r11')
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
17 self.add_keyword('r12')
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 334
diff changeset
18 self.add_keyword('r13')
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 334
diff changeset
19 self.add_keyword('r14')
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 334
diff changeset
20 self.add_keyword('r15')
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
21 self.add_rule('reg', ['r10'], lambda rhs: r10)
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
22 self.add_rule('reg', ['r11'], lambda rhs: r11)
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
23 self.add_rule('reg', ['r12'], lambda rhs: r12)
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 334
diff changeset
24 self.add_rule('reg', ['r13'], lambda rhs: r13)
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 334
diff changeset
25 self.add_rule('reg', ['r14'], lambda rhs: r14)
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 334
diff changeset
26 self.add_rule('reg', ['r15'], lambda rhs: r15)
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
27
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
28 # Instructions rules:
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
29 self.add_keyword('mov')
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 334
diff changeset
30 self.add_instruction(['mov', 'reg', ',', 'reg'],
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 334
diff changeset
31 lambda rhs: Mov(rhs[1], rhs[3]))
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
32 self.add_instruction(['mov', 'imm16', ',', 'reg'],
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
33 lambda rhs: Mov(rhs[1], rhs[3]))
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
34
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
35 self.add_keyword('add')
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
36 self.add_instruction(['add', 'reg', ',', 'reg'],
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
37 lambda rhs: Add(rhs[1], rhs[3]))
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
38
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 334
diff changeset
39 self.add_keyword('reti')
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
40 self.add_instruction(['reti'], lambda rhs: Reti())
201
d5debbfc0200 Added all 27 core instructions of msp430
Windel Bouwman
parents: 200
diff changeset
41
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
42
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
43
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
44 msp430target = Msp430Target()
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
45
201
d5debbfc0200 Added all 27 core instructions of msp430
Windel Bouwman
parents: 200
diff changeset
46
199
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
47 # Target description for the MSP430 processor
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
48
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
49
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
50 msp430target.registers.append(r10)
201
d5debbfc0200 Added all 27 core instructions of msp430
Windel Bouwman
parents: 200
diff changeset
51 msp430target.registers.append(r11)
d5debbfc0200 Added all 27 core instructions of msp430
Windel Bouwman
parents: 200
diff changeset
52 msp430target.registers.append(r12)
d5debbfc0200 Added all 27 core instructions of msp430
Windel Bouwman
parents: 200
diff changeset
53 msp430target.registers.append(r13)
d5debbfc0200 Added all 27 core instructions of msp430
Windel Bouwman
parents: 200
diff changeset
54 msp430target.registers.append(r14)
d5debbfc0200 Added all 27 core instructions of msp430
Windel Bouwman
parents: 200
diff changeset
55 msp430target.registers.append(r15)
d5debbfc0200 Added all 27 core instructions of msp430
Windel Bouwman
parents: 200
diff changeset
56