annotate python/ppci/target/msp430/msp430.py @ 345:b4882ff0ed06

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