annotate python/msp430.py @ 199:a690473b79e2

Added msp430 target
author Windel Bouwman
date Fri, 07 Jun 2013 18:59:57 +0200
parents
children 5e391d9a3381
rev   line source
199
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
1 from target import Register, Instruction, Target
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
2
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
3 # Target description for the MSP430 processor
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
4
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
5 class MSP430Reg(Register):
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
6 def __init__(self, num, name):
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
7 super().__init__(name)
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
8 self.num = num
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
9
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
10 # 8 bit variants:
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
11 PCB = MSP430Reg(0, 'r0')
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
12 R14B = MSP430Reg(14, 'r14')
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
13 R15B = MSP430Reg(15, 'r15')
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
14
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
15 # .. etc
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
16
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
17 #GR8 = RegisterClass((PCB, R15B))
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
18
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
19 class TwoOpArith(Instruction):
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
20 def __init__(self, opc, name):
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
21 super().__init__(opc)
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
22 self.name = name
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
23
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
24 mov_ins = TwoOpArith(4, 'mov')
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
25 add_ins = TwoOpArith(5, 'add')
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
26
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
27 class MSP430(Target):
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
28 def __init__(self):
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
29 self.registers = [PCB, R14B, R15B]
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
30 self.instructions = [mov_ins, add_ins]
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
31
a690473b79e2 Added msp430 target
Windel Bouwman
parents:
diff changeset
32