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