src/arm/isa-arm.c (view raw)
1#include "isa-arm.h"
2
3#include "arm.h"
4#include "isa-inlines.h"
5
6enum {
7 PSR_USER_MASK = 0xF0000000,
8 PSR_PRIV_MASK = 0x000000CF,
9 PSR_STATE_MASK = 0x00000020
10};
11
12// Addressing mode 1
13static inline void _shiftLSL(struct ARMCore* cpu, uint32_t opcode) {
14 int rm = opcode & 0x0000000F;
15 int immediate = (opcode & 0x00000F80) >> 7;
16 if (!immediate) {
17 cpu->shifterOperand = cpu->gprs[rm];
18 cpu->shifterCarryOut = cpu->cpsr.c;
19 } else {
20 cpu->shifterOperand = cpu->gprs[rm] << immediate;
21 cpu->shifterCarryOut = cpu->gprs[rm] & (1 << (32 - immediate));
22 }
23}
24
25static inline void _shiftLSLR(struct ARMCore* cpu, uint32_t opcode) {
26 int rm = opcode & 0x0000000F;
27 ARM_STUB;
28}
29
30static inline void _shiftLSR(struct ARMCore* cpu, uint32_t opcode) {
31 int rm = opcode & 0x0000000F;
32 int immediate = (opcode & 0x00000F80) >> 7;
33 if (immediate) {
34 cpu->shifterOperand = ((uint32_t) cpu->gprs[rm]) >> immediate;
35 cpu->shifterCarryOut = cpu->gprs[rm] & (1 << (immediate - 1));
36 } else {
37 cpu->shifterOperand = 0;
38 cpu->shifterCarryOut = cpu->gprs[rm] & 0x80000000;
39 }
40}
41
42static inline void _shiftLSRR(struct ARMCore* cpu, uint32_t opcode) {
43 int rm = opcode & 0x0000000F;
44 ARM_STUB;
45}
46
47static inline void _shiftASR(struct ARMCore* cpu, uint32_t opcode) {
48 int rm = opcode & 0x0000000F;
49 int immediate = (opcode & 0x00000F80) >> 7;
50 if (immediate) {
51 cpu->shifterOperand = cpu->gprs[rm] >> immediate;
52 cpu->shifterCarryOut = cpu->gprs[rm] & (1 << (immediate - 1));
53 } else {
54 cpu->shifterCarryOut = cpu->gprs[rm] & 0x80000000;
55 cpu->shifterOperand = cpu->shifterCarryOut >> 31; // Ensure sign extension
56 }
57}
58
59static inline void _shiftASRR(struct ARMCore* cpu, uint32_t opcode) {
60 int rm = opcode & 0x0000000F;
61 ARM_STUB;
62}
63
64static inline void _shiftROR(struct ARMCore* cpu, uint32_t opcode) {
65 int rm = opcode & 0x0000000F;
66 int immediate = (opcode & 0x00000F80) >> 7;
67 if (immediate) {
68 cpu->shifterOperand = ARM_ROR(cpu->gprs[rm], immediate);
69 cpu->shifterCarryOut = cpu->gprs[rm] & (1 << (immediate - 1));
70 } else {
71 // RRX
72 cpu->shifterOperand = (cpu->cpsr.c << 31) | (((uint32_t) cpu->gprs[rm]) >> 1);
73 cpu->shifterCarryOut = cpu->gprs[rm] & 0x00000001;
74 }
75}
76
77static inline void _shiftRORR(struct ARMCore* cpu, uint32_t opcode) {
78 int rm = opcode & 0x0000000F;
79 ARM_STUB;
80}
81
82static inline void _immediate(struct ARMCore* cpu, uint32_t opcode) {
83 int rotate = (opcode & 0x00000F00) >> 7;
84 int immediate = opcode & 0x000000FF;
85 if (!rotate) {
86 cpu->shifterOperand = immediate;
87 cpu->shifterCarryOut = cpu->cpsr.c;
88 } else {
89 cpu->shifterOperand = ARM_ROR(immediate, rotate);
90 cpu->shifterCarryOut = ARM_SIGN(cpu->shifterOperand);
91 }
92}
93
94static const ARMInstruction _armTable[0x1000];
95
96static ARMInstruction _ARMLoadInstructionARM(struct ARMMemory* memory, uint32_t address, uint32_t* opcodeOut) {
97 uint32_t opcode = memory->activeRegion[(address & memory->activeMask) >> 2];
98 *opcodeOut = opcode;
99 return _armTable[((opcode >> 16) & 0xFF0) | ((opcode >> 4) & 0x00F)];
100}
101
102void ARMStep(struct ARMCore* cpu) {
103 // TODO
104 uint32_t opcode;
105 ARMInstruction instruction = _ARMLoadInstructionARM(cpu->memory, cpu->gprs[ARM_PC] - WORD_SIZE_ARM, &opcode);
106 cpu->gprs[ARM_PC] += WORD_SIZE_ARM;
107
108 int condition = opcode >> 28;
109 if (condition == 0xE) {
110 instruction(cpu, opcode);
111 return;
112 } else {
113 switch (condition) {
114 case 0x0:
115 if (!ARM_COND_EQ) {
116 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
117 return;
118 }
119 break;
120 case 0x1:
121 if (!ARM_COND_NE) {
122 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
123 return;
124 }
125 break;
126 case 0x2:
127 if (!ARM_COND_CS) {
128 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
129 return;
130 }
131 break;
132 case 0x3:
133 if (!ARM_COND_CC) {
134 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
135 return;
136 }
137 break;
138 case 0x4:
139 if (!ARM_COND_MI) {
140 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
141 return;
142 }
143 break;
144 case 0x5:
145 if (!ARM_COND_PL) {
146 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
147 return;
148 }
149 break;
150 case 0x6:
151 if (!ARM_COND_VS) {
152 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
153 return;
154 }
155 break;
156 case 0x7:
157 if (!ARM_COND_VC) {
158 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
159 return;
160 }
161 break;
162 case 0x8:
163 if (!ARM_COND_HI) {
164 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
165 return;
166 }
167 break;
168 case 0x9:
169 if (!ARM_COND_LS) {
170 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
171 return;
172 }
173 break;
174 case 0xA:
175 if (!ARM_COND_GE) {
176 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
177 return;
178 }
179 break;
180 case 0xB:
181 if (!ARM_COND_LT) {
182 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
183 return;
184 }
185 break;
186 case 0xC:
187 if (!ARM_COND_GT) {
188 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
189 return;
190 }
191 break;
192 case 0xD:
193 if (!ARM_COND_LE) {
194 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32;
195 return;
196 }
197 break;
198 default:
199 break;
200 }
201 }
202 instruction(cpu, opcode);
203}
204
205// Instruction definitions
206// Beware pre-processor antics
207
208#define ARM_ADDITION_S(M, N, D) \
209 if (rd == ARM_PC && _ARMModeHasSPSR(cpu->cpsr.priv)) { \
210 cpu->cpsr = cpu->spsr; \
211 _ARMReadCPSR(cpu); \
212 } else { \
213 cpu->cpsr.n = ARM_SIGN(D); \
214 cpu->cpsr.z = !(D); \
215 cpu->cpsr.c = ARM_CARRY_FROM(M, N, D); \
216 cpu->cpsr.v = ARM_V_ADDITION(M, N, D); \
217 }
218
219#define ARM_SUBTRACTION_S(M, N, D) \
220 if (rd == ARM_PC && _ARMModeHasSPSR(cpu->cpsr.priv)) { \
221 cpu->cpsr = cpu->spsr; \
222 _ARMReadCPSR(cpu); \
223 } else { \
224 cpu->cpsr.n = ARM_SIGN(D); \
225 cpu->cpsr.z = !(D); \
226 cpu->cpsr.c = ARM_BORROW_FROM(M, N, D); \
227 cpu->cpsr.v = ARM_V_SUBTRACTION(M, N, D); \
228 }
229
230#define ARM_NEUTRAL_S(M, N, D) \
231 if (rd == ARM_PC && _ARMModeHasSPSR(cpu->cpsr.priv)) { \
232 cpu->cpsr = cpu->spsr; \
233 _ARMReadCPSR(cpu); \
234 } else { \
235 cpu->cpsr.n = ARM_SIGN(D); \
236 cpu->cpsr.z = !(D); \
237 cpu->cpsr.c = !!cpu->shifterCarryOut; \
238 }
239
240#define ARM_NEUTRAL_HI_S(DLO, DHI) \
241 cpu->cpsr.n = ARM_SIGN(DHI); \
242 cpu->cpsr.z = !((DHI) | (DLO));
243
244#define ADDR_MODE_2_I_TEST (opcode & 0x00000F80)
245#define ADDR_MODE_2_I ((opcode & 0x00000F80) >> 7)
246#define ADDR_MODE_2_ADDRESS (address)
247#define ADDR_MODE_2_RN (cpu->gprs[rn])
248#define ADDR_MODE_2_RM (cpu->gprs[rm])
249#define ADDR_MODE_2_IMMEDIATE (opcode & 0x00000FFF)
250#define ADDR_MODE_2_INDEX(U_OP, M) (cpu->gprs[rn] U_OP M)
251#define ADDR_MODE_2_WRITEBACK(ADDR) (cpu->gprs[rn] = ADDR)
252#define ADDR_MODE_2_LSL (cpu->gprs[rm] << ADDR_MODE_2_I)
253#define ADDR_MODE_2_LSR (ADDR_MODE_2_I_TEST ? ((uint32_t) cpu->gprs[rm]) >> ADDR_MODE_2_I : 0)
254#define ADDR_MODE_2_ASR (ADDR_MODE_2_I_TEST ? ((int32_t) cpu->gprs[rm]) >> ADDR_MODE_2_I : ((int32_t) cpu->gprs[rm]) >> 31)
255#define ADDR_MODE_2_ROR (ADDR_MODE_2_I_TEST ? ARM_ROR(cpu->gprs[rm], ADDR_MODE_2_I) : (cpu->cpsr.c << 31) | (((uint32_t) cpu->gprs[rm]) >> 1))
256
257#define ADDR_MODE_3_ADDRESS ADDR_MODE_2_ADDRESS
258#define ADDR_MODE_3_RN ADDR_MODE_2_RN
259#define ADDR_MODE_3_RM ADDR_MODE_2_RM
260#define ADDR_MODE_3_IMMEDIATE (((opcode & 0x00000F00) >> 4) | (opcode & 0x0000000F))
261#define ADDR_MODE_3_INDEX(U_OP, M) ADDR_MODE_2_INDEX(U_OP, M)
262#define ADDR_MODE_3_WRITEBACK(ADDR) ADDR_MODE_2_WRITEBACK(ADDR)
263
264#define ARM_LOAD_POST_BODY \
265 if (rd == ARM_PC) { \
266 ARM_WRITE_PC; \
267 }
268
269#define DEFINE_INSTRUCTION_ARM(NAME, BODY) \
270 static void _ARMInstruction ## NAME (struct ARMCore* cpu, uint32_t opcode) { \
271 BODY; \
272 cpu->cycles += 1 + cpu->memory->activePrefetchCycles32; \
273 }
274
275#define DEFINE_ALU_INSTRUCTION_EX_ARM(NAME, S_BODY, SHIFTER, BODY) \
276 DEFINE_INSTRUCTION_ARM(NAME, \
277 int rd = (opcode >> 12) & 0xF; \
278 int rn = (opcode >> 16) & 0xF; \
279 UNUSED(rn); \
280 SHIFTER(cpu, opcode); \
281 BODY; \
282 S_BODY; \
283 if (rd == ARM_PC) { \
284 if (cpu->executionMode == MODE_ARM) { \
285 ARM_WRITE_PC; \
286 } else { \
287 THUMB_WRITE_PC; \
288 } \
289 })
290
291#define DEFINE_ALU_INSTRUCTION_ARM(NAME, S_BODY, BODY) \
292 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _LSL, , _shiftLSL, BODY) \
293 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## S_LSL, S_BODY, _shiftLSL, BODY) \
294 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _LSLR, , _shiftLSLR, BODY) \
295 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## S_LSLR, S_BODY, _shiftLSLR, BODY) \
296 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _LSR, , _shiftLSR, BODY) \
297 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## S_LSR, S_BODY, _shiftLSR, BODY) \
298 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _LSRR, , _shiftLSRR, BODY) \
299 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## S_LSRR, S_BODY, _shiftLSRR, BODY) \
300 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _ASR, , _shiftASR, BODY) \
301 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## S_ASR, S_BODY, _shiftASR, BODY) \
302 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _ASRR, , _shiftASRR, BODY) \
303 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## S_ASRR, S_BODY, _shiftASRR, BODY) \
304 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _ROR, , _shiftROR, BODY) \
305 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## S_ROR, S_BODY, _shiftROR, BODY) \
306 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _RORR, , _shiftRORR, BODY) \
307 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## S_RORR, S_BODY, _shiftRORR, BODY) \
308 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## I, , _immediate, BODY) \
309 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## SI, S_BODY, _immediate, BODY)
310
311#define DEFINE_ALU_INSTRUCTION_S_ONLY_ARM(NAME, S_BODY, BODY) \
312 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _LSL, S_BODY, _shiftLSL, BODY) \
313 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _LSLR, S_BODY, _shiftLSLR, BODY) \
314 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _LSR, S_BODY, _shiftLSR, BODY) \
315 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _LSRR, S_BODY, _shiftLSRR, BODY) \
316 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _ASR, S_BODY, _shiftASR, BODY) \
317 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _ASRR, S_BODY, _shiftASRR, BODY) \
318 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _ROR, S_BODY, _shiftROR, BODY) \
319 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## _RORR, S_BODY, _shiftRORR, BODY) \
320 DEFINE_ALU_INSTRUCTION_EX_ARM(NAME ## I, S_BODY, _immediate, BODY)
321
322#define DEFINE_MULTIPLY_INSTRUCTION_EX_ARM(NAME, BODY, S_BODY) \
323 DEFINE_INSTRUCTION_ARM(NAME, \
324 int rd = (opcode >> 12) & 0xF; \
325 int rdHi = (opcode >> 16) & 0xF; \
326 int rs = (opcode >> 8) & 0xF; \
327 int rm = opcode & 0xF; \
328 UNUSED(rdHi); \
329 BODY; \
330 S_BODY; \
331 if (rd == ARM_PC) { \
332 ARM_WRITE_PC; \
333 })
334
335#define DEFINE_MULTIPLY_INSTRUCTION_ARM(NAME, BODY, S_BODY) \
336 DEFINE_MULTIPLY_INSTRUCTION_EX_ARM(NAME, BODY, ) \
337 DEFINE_MULTIPLY_INSTRUCTION_EX_ARM(NAME ## S, BODY, S_BODY)
338
339#define DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME, ADDRESS, WRITEBACK, BODY) \
340 DEFINE_INSTRUCTION_ARM(NAME, \
341 uint32_t address; \
342 int rn = (opcode >> 16) & 0xF; \
343 int rd = (opcode >> 12) & 0xF; \
344 int rm = opcode & 0xF; \
345 UNUSED(rm); \
346 address = ADDRESS; \
347 BODY; \
348 WRITEBACK;)
349
350#define DEFINE_LOAD_STORE_INSTRUCTION_SHIFTER_ARM(NAME, SHIFTER, BODY) \
351 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME, SHIFTER, ADDR_MODE_2_WRITEBACK(ADDR_MODE_2_INDEX(-, ADDR_MODE_2_RM)), BODY) \
352 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## U, SHIFTER, ADDR_MODE_2_WRITEBACK(ADDR_MODE_2_INDEX(+, ADDR_MODE_2_RM)), BODY) \
353 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## P, ADDR_MODE_2_INDEX(-, SHIFTER), , BODY) \
354 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## PW, ADDR_MODE_2_INDEX(-, SHIFTER), ADDR_MODE_2_WRITEBACK(ADDR_MODE_2_ADDRESS), BODY) \
355 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## PU, ADDR_MODE_2_INDEX(+, SHIFTER), , BODY) \
356 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## PUW, ADDR_MODE_2_INDEX(+, SHIFTER), ADDR_MODE_2_WRITEBACK(ADDR_MODE_2_ADDRESS), BODY)
357
358#define DEFINE_LOAD_STORE_INSTRUCTION_ARM(NAME, BODY) \
359 DEFINE_LOAD_STORE_INSTRUCTION_SHIFTER_ARM(NAME ## _LSL_, ADDR_MODE_2_LSL, BODY) \
360 DEFINE_LOAD_STORE_INSTRUCTION_SHIFTER_ARM(NAME ## _LSR_, ADDR_MODE_2_LSR, BODY) \
361 DEFINE_LOAD_STORE_INSTRUCTION_SHIFTER_ARM(NAME ## _ASR_, ADDR_MODE_2_ASR, BODY) \
362 DEFINE_LOAD_STORE_INSTRUCTION_SHIFTER_ARM(NAME ## _ROR_, ADDR_MODE_2_ROR, BODY) \
363 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## I, ADDR_MODE_2_RN, ADDR_MODE_2_WRITEBACK(ADDR_MODE_2_INDEX(-, ADDR_MODE_2_IMMEDIATE)), BODY) \
364 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## IU, ADDR_MODE_2_RN, ADDR_MODE_2_WRITEBACK(ADDR_MODE_2_INDEX(+, ADDR_MODE_2_IMMEDIATE)), BODY) \
365 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## IP, ADDR_MODE_2_INDEX(-, ADDR_MODE_2_IMMEDIATE), , BODY) \
366 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## IPW, ADDR_MODE_2_INDEX(-, ADDR_MODE_2_IMMEDIATE), ADDR_MODE_2_WRITEBACK(ADDR_MODE_2_ADDRESS), BODY) \
367 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## IPU, ADDR_MODE_2_INDEX(+, ADDR_MODE_2_IMMEDIATE), , BODY) \
368 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## IPUW, ADDR_MODE_2_INDEX(+, ADDR_MODE_2_IMMEDIATE), ADDR_MODE_2_WRITEBACK(ADDR_MODE_2_ADDRESS), BODY) \
369
370#define DEFINE_LOAD_STORE_MODE_3_INSTRUCTION_ARM(NAME, BODY) \
371 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME, ADDR_MODE_3_RN, ADDR_MODE_3_WRITEBACK(ADDR_MODE_3_INDEX(-, ADDR_MODE_3_RM)), BODY) \
372 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## U, ADDR_MODE_3_RN, ADDR_MODE_3_WRITEBACK(ADDR_MODE_3_INDEX(+, ADDR_MODE_3_RM)), BODY) \
373 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## P, ADDR_MODE_3_INDEX(-, ADDR_MODE_3_RM), , BODY) \
374 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## PW, ADDR_MODE_3_INDEX(-, ADDR_MODE_3_RM), ADDR_MODE_3_WRITEBACK(ADDR_MODE_3_ADDRESS), BODY) \
375 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## PU, ADDR_MODE_3_INDEX(+, ADDR_MODE_3_RM), , BODY) \
376 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## PUW, ADDR_MODE_3_INDEX(+, ADDR_MODE_3_RM), ADDR_MODE_3_WRITEBACK(ADDR_MODE_3_ADDRESS), BODY) \
377 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## I, ADDR_MODE_3_RN, ADDR_MODE_3_WRITEBACK(ADDR_MODE_3_INDEX(-, ADDR_MODE_3_IMMEDIATE)), BODY) \
378 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## IU, ADDR_MODE_3_RN, ADDR_MODE_3_WRITEBACK(ADDR_MODE_3_INDEX(+, ADDR_MODE_3_IMMEDIATE)), BODY) \
379 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## IP, ADDR_MODE_3_INDEX(-, ADDR_MODE_3_IMMEDIATE), , BODY) \
380 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## IPW, ADDR_MODE_3_INDEX(-, ADDR_MODE_3_IMMEDIATE), ADDR_MODE_3_WRITEBACK(ADDR_MODE_3_ADDRESS), BODY) \
381 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## IPU, ADDR_MODE_3_INDEX(+, ADDR_MODE_3_IMMEDIATE), , BODY) \
382 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## IPUW, ADDR_MODE_3_INDEX(+, ADDR_MODE_3_IMMEDIATE), ADDR_MODE_3_WRITEBACK(ADDR_MODE_3_ADDRESS), BODY) \
383
384#define DEFINE_LOAD_STORE_T_INSTRUCTION_SHIFTER_ARM(NAME, SHIFTER, BODY) \
385 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME, SHIFTER, ADDR_MODE_2_WRITEBACK(ADDR_MODE_2_INDEX(-, ADDR_MODE_2_RM)), BODY) \
386 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## U, SHIFTER, ADDR_MODE_2_WRITEBACK(ADDR_MODE_2_INDEX(+, ADDR_MODE_2_RM)), BODY) \
387
388#define DEFINE_LOAD_STORE_T_INSTRUCTION_ARM(NAME, BODY) \
389 DEFINE_LOAD_STORE_T_INSTRUCTION_SHIFTER_ARM(NAME ## _LSL_, ADDR_MODE_2_LSL, BODY) \
390 DEFINE_LOAD_STORE_T_INSTRUCTION_SHIFTER_ARM(NAME ## _LSR_, ADDR_MODE_2_LSR, BODY) \
391 DEFINE_LOAD_STORE_T_INSTRUCTION_SHIFTER_ARM(NAME ## _ASR_, ADDR_MODE_2_ASR, BODY) \
392 DEFINE_LOAD_STORE_T_INSTRUCTION_SHIFTER_ARM(NAME ## _ROR_, ADDR_MODE_2_ROR, BODY) \
393 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## I, ADDR_MODE_2_RN, ADDR_MODE_2_WRITEBACK(ADDR_MODE_2_INDEX(-, ADDR_MODE_2_IMMEDIATE)), BODY) \
394 DEFINE_LOAD_STORE_INSTRUCTION_EX_ARM(NAME ## IU, ADDR_MODE_2_RN, ADDR_MODE_2_WRITEBACK(ADDR_MODE_2_INDEX(+, ADDR_MODE_2_IMMEDIATE)), BODY) \
395
396#define ARM_MS_PRE \
397 enum PrivilegeMode privilegeMode = cpu->privilegeMode; \
398 ARMSetPrivilegeMode(cpu, MODE_SYSTEM);
399
400#define ARM_MS_POST ARMSetPrivilegeMode(cpu, privilegeMode);
401
402#define ADDR_MODE_4_DA uint32_t addr = cpu->gprs[rn]
403#define ADDR_MODE_4_IA uint32_t addr = cpu->gprs[rn]
404#define ADDR_MODE_4_DB uint32_t addr = cpu->gprs[rn] - 4
405#define ADDR_MODE_4_IB uint32_t addr = cpu->gprs[rn] + 4
406#define ADDR_MODE_4_DAW cpu->gprs[rn] = addr
407#define ADDR_MODE_4_IAW cpu->gprs[rn] = addr
408#define ADDR_MODE_4_DBW cpu->gprs[rn] = addr + 4
409#define ADDR_MODE_4_IBW cpu->gprs[rn] = addr - 4
410
411#define ARM_M_INCREMENT(BODY) \
412 for (m = rs, i = 0; m; m >>= 1, ++i) { \
413 if (m & 1) { \
414 BODY; \
415 addr += 4; \
416 } \
417 }
418
419#define ARM_M_DECREMENT(BODY) \
420 for (m = 0x8000, i = 15; m; m >>= 1, --i) { \
421 if (rs & m) { \
422 BODY; \
423 addr -= 4; \
424 } \
425 }
426
427#define DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME, ADDRESS, WRITEBACK, LOOP, S_PRE, S_POST, BODY, POST_BODY) \
428 DEFINE_INSTRUCTION_ARM(NAME, \
429 int rn = (opcode >> 16) & 0xF; \
430 int rs = opcode & 0x0000FFFF; \
431 int m; \
432 int i; \
433 ADDRESS; \
434 S_PRE; \
435 LOOP(BODY); \
436 S_POST; \
437 WRITEBACK; \
438 POST_BODY;)
439
440
441#define DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(NAME, BODY, POST_BODY) \
442 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## DA, ADDR_MODE_4_DA, , ARM_M_DECREMENT, , , BODY, POST_BODY) \
443 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## DAW, ADDR_MODE_4_DA, ADDR_MODE_4_DAW, ARM_M_DECREMENT, , , BODY, POST_BODY) \
444 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## DB, ADDR_MODE_4_DB, , ARM_M_DECREMENT, , , BODY, POST_BODY) \
445 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## DBW, ADDR_MODE_4_DB, ADDR_MODE_4_DBW, ARM_M_DECREMENT, , , BODY, POST_BODY) \
446 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## IA, ADDR_MODE_4_IA, , ARM_M_INCREMENT, , , BODY, POST_BODY) \
447 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## IAW, ADDR_MODE_4_IA, ADDR_MODE_4_IAW, ARM_M_INCREMENT, , , BODY, POST_BODY) \
448 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## IB, ADDR_MODE_4_IB, , ARM_M_INCREMENT, , , BODY, POST_BODY) \
449 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## IBW, ADDR_MODE_4_IB, ADDR_MODE_4_IBW, ARM_M_INCREMENT, , , BODY, POST_BODY) \
450 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## SDA, ADDR_MODE_4_DA, , ARM_M_DECREMENT, ARM_MS_PRE, ARM_MS_POST, BODY, POST_BODY) \
451 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## SDAW, ADDR_MODE_4_DA, ADDR_MODE_4_DAW, ARM_M_DECREMENT, ARM_MS_PRE, ARM_MS_POST, BODY, POST_BODY) \
452 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## SDB, ADDR_MODE_4_DB, , ARM_M_DECREMENT, ARM_MS_PRE, ARM_MS_POST, BODY, POST_BODY) \
453 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## SDBW, ADDR_MODE_4_DB, ADDR_MODE_4_DBW, ARM_M_DECREMENT, ARM_MS_PRE, ARM_MS_POST, BODY, POST_BODY) \
454 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## SIA, ADDR_MODE_4_IA, , ARM_M_INCREMENT, ARM_MS_PRE, ARM_MS_POST, BODY, POST_BODY) \
455 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## SIAW, ADDR_MODE_4_IA, ADDR_MODE_4_IAW, ARM_M_INCREMENT, ARM_MS_PRE, ARM_MS_POST, BODY, POST_BODY) \
456 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## SIB, ADDR_MODE_4_IB, , ARM_M_INCREMENT, ARM_MS_PRE, ARM_MS_POST, BODY, POST_BODY) \
457 DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_EX_ARM(NAME ## SIBW, ADDR_MODE_4_IB, ADDR_MODE_4_IBW, ARM_M_INCREMENT, ARM_MS_PRE, ARM_MS_POST, BODY, POST_BODY)
458
459// Begin ALU definitions
460
461DEFINE_ALU_INSTRUCTION_ARM(ADD, ARM_ADDITION_S(n, cpu->shifterOperand, cpu->gprs[rd]),
462 int32_t n = cpu->gprs[rn];
463 cpu->gprs[rd] = n + cpu->shifterOperand;)
464
465DEFINE_ALU_INSTRUCTION_ARM(ADC, ARM_ADDITION_S(cpu->gprs[rn], shifterOperand, cpu->gprs[rd]),
466 int32_t n = cpu->gprs[rn];
467 int32_t shifterOperand = cpu->shifterOperand + cpu->cpsr.c;
468 cpu->gprs[rd] = n + shifterOperand;)
469
470DEFINE_ALU_INSTRUCTION_ARM(AND, ARM_NEUTRAL_S(cpu->gprs[rn], cpu->shifterOperand, cpu->gprs[rd]),
471 cpu->gprs[rd] = cpu->gprs[rn] & cpu->shifterOperand;)
472
473DEFINE_ALU_INSTRUCTION_ARM(BIC, ARM_NEUTRAL_S(cpu->gprs[rn], cpu->shifterOperand, cpu->gprs[rd]),
474 cpu->gprs[rd] = cpu->gprs[rn] & ~cpu->shifterOperand;)
475
476DEFINE_ALU_INSTRUCTION_S_ONLY_ARM(CMN, ARM_ADDITION_S(cpu->gprs[rn], cpu->shifterOperand, aluOut),
477 int32_t aluOut = cpu->gprs[rn] + cpu->shifterOperand;)
478
479DEFINE_ALU_INSTRUCTION_S_ONLY_ARM(CMP, ARM_SUBTRACTION_S(cpu->gprs[rn], cpu->shifterOperand, aluOut),
480 int32_t aluOut = cpu->gprs[rn] - cpu->shifterOperand;)
481
482DEFINE_ALU_INSTRUCTION_ARM(EOR, ARM_NEUTRAL_S(cpu->gprs[rn], cpu->shifterOperand, cpu->gprs[rd]),
483 cpu->gprs[rd] = cpu->gprs[rn] ^ cpu->shifterOperand;)
484
485DEFINE_ALU_INSTRUCTION_ARM(MOV, ARM_NEUTRAL_S(cpu->gprs[rn], cpu->shifterOperand, cpu->gprs[rd]),
486 cpu->gprs[rd] = cpu->shifterOperand;)
487
488DEFINE_ALU_INSTRUCTION_ARM(MVN, ARM_NEUTRAL_S(cpu->gprs[rn], cpu->shifterOperand, cpu->gprs[rd]),
489 cpu->gprs[rd] = ~cpu->shifterOperand;)
490
491DEFINE_ALU_INSTRUCTION_ARM(ORR, ARM_NEUTRAL_S(cpu->gprs[rn], cpu->shifterOperand, cpu->gprs[rd]),
492 cpu->gprs[rd] = cpu->gprs[rn] | cpu->shifterOperand;)
493
494DEFINE_ALU_INSTRUCTION_ARM(RSB, ARM_SUBTRACTION_S(cpu->shifterOperand, n, cpu->gprs[rd]),
495 int32_t n = cpu->gprs[rn];
496 cpu->gprs[rd] = cpu->shifterOperand - n;)
497
498DEFINE_ALU_INSTRUCTION_ARM(RSC, ARM_SUBTRACTION_S(cpu->shifterOperand, n, cpu->gprs[rd]),
499 int32_t n = cpu->gprs[rn] + !cpu->cpsr.c;
500 cpu->gprs[rd] = cpu->shifterOperand - n;)
501
502DEFINE_ALU_INSTRUCTION_ARM(SBC, ARM_SUBTRACTION_S(n, shifterOperand, cpu->gprs[rd]),
503 int32_t n = cpu->gprs[rn];
504 int32_t shifterOperand = cpu->shifterOperand + !cpu->cpsr.c;
505 cpu->gprs[rd] = n - shifterOperand;)
506
507DEFINE_ALU_INSTRUCTION_ARM(SUB, ARM_SUBTRACTION_S(n, cpu->shifterOperand, cpu->gprs[rd]),
508 int32_t n = cpu->gprs[rn];
509 cpu->gprs[rd] = n - cpu->shifterOperand;)
510
511DEFINE_ALU_INSTRUCTION_S_ONLY_ARM(TEQ, ARM_NEUTRAL_S(cpu->gprs[rn], cpu->shifterOperand, aluOut),
512 int32_t aluOut = cpu->gprs[rn] ^ cpu->shifterOperand;)
513
514DEFINE_ALU_INSTRUCTION_S_ONLY_ARM(TST, ARM_NEUTRAL_S(cpu->gprs[rn], cpu->shifterOperand, aluOut),
515 int32_t aluOut = cpu->gprs[rn] & cpu->shifterOperand;)
516
517// End ALU definitions
518
519// Begin multiply definitions
520
521DEFINE_MULTIPLY_INSTRUCTION_ARM(MLA, cpu->gprs[rdHi] = cpu->gprs[rm] * cpu->gprs[rs] + cpu->gprs[rd], ARM_NEUTRAL_S(, , cpu->gprs[rdHi]))
522DEFINE_MULTIPLY_INSTRUCTION_ARM(MUL, cpu->gprs[rdHi] = cpu->gprs[rm] * cpu->gprs[rs], ARM_NEUTRAL_S(cpu->gprs[rm], cpu->gprs[rs], cpu->gprs[rd]))
523DEFINE_INSTRUCTION_ARM(SMLAL, ARM_STUB)
524DEFINE_INSTRUCTION_ARM(SMLALS, ARM_STUB)
525DEFINE_MULTIPLY_INSTRUCTION_ARM(SMULL,
526 int64_t d = ((int64_t) cpu->gprs[rm]) * ((int64_t) cpu->gprs[rs]);
527 cpu->gprs[rd] = d;
528 cpu->gprs[rdHi] = d >> 32;,
529 ARM_NEUTRAL_HI_S(cpu->gprs[rd], cpu->gprs[rdHi]))
530DEFINE_INSTRUCTION_ARM(UMLAL, ARM_STUB)
531DEFINE_INSTRUCTION_ARM(UMLALS, ARM_STUB)
532DEFINE_MULTIPLY_INSTRUCTION_ARM(UMULL,
533 uint64_t d = ((uint64_t) cpu->gprs[rm]) * ((uint64_t) cpu->gprs[rs]);
534 cpu->gprs[rd] = d;
535 cpu->gprs[rdHi] = d >> 32;,
536 ARM_NEUTRAL_HI_S(cpu->gprs[rd], cpu->gprs[rdHi]))
537
538// End multiply definitions
539
540// Begin load/store definitions
541
542DEFINE_LOAD_STORE_INSTRUCTION_ARM(LDR, cpu->gprs[rd] = cpu->memory->load32(cpu->memory, address); ARM_LOAD_POST_BODY;)
543DEFINE_LOAD_STORE_INSTRUCTION_ARM(LDRB, cpu->gprs[rd] = cpu->memory->loadU8(cpu->memory, address); ARM_LOAD_POST_BODY;)
544DEFINE_LOAD_STORE_MODE_3_INSTRUCTION_ARM(LDRH, cpu->gprs[rd] = cpu->memory->loadU16(cpu->memory, address); ARM_LOAD_POST_BODY;)
545DEFINE_LOAD_STORE_MODE_3_INSTRUCTION_ARM(LDRSB, cpu->gprs[rd] = cpu->memory->load8(cpu->memory, address); ARM_LOAD_POST_BODY;)
546DEFINE_LOAD_STORE_MODE_3_INSTRUCTION_ARM(LDRSH, cpu->gprs[rd] = cpu->memory->load16(cpu->memory, address); ARM_LOAD_POST_BODY;)
547DEFINE_LOAD_STORE_INSTRUCTION_ARM(STR, cpu->memory->store32(cpu->memory, address, cpu->gprs[rd]))
548DEFINE_LOAD_STORE_INSTRUCTION_ARM(STRB, cpu->memory->store8(cpu->memory, address, cpu->gprs[rd]))
549DEFINE_LOAD_STORE_MODE_3_INSTRUCTION_ARM(STRH, cpu->memory->store16(cpu->memory, address, cpu->gprs[rd]))
550
551DEFINE_LOAD_STORE_T_INSTRUCTION_ARM(LDRBT,
552 enum PrivilegeMode priv = cpu->privilegeMode;
553 ARMSetPrivilegeMode(cpu, MODE_USER);
554 cpu->gprs[rd] = cpu->memory->loadU8(cpu->memory, address);
555 ARMSetPrivilegeMode(cpu, priv);
556 ARM_LOAD_POST_BODY;)
557
558DEFINE_LOAD_STORE_T_INSTRUCTION_ARM(LDRT,
559 enum PrivilegeMode priv = cpu->privilegeMode;
560 ARMSetPrivilegeMode(cpu, MODE_USER);
561 cpu->gprs[rd] = cpu->memory->load32(cpu->memory, address);
562 ARMSetPrivilegeMode(cpu, priv);
563 ARM_LOAD_POST_BODY;)
564
565DEFINE_LOAD_STORE_T_INSTRUCTION_ARM(STRBT,
566 enum PrivilegeMode priv = cpu->privilegeMode;
567 ARMSetPrivilegeMode(cpu, MODE_USER);
568 cpu->memory->store32(cpu->memory, address, cpu->gprs[rd]);
569 ARMSetPrivilegeMode(cpu, priv);)
570
571DEFINE_LOAD_STORE_T_INSTRUCTION_ARM(STRT,
572 enum PrivilegeMode priv = cpu->privilegeMode;
573 ARMSetPrivilegeMode(cpu, MODE_USER);
574 cpu->memory->store8(cpu->memory, address, cpu->gprs[rd]);
575 ARMSetPrivilegeMode(cpu, priv);)
576
577DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(LDM,
578 cpu->gprs[i] = cpu->memory->load32(cpu->memory, addr);,
579 if (rs & 0x8000) {
580 ARM_WRITE_PC;
581 })
582
583DEFINE_LOAD_STORE_MULTIPLE_INSTRUCTION_ARM(STM, cpu->memory->store32(cpu->memory, addr, cpu->gprs[i]);, )
584
585DEFINE_INSTRUCTION_ARM(SWP, ARM_STUB)
586DEFINE_INSTRUCTION_ARM(SWPB, ARM_STUB)
587
588// End load/store definitions
589
590// Begin branch definitions
591
592DEFINE_INSTRUCTION_ARM(B,
593 int32_t offset = opcode << 8;
594 offset >>= 6;
595 cpu->gprs[ARM_PC] += offset;
596 ARM_WRITE_PC;)
597
598DEFINE_INSTRUCTION_ARM(BL,
599 int32_t immediate = (opcode & 0x00FFFFFF) << 8;
600 cpu->gprs[ARM_LR] = cpu->gprs[ARM_PC] - WORD_SIZE_ARM;
601 cpu->gprs[ARM_PC] += immediate >> 6;
602 ARM_WRITE_PC;)
603
604DEFINE_INSTRUCTION_ARM(BX,
605 int rm = opcode & 0x0000000F;
606 _ARMSetMode(cpu, cpu->gprs[rm] & 0x00000001);
607 cpu->gprs[ARM_PC] = cpu->gprs[rm] & 0xFFFFFFFE;
608 if (cpu->executionMode == MODE_THUMB) {
609 THUMB_WRITE_PC;
610 } else {
611 ARM_WRITE_PC;
612 })
613
614// End branch definitions
615
616// Begin miscellaneous definitions
617
618DEFINE_INSTRUCTION_ARM(BKPT, ARM_STUB) // Not strictly in ARMv4T, but here for convenience
619DEFINE_INSTRUCTION_ARM(ILL, ARM_STUB) // Illegal opcode
620
621DEFINE_INSTRUCTION_ARM(MSR,
622 int c = opcode & 0x00010000;
623 int f = opcode & 0x00080000;
624 int32_t operand = cpu->gprs[opcode & 0x0000000F];
625 int32_t mask = (c ? 0x000000FF : 0) | (f ? 0xFF000000 : 0);
626 if (mask & PSR_USER_MASK) {
627 cpu->cpsr.packed = (cpu->cpsr.packed & ~PSR_USER_MASK) | (operand & PSR_USER_MASK);
628 }
629 if (cpu->privilegeMode != MODE_USER && (mask & PSR_PRIV_MASK)) {
630 ARMSetPrivilegeMode(cpu, (enum PrivilegeMode) ((operand & 0x0000000F) | 0x00000010));
631 cpu->cpsr.packed = (cpu->cpsr.packed & ~PSR_PRIV_MASK) | (operand & PSR_PRIV_MASK);
632 })
633
634DEFINE_INSTRUCTION_ARM(MSRR,
635 int c = opcode & 0x00010000;
636 int f = opcode & 0x00080000;
637 int32_t operand = cpu->gprs[opcode & 0x0000000F];
638 int32_t mask = (c ? 0x000000FF : 0) | (f ? 0xFF000000 : 0);
639 mask &= PSR_USER_MASK | PSR_PRIV_MASK | PSR_STATE_MASK;
640 cpu->spsr.packed = (cpu->spsr.packed & ~mask) | (operand & mask);)
641
642DEFINE_INSTRUCTION_ARM(MRS, \
643 int rd = (opcode >> 12) & 0xF; \
644 cpu->gprs[rd] = cpu->cpsr.packed;)
645
646DEFINE_INSTRUCTION_ARM(MRSR, \
647 int rd = (opcode >> 12) & 0xF; \
648 cpu->gprs[rd] = cpu->spsr.packed;)
649
650DEFINE_INSTRUCTION_ARM(MSRI,
651 int c = opcode & 0x00010000;
652 int f = opcode & 0x00080000;
653 int rotate = (opcode & 0x00000F00) >> 8;
654 int32_t operand = ARM_ROR(opcode & 0x000000FF, rotate);
655 int32_t mask = (c ? 0x000000FF : 0) | (f ? 0xFF000000 : 0);
656 if (mask & PSR_USER_MASK) {
657 cpu->cpsr.packed = (cpu->cpsr.packed & ~PSR_USER_MASK) | (operand & PSR_USER_MASK);
658 }
659 if (cpu->privilegeMode != MODE_USER && (mask & PSR_PRIV_MASK)) {
660 ARMSetPrivilegeMode(cpu, (enum PrivilegeMode) ((operand & 0x0000000F) | 0x00000010));
661 cpu->cpsr.packed = (cpu->cpsr.packed & ~PSR_PRIV_MASK) | (operand & PSR_PRIV_MASK);
662 })
663
664DEFINE_INSTRUCTION_ARM(MSRRI,
665 int c = opcode & 0x00010000;
666 int f = opcode & 0x00080000;
667 int rotate = (opcode & 0x00000F00) >> 8;
668 int32_t operand = ARM_ROR(opcode & 0x000000FF, rotate);
669 int32_t mask = (c ? 0x000000FF : 0) | (f ? 0xFF000000 : 0);
670 mask &= PSR_USER_MASK | PSR_PRIV_MASK | PSR_STATE_MASK;
671 cpu->spsr.packed = (cpu->spsr.packed & ~mask) | (operand & mask);)
672
673DEFINE_INSTRUCTION_ARM(SWI, cpu->board->swi32(cpu->board, opcode & 0xFFFFFF))
674
675#define DECLARE_INSTRUCTION_ARM(EMITTER, NAME) \
676 EMITTER ## NAME
677
678#define DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, ALU) \
679 DO_8(DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## I)), \
680 DO_8(DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## I))
681
682#define DECLARE_ARM_ALU_BLOCK(EMITTER, ALU, EX1, EX2, EX3, EX4) \
683 DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## _LSL), \
684 DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## _LSLR), \
685 DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## _LSR), \
686 DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## _LSRR), \
687 DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## _ASR), \
688 DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## _ASRR), \
689 DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## _ROR), \
690 DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## _RORR), \
691 DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## _LSL), \
692 DECLARE_INSTRUCTION_ARM(EMITTER, EX1), \
693 DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## _LSR), \
694 DECLARE_INSTRUCTION_ARM(EMITTER, EX2), \
695 DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## _ASR), \
696 DECLARE_INSTRUCTION_ARM(EMITTER, EX3), \
697 DECLARE_INSTRUCTION_ARM(EMITTER, ALU ## _ROR), \
698 DECLARE_INSTRUCTION_ARM(EMITTER, EX4)
699
700#define DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, NAME, P, U, W) \
701 DO_8(DECLARE_INSTRUCTION_ARM(EMITTER, NAME ## I ## P ## U ## W)), \
702 DO_8(DECLARE_INSTRUCTION_ARM(EMITTER, NAME ## I ## P ## U ## W))
703
704#define DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, NAME, P, U, W) \
705 DECLARE_INSTRUCTION_ARM(EMITTER, NAME ## _LSL_ ## P ## U ## W), \
706 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
707 DECLARE_INSTRUCTION_ARM(EMITTER, NAME ## _LSR_ ## P ## U ## W), \
708 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
709 DECLARE_INSTRUCTION_ARM(EMITTER, NAME ## _ASR_ ## P ## U ## W), \
710 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
711 DECLARE_INSTRUCTION_ARM(EMITTER, NAME ## _ROR_ ## P ## U ## W), \
712 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
713 DECLARE_INSTRUCTION_ARM(EMITTER, NAME ## _LSL_ ## P ## U ## W), \
714 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
715 DECLARE_INSTRUCTION_ARM(EMITTER, NAME ## _LSR_ ## P ## U ## W), \
716 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
717 DECLARE_INSTRUCTION_ARM(EMITTER, NAME ## _ASR_ ## P ## U ## W), \
718 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
719 DECLARE_INSTRUCTION_ARM(EMITTER, NAME ## _ROR_ ## P ## U ## W), \
720 DECLARE_INSTRUCTION_ARM(EMITTER, ILL)
721
722#define DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, NAME, MODE, W) \
723 DO_8(DECLARE_INSTRUCTION_ARM(EMITTER, NAME ## MODE ## W)), \
724 DO_8(DECLARE_INSTRUCTION_ARM(EMITTER, NAME ## MODE ## W))
725
726#define DECLARE_ARM_BRANCH_BLOCK(EMITTER, NAME) \
727 DO_256(DECLARE_INSTRUCTION_ARM(EMITTER, NAME))
728
729// TODO: Support coprocessors
730#define DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, NAME, P, U, W, N) \
731 DO_8(0), \
732 DO_8(0)
733
734#define DECLARE_ARM_COPROCESSOR_BLOCK(EMITTER, NAME1, NAME2) \
735 DO_8(DO_8(DO_INTERLACE(0, 0))), \
736 DO_8(DO_8(DO_INTERLACE(0, 0)))
737
738#define DECLARE_ARM_SWI_BLOCK(EMITTER) \
739 DO_256(DECLARE_INSTRUCTION_ARM(EMITTER, SWI))
740
741#define DECLARE_ARM_EMITTER_BLOCK(EMITTER) \
742 DECLARE_ARM_ALU_BLOCK(EMITTER, AND, MUL, STRH, ILL, ILL), \
743 DECLARE_ARM_ALU_BLOCK(EMITTER, ANDS, MULS, LDRH, LDRSB, LDRSH), \
744 DECLARE_ARM_ALU_BLOCK(EMITTER, EOR, MLA, ILL, ILL, ILL), \
745 DECLARE_ARM_ALU_BLOCK(EMITTER, EORS, MLAS, ILL, ILL, ILL), \
746 DECLARE_ARM_ALU_BLOCK(EMITTER, SUB, ILL, STRHI, ILL, ILL), \
747 DECLARE_ARM_ALU_BLOCK(EMITTER, SUBS, ILL, LDRHI, LDRSBI, LDRSHI), \
748 DECLARE_ARM_ALU_BLOCK(EMITTER, RSB, ILL, ILL, ILL, ILL), \
749 DECLARE_ARM_ALU_BLOCK(EMITTER, RSBS, ILL, ILL, ILL, ILL), \
750 DECLARE_ARM_ALU_BLOCK(EMITTER, ADD, UMULL, STRHU, ILL, ILL), \
751 DECLARE_ARM_ALU_BLOCK(EMITTER, ADDS, UMULLS, LDRHU, LDRSBU, LDRSHU), \
752 DECLARE_ARM_ALU_BLOCK(EMITTER, ADC, UMLAL, ILL, ILL, ILL), \
753 DECLARE_ARM_ALU_BLOCK(EMITTER, ADCS, UMLALS, ILL, ILL, ILL), \
754 DECLARE_ARM_ALU_BLOCK(EMITTER, SBC, SMULL, STRHIU, ILL, ILL), \
755 DECLARE_ARM_ALU_BLOCK(EMITTER, SBCS, SMULLS, LDRHIU, LDRSBIU, LDRSHIU), \
756 DECLARE_ARM_ALU_BLOCK(EMITTER, RSC, SMLAL, ILL, ILL, ILL), \
757 DECLARE_ARM_ALU_BLOCK(EMITTER, RSCS, SMLALS, ILL, ILL, ILL), \
758 DECLARE_INSTRUCTION_ARM(EMITTER, MRS), \
759 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
760 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
761 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
762 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
763 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
764 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
765 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
766 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
767 DECLARE_INSTRUCTION_ARM(EMITTER, SWP), \
768 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
769 DECLARE_INSTRUCTION_ARM(EMITTER, STRHP), \
770 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
771 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
772 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
773 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
774 DECLARE_ARM_ALU_BLOCK(EMITTER, TST, ILL, LDRHP, LDRSBP, LDRSHP), \
775 DECLARE_INSTRUCTION_ARM(EMITTER, MSR), \
776 DECLARE_INSTRUCTION_ARM(EMITTER, BX), \
777 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
778 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
779 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
780 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
781 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
782 DECLARE_INSTRUCTION_ARM(EMITTER, BKPT), \
783 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
784 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
785 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
786 DECLARE_INSTRUCTION_ARM(EMITTER, STRHPW), \
787 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
788 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
789 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
790 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
791 DECLARE_ARM_ALU_BLOCK(EMITTER, TEQ, ILL, LDRHPW, LDRSBPW, LDRSHPW), \
792 DECLARE_INSTRUCTION_ARM(EMITTER, MRSR), \
793 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
794 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
795 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
796 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
797 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
798 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
799 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
800 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
801 DECLARE_INSTRUCTION_ARM(EMITTER, SWPB), \
802 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
803 DECLARE_INSTRUCTION_ARM(EMITTER, STRHIP), \
804 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
805 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
806 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
807 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
808 DECLARE_ARM_ALU_BLOCK(EMITTER, CMP, ILL, LDRHIP, LDRSBIP, LDRSHIP), \
809 DECLARE_INSTRUCTION_ARM(EMITTER, MSRR), \
810 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
811 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
812 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
813 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
814 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
815 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
816 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
817 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
818 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
819 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
820 DECLARE_INSTRUCTION_ARM(EMITTER, STRHIPW), \
821 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
822 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
823 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
824 DECLARE_INSTRUCTION_ARM(EMITTER, ILL), \
825 DECLARE_ARM_ALU_BLOCK(EMITTER, CMN, ILL, LDRHIPW, LDRSBIPW, LDRSHIPW), \
826 DECLARE_ARM_ALU_BLOCK(EMITTER, ORR, SMLAL, STRHPU, ILL, ILL), \
827 DECLARE_ARM_ALU_BLOCK(EMITTER, ORRS, SMLALS, LDRHPU, LDRSBPU, LDRSHPU), \
828 DECLARE_ARM_ALU_BLOCK(EMITTER, MOV, SMLAL, STRHPUW, ILL, ILL), \
829 DECLARE_ARM_ALU_BLOCK(EMITTER, MOVS, SMLALS, LDRHPUW, LDRSBPUW, LDRSHPUW), \
830 DECLARE_ARM_ALU_BLOCK(EMITTER, BIC, SMLAL, STRHIPU, ILL, ILL), \
831 DECLARE_ARM_ALU_BLOCK(EMITTER, BICS, SMLALS, LDRHIPU, LDRSBIPU, LDRSHIPU), \
832 DECLARE_ARM_ALU_BLOCK(EMITTER, MVN, SMLAL, STRHIPUW, ILL, ILL), \
833 DECLARE_ARM_ALU_BLOCK(EMITTER, MVNS, SMLALS, LDRHIPUW, LDRSBIPUW, LDRSHIPUW), \
834 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, AND), \
835 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, ANDS), \
836 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, EOR), \
837 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, EORS), \
838 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, SUB), \
839 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, SUBS), \
840 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, RSB), \
841 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, RSBS), \
842 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, ADD), \
843 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, ADDS), \
844 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, ADC), \
845 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, ADCS), \
846 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, SBC), \
847 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, SBCS), \
848 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, RSC), \
849 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, RSCS), \
850 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, TST), \
851 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, TST), \
852 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, MSR), \
853 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, TEQ), \
854 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, CMP), \
855 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, CMP), \
856 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, MSRR), \
857 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, CMN), \
858 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, ORR), \
859 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, ORRS), \
860 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, MOV), \
861 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, MOVS), \
862 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, BIC), \
863 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, BICS), \
864 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, MVN), \
865 DECLARE_ARM_ALU_IMMEDIATE_BLOCK(EMITTER, MVNS), \
866 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STR, , , ), \
867 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDR, , , ), \
868 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STRT, , , ), \
869 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDRT, , , ), \
870 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STRB, , , ), \
871 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDRB, , , ), \
872 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STRBT, , , ), \
873 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDRBT, , , ), \
874 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STR, , U, ), \
875 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDR, , U, ), \
876 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STRT, , U, ), \
877 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDRT, , U, ), \
878 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STRB, , U, ), \
879 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDRB, , U, ), \
880 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STRBT, , U, ), \
881 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDRBT, , U, ), \
882 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STR, P, , ), \
883 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDR, P, , ), \
884 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STR, P, , W), \
885 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDR, P, , W), \
886 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STRB, P, , ), \
887 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDRB, P, , ), \
888 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STRB, P, , W), \
889 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDRB, P, , W), \
890 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STR, P, U, ), \
891 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDR, P, U, ), \
892 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STR, P, U, W), \
893 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDR, P, U, W), \
894 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STRB, P, U, ), \
895 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDRB, P, U, ), \
896 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, STRB, P, U, W), \
897 DECLARE_ARM_LOAD_STORE_IMMEDIATE_BLOCK(EMITTER, LDRB, P, U, W), \
898 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STR, , , ), \
899 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDR, , , ), \
900 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STRT, , , ), \
901 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDRT, , , ), \
902 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STRB, , , ), \
903 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDRB, , , ), \
904 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STRBT, , , ), \
905 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDRBT, , , ), \
906 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STR, , U, ), \
907 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDR, , U, ), \
908 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STRT, , U, ), \
909 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDRT, , U, ), \
910 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STRB, , U, ), \
911 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDRB, , U, ), \
912 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STRBT, , U, ), \
913 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDRBT, , U, ), \
914 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STR, P, , ), \
915 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDR, P, , ), \
916 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STR, P, , W), \
917 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDR, P, , W), \
918 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STRB, P, , ), \
919 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDRB, P, , ), \
920 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STRB, P, , W), \
921 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDRB, P, , W), \
922 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STR, P, U, ), \
923 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDR, P, U, ), \
924 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STR, P, U, W), \
925 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDR, P, U, W), \
926 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STRB, P, U, ), \
927 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDRB, P, U, ), \
928 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, STRB, P, U, W), \
929 DECLARE_ARM_LOAD_STORE_BLOCK(EMITTER, LDRB, P, U, W), \
930 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STM, DA, ), \
931 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDM, DA, ), \
932 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STM, DA, W), \
933 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDM, DA, W), \
934 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STMS, DA, ), \
935 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDMS, DA, ), \
936 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STMS, DA, W), \
937 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDMS, DA, W), \
938 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STM, IA, ), \
939 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDM, IA, ), \
940 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STM, IA, W), \
941 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDM, IA, W), \
942 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STMS, IA, ), \
943 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDMS, IA, ), \
944 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STMS, IA, W), \
945 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDMS, IA, W), \
946 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STM, DB, ), \
947 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDM, DB, ), \
948 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STM, DB, W), \
949 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDM, DB, W), \
950 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STMS, DB, ), \
951 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDMS, DB, ), \
952 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STMS, DB, W), \
953 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDMS, DB, W), \
954 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STM, IB, ), \
955 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDM, IB, ), \
956 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STM, IB, W), \
957 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDM, IB, W), \
958 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STMS, IB, ), \
959 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDMS, IB, ), \
960 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, STMS, IB, W), \
961 DECLARE_ARM_LOAD_STORE_MULTIPLE_BLOCK(EMITTER, LDMS, IB, W), \
962 DECLARE_ARM_BRANCH_BLOCK(EMITTER, B), \
963 DECLARE_ARM_BRANCH_BLOCK(EMITTER, BL), \
964 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, , , , ), \
965 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, , , , ), \
966 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, , , , W), \
967 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, , , , W), \
968 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, , , N, ), \
969 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, , , N, ), \
970 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, , , N, W), \
971 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, , , N, W), \
972 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, , U, , ), \
973 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, , U, , ), \
974 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, , U, , W), \
975 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, , U, , W), \
976 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, , U, N, ), \
977 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, , U, N, ), \
978 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, , U, N, W), \
979 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, , U, N, W), \
980 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, P, , , ), \
981 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, P, , , ), \
982 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, P, , , W), \
983 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, P, , , W), \
984 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, P, U, N, ), \
985 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, P, U, N, ), \
986 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, P, U, N, W), \
987 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, P, U, N, W), \
988 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, P, , N, ), \
989 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, P, , N, ), \
990 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, P, , N, W), \
991 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, P, , N, W), \
992 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, P, U, N, ), \
993 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, P, U, N, ), \
994 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, STC, P, U, N, W), \
995 DECLARE_ARM_LOAD_STORE_COPROCESSOR_BLOCK(EMITTER, LDC, P, U, N, W), \
996 DECLARE_ARM_COPROCESSOR_BLOCK(EMITTER, CDP, MCR), \
997 DECLARE_ARM_SWI_BLOCK(EMITTER)
998
999static const ARMInstruction _armTable[0x1000] = {
1000 DECLARE_ARM_EMITTER_BLOCK(_ARMInstruction)
1001};