annotate python/arm_cm3.py @ 205:d77cb5962cc5

Added some handcoded arm code generation
author Windel Bouwman
date Sun, 23 Jun 2013 18:23:18 +0200
parents ca1ea402f6a1
children 6c6bf8890d8a
rev   line source
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
1 import struct, types
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
2 from target import Register, Instruction, Target
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
3 from asmnodes import ASymbol, ANumber
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
4 from ppci import CompilerError
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
5 import ir
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
6
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
7 def u16(h):
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
8 return struct.pack('<H', h)
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
9
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
10 def u32(x):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
11 return struct.pack('<I', x)
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
12
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
13 armtarget = Target('arm')
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
14
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
15 class ArmReg(Register):
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
16 def __init__(self, num, name):
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
17 super().__init__(name)
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
18 self.num = num
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
19
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
20 class ArmImm:
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
21 def __init__(self, i):
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
22 self.i = i
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
23
203
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
24 class RegOp:
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
25 def __init__(self, num):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
26 assert num < 8
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
27 self.num = num
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
28
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
29 @classmethod
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
30 def Create(cls, vop):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
31 if type(vop) is ASymbol:
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
32 name = vop.name
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
33 regs = {}
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
34 for r in armtarget.registers:
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
35 regs[r.name] = r
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
36 if name in regs:
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
37 r = regs[name]
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
38 return cls(r.num)
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
39
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
40 class Label:
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
41 def __init__(self, name):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
42 self.name = name
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
43
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
44 @classmethod
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
45 def Create(cls, vop):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
46 if type(vop) is ASymbol:
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
47 name = vop.name
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
48 return cls(name)
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
49
203
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
50 class Imm8:
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
51 def __init__(self, imm):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
52 assert imm < 256
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
53 self.imm = imm
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
54
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
55 @classmethod
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
56 def Create(cls, vop):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
57 if type(vop) is ANumber and vop.number < 256:
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
58 return cls(vop.number)
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
59
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
60 class Imm3:
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
61 def __init__(self, imm):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
62 assert imm < 8
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
63 assert type(imm) is int
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
64 self.imm = imm
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
65
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
66 @classmethod
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
67 def Create(cls, vop):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
68 if type(vop) is ANumber and vop.number < 8:
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
69 return cls(vop.number)
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
70
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
71 class RegisterSet:
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
72 def __init__(self, regs):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
73 pass
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
74
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
75 # 8 bit registers:
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
76 r0 = ArmReg(0, 'r0')
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
77 armtarget.registers.append(r0)
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
78 r4 = ArmReg(4, 'r4')
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
79 armtarget.registers.append(r4)
203
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
80 r5 = ArmReg(5, 'r5')
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
81 armtarget.registers.append(r5)
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
82 r6 = ArmReg(6, 'r6')
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
83 armtarget.registers.append(r6)
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
84 r7 = ArmReg(7, 'r7')
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
85 armtarget.registers.append(r7)
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
86
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
87 class ArmInstruction(Instruction):
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
88 pass
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
89
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
90 @armtarget.instruction
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
91 class ldr_ins(ArmInstruction):
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
92 mnemonic = 'ldr'
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
93 opcode = 1337
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
94 irpattern = 'todo'
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
95
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
96 @armtarget.instruction
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
97 class dcd_ins(ArmInstruction):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
98 mnemonic = 'dcd'
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
99 def __init__(self, expr):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
100 self.expr = expr
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
101 def encode(self):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
102 return u32(self.expr)
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
103
203
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
104 class Operand2:
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
105 def __init__(self, expr):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
106 if type(expr) is ANumber:
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
107 pass
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
108 pass
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
109
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
110 @armtarget.instruction
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
111 class mov_ins(ArmInstruction):
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
112 """ mov Rd, imm8, move immediate value into register """
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
113 mnemonic = 'mov'
203
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
114 opcode = 4 # 00100 Rd(3) imm8
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
115 operands = (RegOp, Imm8)
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
116 irpattern = ir.ImmLoad
203
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
117 def __init__(self, rd, imm):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
118 self.imm = imm.imm
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
119 self.r = rd.num
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
120
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
121 @classmethod
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
122 def FromIr(cls, ir_ins):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
123 pass
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
124
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
125 def encode(self):
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
126 rd = self.r
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
127 opcode = self.opcode
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
128 imm8 = self.imm
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
129 h = (opcode << 11) | (rd << 8) | imm8
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
130 return u16(h)
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
131
203
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
132 @armtarget.instruction
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
133 class movregreg_ins(ArmInstruction):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
134 """ mov Rd, Rm """
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
135 mnemonic = 'mov'
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
136 opcode = 8 # 01000 Rd(3) imm8
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
137 operands = (RegOp, RegOp)
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
138 def __init__(self, rd, rm):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
139 self.rd = rd
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
140 self.rm = rm
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
141 def encode(self):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
142 rd = self.rd.num
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
143 D = (rd & 0x8) >> 3
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
144 assert D < 2
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
145 rd = rd & 0x7
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
146 rm = self.rm.num
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
147 assert rm < 16
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
148 opcode = self.opcode
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
149 h = (opcode << 11) | (3 << 9) | (D << 7) | (rm << 3) | rd
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
150 return u16(h)
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
151
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
152 @armtarget.instruction
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
153 class addregregimm3_ins(ArmInstruction):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
154 """ add Rd, Rn, imm3 """
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
155 mnemonic = 'add'
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
156 opcode = 3 # 00011
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
157 operands = (RegOp, RegOp, Imm3)
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
158 irpattern = 3
203
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
159 def __init__(self, rd, rn, imm3):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
160 self.rd = rd
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
161 self.rn = rn
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
162 self.imm3 = imm3
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
163 def encode(self):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
164 rd = self.rd.num
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
165 rn = self.rn.num
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
166 imm3 = self.imm3.imm
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
167 opcode = self.opcode
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
168 h = (opcode << 11) | (1 << 10) | (imm3 << 6) | (rn << 3) | rd
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
169 return u16(h)
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
170
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
171 @armtarget.instruction
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
172 class cmpregimm8_ins(ArmInstruction):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
173 """ cmp Rn, imm8 """
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
174 mnemonic = 'cmp'
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
175 opcode = 5 # 00101
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
176 operands = (RegOp, Imm8)
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
177 def __init__(self, rn, imm):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
178 self.rn = rn
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
179 self.imm = imm
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
180 def encode(self):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
181 rn = self.rn.num
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
182 imm = self.imm.imm
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
183 opcode = self.opcode
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
184 h = (opcode << 11) | (rn << 8) | imm
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 202
diff changeset
185 return u16(h)
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
186
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
187 @armtarget.instruction
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
188 class jmp_ins(ArmInstruction):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
189 operands = (Label)
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
190 mnemonic = 'jmp'
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
191 def __init__(self, target_label):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
192 self.target = target_label
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
193 def fixUp(self):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
194 pass
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
195 def encode(self):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
196 h = 1337 # TODO
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
197 return u16(h)
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
198
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
199 @armtarget.instruction
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
200 class push_ins(ArmInstruction):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
201 operands = (RegisterSet)
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
202 mnemonic = 'push'
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
203 def __init__(self, regs):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
204 self.regs = regs
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
205 def encode(self):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
206 return u16(0)
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
207
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
208 @armtarget.instruction
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
209 class pop_ins(ArmInstruction):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
210 operands = (RegisterSet)
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
211 mnemonic = 'pop'
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
212 def __init__(self, regs):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
213 self.regs = regs
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
214 def encode(self):
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
215 return u16(0)
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
216
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 203
diff changeset
217 @armtarget.instruction
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
218 class yield_ins(ArmInstruction):
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
219 operands = ()
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
220 mnemonic = 'yield'
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
221 def encode(self):
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
222 return u16(0xbf10)
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
223