OSDN Git Service

9fa9160bbc5292b999416dbb39c8e2f5c6df58f8
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / cgen-cpu / arm7t / thumb-semsw.cxx
1 /* Simulator instruction semantics for thumb.
2
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
4
5 Copyright (C) 2000-2009 Red Hat, Inc.
6
7 This file is part of the Red Hat simulators.
8
9
10 */
11
12
13 #include "arm7f.h"
14
15 using namespace arm7f; // FIXME: namespace organization still wip
16
17 #define GET_ATTR(name) GET_ATTR_##name ()
18
19
20 void
21 arm7f_cpu::thumb_pbb_run ()
22 {
23   arm7f_cpu* current_cpu = this;
24   thumb_scache* vpc;
25   // These two are used to pass data from cti insns to the cti-chain insn.
26   PCADDR pbb_br_npc;
27   branch_status pbb_br_status;
28
29 #ifdef __GNUC__
30 {
31   static const struct sem_labels
32     {
33       enum thumb_insn_type insn;
34       void *label;
35     }
36   labels[] = 
37     {
38       { THUMB_INSN_X_AFTER, && case_INSN_X_AFTER },
39       { THUMB_INSN_X_BEFORE, && case_INSN_X_BEFORE },
40       { THUMB_INSN_X_CTI_CHAIN, && case_INSN_X_CTI_CHAIN },
41       { THUMB_INSN_X_CHAIN, && case_INSN_X_CHAIN },
42       { THUMB_INSN_X_BEGIN, && case_INSN_X_BEGIN },
43       { THUMB_INSN_X_INVALID, && case_INSN_X_INVALID },
44       { THUMB_INSN_LSL, && case_INSN_LSL },
45       { THUMB_INSN_LSR, && case_INSN_LSR },
46       { THUMB_INSN_ASR, && case_INSN_ASR },
47       { THUMB_INSN_ADD, && case_INSN_ADD },
48       { THUMB_INSN_ADDI, && case_INSN_ADDI },
49       { THUMB_INSN_SUB, && case_INSN_SUB },
50       { THUMB_INSN_SUBI, && case_INSN_SUBI },
51       { THUMB_INSN_MOV, && case_INSN_MOV },
52       { THUMB_INSN_CMP, && case_INSN_CMP },
53       { THUMB_INSN_ADDI8, && case_INSN_ADDI8 },
54       { THUMB_INSN_SUBI8, && case_INSN_SUBI8 },
55       { THUMB_INSN_ALU_AND, && case_INSN_ALU_AND },
56       { THUMB_INSN_ALU_EOR, && case_INSN_ALU_EOR },
57       { THUMB_INSN_ALU_LSL, && case_INSN_ALU_LSL },
58       { THUMB_INSN_ALU_LSR, && case_INSN_ALU_LSR },
59       { THUMB_INSN_ALU_ASR, && case_INSN_ALU_ASR },
60       { THUMB_INSN_ALU_ROR, && case_INSN_ALU_ROR },
61       { THUMB_INSN_ALU_ADC, && case_INSN_ALU_ADC },
62       { THUMB_INSN_ALU_SBC, && case_INSN_ALU_SBC },
63       { THUMB_INSN_ALU_TST, && case_INSN_ALU_TST },
64       { THUMB_INSN_ALU_NEG, && case_INSN_ALU_NEG },
65       { THUMB_INSN_ALU_CMP, && case_INSN_ALU_CMP },
66       { THUMB_INSN_ALU_CMN, && case_INSN_ALU_CMN },
67       { THUMB_INSN_ALU_ORR, && case_INSN_ALU_ORR },
68       { THUMB_INSN_ALU_MUL, && case_INSN_ALU_MUL },
69       { THUMB_INSN_ALU_BIC, && case_INSN_ALU_BIC },
70       { THUMB_INSN_ALU_MVN, && case_INSN_ALU_MVN },
71       { THUMB_INSN_ADD_RD_HS, && case_INSN_ADD_RD_HS },
72       { THUMB_INSN_ADD_HD_RS, && case_INSN_ADD_HD_RS },
73       { THUMB_INSN_ADD_HD_HS, && case_INSN_ADD_HD_HS },
74       { THUMB_INSN_CMP_RD_HS, && case_INSN_CMP_RD_HS },
75       { THUMB_INSN_CMP_HD_RS, && case_INSN_CMP_HD_RS },
76       { THUMB_INSN_CMP_HD_HS, && case_INSN_CMP_HD_HS },
77       { THUMB_INSN_MOV_RD_HS, && case_INSN_MOV_RD_HS },
78       { THUMB_INSN_MOV_HD_RS, && case_INSN_MOV_HD_RS },
79       { THUMB_INSN_MOV_HD_HS, && case_INSN_MOV_HD_HS },
80       { THUMB_INSN_BX_RS, && case_INSN_BX_RS },
81       { THUMB_INSN_BX_HS, && case_INSN_BX_HS },
82       { THUMB_INSN_LDR_PC, && case_INSN_LDR_PC },
83       { THUMB_INSN_STR, && case_INSN_STR },
84       { THUMB_INSN_STRB, && case_INSN_STRB },
85       { THUMB_INSN_LDR, && case_INSN_LDR },
86       { THUMB_INSN_LDRB, && case_INSN_LDRB },
87       { THUMB_INSN_STRH, && case_INSN_STRH },
88       { THUMB_INSN_LDRH, && case_INSN_LDRH },
89       { THUMB_INSN_LDSB, && case_INSN_LDSB },
90       { THUMB_INSN_LDSH, && case_INSN_LDSH },
91       { THUMB_INSN_STR_IMM, && case_INSN_STR_IMM },
92       { THUMB_INSN_LDR_IMM, && case_INSN_LDR_IMM },
93       { THUMB_INSN_STRB_IMM, && case_INSN_STRB_IMM },
94       { THUMB_INSN_LDRB_IMM, && case_INSN_LDRB_IMM },
95       { THUMB_INSN_STRH_IMM, && case_INSN_STRH_IMM },
96       { THUMB_INSN_LDRH_IMM, && case_INSN_LDRH_IMM },
97       { THUMB_INSN_STR_SPREL, && case_INSN_STR_SPREL },
98       { THUMB_INSN_LDR_SPREL, && case_INSN_LDR_SPREL },
99       { THUMB_INSN_LDA_PC, && case_INSN_LDA_PC },
100       { THUMB_INSN_LDA_SP, && case_INSN_LDA_SP },
101       { THUMB_INSN_ADD_SP, && case_INSN_ADD_SP },
102       { THUMB_INSN_SUB_SP, && case_INSN_SUB_SP },
103       { THUMB_INSN_PUSH, && case_INSN_PUSH },
104       { THUMB_INSN_PUSH_LR, && case_INSN_PUSH_LR },
105       { THUMB_INSN_POP, && case_INSN_POP },
106       { THUMB_INSN_POP_PC, && case_INSN_POP_PC },
107       { THUMB_INSN_STMIA, && case_INSN_STMIA },
108       { THUMB_INSN_LDMIA, && case_INSN_LDMIA },
109       { THUMB_INSN_BEQ, && case_INSN_BEQ },
110       { THUMB_INSN_BNE, && case_INSN_BNE },
111       { THUMB_INSN_BCS, && case_INSN_BCS },
112       { THUMB_INSN_BCC, && case_INSN_BCC },
113       { THUMB_INSN_BMI, && case_INSN_BMI },
114       { THUMB_INSN_BPL, && case_INSN_BPL },
115       { THUMB_INSN_BVS, && case_INSN_BVS },
116       { THUMB_INSN_BVC, && case_INSN_BVC },
117       { THUMB_INSN_BHI, && case_INSN_BHI },
118       { THUMB_INSN_BLS, && case_INSN_BLS },
119       { THUMB_INSN_BGE, && case_INSN_BGE },
120       { THUMB_INSN_BLT, && case_INSN_BLT },
121       { THUMB_INSN_BGT, && case_INSN_BGT },
122       { THUMB_INSN_BLE, && case_INSN_BLE },
123       { THUMB_INSN_SWI, && case_INSN_SWI },
124       { THUMB_INSN_B, && case_INSN_B },
125       { THUMB_INSN_BL_HI, && case_INSN_BL_HI },
126       { THUMB_INSN_BL_LO, && case_INSN_BL_LO },
127     { (thumb_insn_type) 0, 0 }
128   };
129
130   if (! thumb_idesc::idesc_table_initialized_p)
131     {
132       for (int i=0; labels[i].label != 0; i++)
133         thumb_idesc::idesc_table[labels[i].insn].cgoto.label = labels[i].label; 
134
135       // confirm that table is all filled up
136       for (int i = 0; i <= THUMB_INSN_BL_LO; i++)
137         assert (thumb_idesc::idesc_table[i].cgoto.label != 0);
138
139       // Initialize the compiler virtual insn.
140       current_cpu->thumb_engine.compile_begin_insn (current_cpu);
141
142       thumb_idesc::idesc_table_initialized_p = true;
143     }
144 }
145 #endif
146
147 #ifdef __GNUC__
148 #define CASE(X) case_##X
149 // Branch to next handler without going around main loop.
150 #define NEXT(vpc) goto * vpc->execute.cgoto.label;
151 // Break out of threaded interpreter and return to "main loop".
152 #define BREAK(vpc) goto end_switch
153 #else
154 #define CASE(X) case THUMB_##X
155 #define NEXT(vpc) goto restart
156 #define BREAK(vpc) break
157 #endif
158
159   // Get next insn to execute.
160   vpc = current_cpu->thumb_engine.get_next_vpc (current_cpu->h_pc_get ());
161
162 restart:
163 #ifdef __GNUC__
164   goto * vpc->execute.cgoto.label;
165 #else
166   switch (vpc->idesc->sem_index)
167 #endif
168
169   {
170 // ********** --after--
171
172   CASE (INSN_X_AFTER):
173     {
174       thumb_scache* abuf = vpc;
175 #define FLD(f) abuf->fields.fmt_empty.f
176       PCADDR pc = abuf->addr;
177       vpc = vpc + 1;
178
179   {
180     current_cpu->thumb_engine.pbb_after (current_cpu, abuf);
181   }
182
183 #undef FLD
184     }
185     NEXT (vpc);
186
187 // ********** --before--
188
189   CASE (INSN_X_BEFORE):
190     {
191       thumb_scache* abuf = vpc;
192 #define FLD(f) abuf->fields.fmt_empty.f
193       PCADDR pc = abuf->addr;
194       vpc = vpc + 1;
195
196   {
197     current_cpu->thumb_engine.pbb_before (current_cpu, abuf);
198   }
199
200 #undef FLD
201     }
202     NEXT (vpc);
203
204 // ********** --cti-chain--
205
206   CASE (INSN_X_CTI_CHAIN):
207     {
208       thumb_scache* abuf = vpc;
209 #define FLD(f) abuf->fields.fmt_empty.f
210       PCADDR pc = abuf->addr;
211       vpc = vpc + 1;
212
213   {
214     vpc = current_cpu->thumb_engine.pbb_cti_chain (current_cpu, abuf, pbb_br_status, pbb_br_npc);
215     // If we don't have to give up control, don't.
216     // Note that we may overrun step_insn_count since we do the test at the
217     // end of the block.  This is defined to be ok.
218     if (UNLIKELY(current_cpu->stop_after_insns_p (abuf->fields.chain.insn_count)))
219       BREAK (vpc);
220   }
221
222 #undef FLD
223     }
224     NEXT (vpc);
225
226 // ********** --chain--
227
228   CASE (INSN_X_CHAIN):
229     {
230       thumb_scache* abuf = vpc;
231 #define FLD(f) abuf->fields.fmt_empty.f
232       PCADDR pc = abuf->addr;
233       vpc = vpc + 1;
234
235   {
236     vpc = current_cpu->thumb_engine.pbb_chain (current_cpu, abuf);
237     // If we don't have to give up control, don't.
238     // Note that we may overrun step_insn_count since we do the test at the
239     // end of the block.  This is defined to be ok.
240     if (UNLIKELY(current_cpu->stop_after_insns_p (abuf->fields.chain.insn_count)))
241       BREAK (vpc);
242   }
243
244 #undef FLD
245     }
246     NEXT (vpc);
247
248 // ********** --begin--
249
250   CASE (INSN_X_BEGIN):
251     {
252       thumb_scache* abuf = vpc;
253 #define FLD(f) abuf->fields.fmt_empty.f
254       PCADDR pc = abuf->addr;
255       vpc = vpc + 1;
256
257   {
258     vpc = current_cpu->thumb_pbb_begin (current_cpu->h_pc_get ());
259   }
260
261 #undef FLD
262     }
263     NEXT (vpc);
264
265 // ********** --invalid--
266
267   CASE (INSN_X_INVALID):
268     {
269       thumb_scache* abuf = vpc;
270 #define FLD(f) abuf->fields.fmt_empty.f
271       PCADDR pc = abuf->addr;
272       vpc = vpc + 1;
273
274   {
275     current_cpu->invalid_insn (pc);
276     assert (0);
277     /* NOTREACHED */
278   }
279
280 #undef FLD
281     }
282     NEXT (vpc);
283
284 // ********** lsl $rd,$rs,#$offset5
285
286   CASE (INSN_LSL):
287     {
288       thumb_scache* abuf = vpc;
289 #define FLD(f) abuf->fields.sfmt_lsl.f
290       PCADDR pc = abuf->addr;
291       vpc = vpc + 1;
292       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
293
294 {
295   BI tmp_carry_out;
296   tmp_carry_out = current_cpu->compute_carry_out_immshift (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), SHIFT_TYPE_LSL, FLD (f_offset5), current_cpu->hardware.h_cbit);
297 current_cpu->thumb_h_gr_t_set (FLD (f_rd), SLLSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), FLD (f_offset5)));
298 {
299 {
300 current_cpu->hardware.h_zbit = EQSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
301 current_cpu->hardware.h_nbit = LTSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
302 }
303 current_cpu->hardware.h_cbit = tmp_carry_out;
304 }
305 }
306
307 #undef FLD
308     }
309     NEXT (vpc);
310
311 // ********** lsr $rd,$rs,#$offset5
312
313   CASE (INSN_LSR):
314     {
315       thumb_scache* abuf = vpc;
316 #define FLD(f) abuf->fields.sfmt_lsl.f
317       PCADDR pc = abuf->addr;
318       vpc = vpc + 1;
319       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
320
321 {
322   BI tmp_carry_out;
323   tmp_carry_out = current_cpu->compute_carry_out_immshift (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), SHIFT_TYPE_LSR, FLD (f_offset5), current_cpu->hardware.h_cbit);
324 current_cpu->thumb_h_gr_t_set (FLD (f_rd), SRLSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), FLD (f_offset5)));
325 {
326 {
327 current_cpu->hardware.h_zbit = EQSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
328 current_cpu->hardware.h_nbit = LTSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
329 }
330 current_cpu->hardware.h_cbit = tmp_carry_out;
331 }
332 }
333
334 #undef FLD
335     }
336     NEXT (vpc);
337
338 // ********** asr $rd,$rs,#$offset5
339
340   CASE (INSN_ASR):
341     {
342       thumb_scache* abuf = vpc;
343 #define FLD(f) abuf->fields.sfmt_lsl.f
344       PCADDR pc = abuf->addr;
345       vpc = vpc + 1;
346       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
347
348 {
349   BI tmp_carry_out;
350   tmp_carry_out = current_cpu->compute_carry_out_immshift (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), SHIFT_TYPE_ASR, FLD (f_offset5), current_cpu->hardware.h_cbit);
351 current_cpu->thumb_h_gr_t_set (FLD (f_rd), SRASI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), FLD (f_offset5)));
352 {
353 {
354 current_cpu->hardware.h_zbit = EQSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
355 current_cpu->hardware.h_nbit = LTSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
356 }
357 current_cpu->hardware.h_cbit = tmp_carry_out;
358 }
359 }
360
361 #undef FLD
362     }
363     NEXT (vpc);
364
365 // ********** add $rd,$rs,$rn
366
367   CASE (INSN_ADD):
368     {
369       thumb_scache* abuf = vpc;
370 #define FLD(f) abuf->fields.sfmt_add.f
371       PCADDR pc = abuf->addr;
372       vpc = vpc + 1;
373       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
374
375 {
376 {
377   SI tmp_result;
378   tmp_result = ADDCSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->thumb_h_gr_t_get (FLD (f_rn)), 0);
379 {
380 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
381 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
382 }
383 current_cpu->hardware.h_cbit = ADDCFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->thumb_h_gr_t_get (FLD (f_rn)), 0);
384 current_cpu->hardware.h_vbit = ADDOFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->thumb_h_gr_t_get (FLD (f_rn)), 0);
385 }
386 current_cpu->thumb_h_gr_t_set (FLD (f_rd), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->thumb_h_gr_t_get (FLD (f_rn))));
387 }
388
389 #undef FLD
390     }
391     NEXT (vpc);
392
393 // ********** add $rd,$rs,#$offset3
394
395   CASE (INSN_ADDI):
396     {
397       thumb_scache* abuf = vpc;
398 #define FLD(f) abuf->fields.sfmt_addi.f
399       PCADDR pc = abuf->addr;
400       vpc = vpc + 1;
401       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
402
403 {
404 {
405   SI tmp_result;
406   tmp_result = ADDCSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), FLD (f_offset3), 0);
407 {
408 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
409 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
410 }
411 current_cpu->hardware.h_cbit = ADDCFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), FLD (f_offset3), 0);
412 current_cpu->hardware.h_vbit = ADDOFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), FLD (f_offset3), 0);
413 }
414 current_cpu->thumb_h_gr_t_set (FLD (f_rd), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), FLD (f_offset3)));
415 }
416
417 #undef FLD
418     }
419     NEXT (vpc);
420
421 // ********** sub $rd,$rs,$rn
422
423   CASE (INSN_SUB):
424     {
425       thumb_scache* abuf = vpc;
426 #define FLD(f) abuf->fields.sfmt_add.f
427       PCADDR pc = abuf->addr;
428       vpc = vpc + 1;
429       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
430
431 {
432 {
433   SI tmp_result;
434   tmp_result = SUBCSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->thumb_h_gr_t_get (FLD (f_rn)), 0);
435 {
436 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
437 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
438 }
439 current_cpu->hardware.h_cbit = NOTBI (SUBCFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->thumb_h_gr_t_get (FLD (f_rn)), 0));
440 current_cpu->hardware.h_vbit = SUBOFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->thumb_h_gr_t_get (FLD (f_rn)), 0);
441 }
442 current_cpu->thumb_h_gr_t_set (FLD (f_rd), SUBSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->thumb_h_gr_t_get (FLD (f_rn))));
443 }
444
445 #undef FLD
446     }
447     NEXT (vpc);
448
449 // ********** sub $rd,$rs,#$offset3
450
451   CASE (INSN_SUBI):
452     {
453       thumb_scache* abuf = vpc;
454 #define FLD(f) abuf->fields.sfmt_addi.f
455       PCADDR pc = abuf->addr;
456       vpc = vpc + 1;
457       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
458
459 {
460 {
461   SI tmp_result;
462   tmp_result = SUBCSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), FLD (f_offset3), 0);
463 {
464 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
465 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
466 }
467 current_cpu->hardware.h_cbit = NOTBI (SUBCFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), FLD (f_offset3), 0));
468 current_cpu->hardware.h_vbit = SUBOFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), FLD (f_offset3), 0);
469 }
470 current_cpu->thumb_h_gr_t_set (FLD (f_rd), SUBSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), FLD (f_offset3)));
471 }
472
473 #undef FLD
474     }
475     NEXT (vpc);
476
477 // ********** mov ${bit10-rd},#$offset8
478
479   CASE (INSN_MOV):
480     {
481       thumb_scache* abuf = vpc;
482 #define FLD(f) abuf->fields.sfmt_mov.f
483       PCADDR pc = abuf->addr;
484       vpc = vpc + 1;
485       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
486
487 {
488 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rd), FLD (f_offset8));
489 {
490 current_cpu->hardware.h_zbit = EQSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), 0);
491 current_cpu->hardware.h_nbit = LTSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), 0);
492 }
493 }
494
495 #undef FLD
496     }
497     NEXT (vpc);
498
499 // ********** cmp ${bit10-rd},#$offset8
500
501   CASE (INSN_CMP):
502     {
503       thumb_scache* abuf = vpc;
504 #define FLD(f) abuf->fields.sfmt_mov.f
505       PCADDR pc = abuf->addr;
506       vpc = vpc + 1;
507       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
508
509 {
510   SI tmp_result;
511   tmp_result = SUBCSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), FLD (f_offset8), 0);
512 {
513 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
514 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
515 }
516 current_cpu->hardware.h_cbit = NOTBI (SUBCFSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), FLD (f_offset8), 0));
517 current_cpu->hardware.h_vbit = SUBOFSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), FLD (f_offset8), 0);
518 }
519
520 #undef FLD
521     }
522     NEXT (vpc);
523
524 // ********** add ${bit10-rd},#$offset8
525
526   CASE (INSN_ADDI8):
527     {
528       thumb_scache* abuf = vpc;
529 #define FLD(f) abuf->fields.sfmt_mov.f
530       PCADDR pc = abuf->addr;
531       vpc = vpc + 1;
532       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
533
534 {
535 {
536   SI tmp_result;
537   tmp_result = ADDCSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), FLD (f_offset8), 0);
538 {
539 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
540 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
541 }
542 current_cpu->hardware.h_cbit = ADDCFSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), FLD (f_offset8), 0);
543 current_cpu->hardware.h_vbit = ADDOFSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), FLD (f_offset8), 0);
544 }
545 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rd), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), FLD (f_offset8)));
546 }
547
548 #undef FLD
549     }
550     NEXT (vpc);
551
552 // ********** sub ${bit10-rd},#$offset8
553
554   CASE (INSN_SUBI8):
555     {
556       thumb_scache* abuf = vpc;
557 #define FLD(f) abuf->fields.sfmt_mov.f
558       PCADDR pc = abuf->addr;
559       vpc = vpc + 1;
560       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
561
562 {
563 {
564   SI tmp_result;
565   tmp_result = SUBCSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), FLD (f_offset8), 0);
566 {
567 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
568 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
569 }
570 current_cpu->hardware.h_cbit = NOTBI (SUBCFSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), FLD (f_offset8), 0));
571 current_cpu->hardware.h_vbit = SUBOFSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), FLD (f_offset8), 0);
572 }
573 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rd), SUBSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)), FLD (f_offset8)));
574 }
575
576 #undef FLD
577     }
578     NEXT (vpc);
579
580 // ********** and $rd,$rs
581
582   CASE (INSN_ALU_AND):
583     {
584       thumb_scache* abuf = vpc;
585 #define FLD(f) abuf->fields.sfmt_addi.f
586       PCADDR pc = abuf->addr;
587       vpc = vpc + 1;
588       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
589
590 {
591 current_cpu->thumb_h_gr_t_set (FLD (f_rd), ANDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs))));
592 {
593 current_cpu->hardware.h_zbit = EQSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
594 current_cpu->hardware.h_nbit = LTSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
595 }
596 }
597
598 #undef FLD
599     }
600     NEXT (vpc);
601
602 // ********** eor $rd,$rs
603
604   CASE (INSN_ALU_EOR):
605     {
606       thumb_scache* abuf = vpc;
607 #define FLD(f) abuf->fields.sfmt_addi.f
608       PCADDR pc = abuf->addr;
609       vpc = vpc + 1;
610       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
611
612 {
613 current_cpu->thumb_h_gr_t_set (FLD (f_rd), XORSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs))));
614 {
615 current_cpu->hardware.h_zbit = EQSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
616 current_cpu->hardware.h_nbit = LTSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
617 }
618 }
619
620 #undef FLD
621     }
622     NEXT (vpc);
623
624 // ********** lsl $rd,$rs
625
626   CASE (INSN_ALU_LSL):
627     {
628       thumb_scache* abuf = vpc;
629 #define FLD(f) abuf->fields.sfmt_addi.f
630       PCADDR pc = abuf->addr;
631       vpc = vpc + 1;
632       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
633
634 {
635   BI tmp_carry_out;
636   SI tmp_result;
637   tmp_carry_out = current_cpu->compute_carry_out_regshift (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), SHIFT_TYPE_LSL, current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->hardware.h_cbit);
638   tmp_result = SLLSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)));
639 current_cpu->thumb_h_gr_t_set (FLD (f_rd), tmp_result);
640 {
641 {
642 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
643 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
644 }
645 current_cpu->hardware.h_cbit = tmp_carry_out;
646 }
647 }
648
649 #undef FLD
650     }
651     NEXT (vpc);
652
653 // ********** lsr $rd,$rs
654
655   CASE (INSN_ALU_LSR):
656     {
657       thumb_scache* abuf = vpc;
658 #define FLD(f) abuf->fields.sfmt_addi.f
659       PCADDR pc = abuf->addr;
660       vpc = vpc + 1;
661       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
662
663 {
664   BI tmp_carry_out;
665   SI tmp_result;
666   tmp_carry_out = current_cpu->compute_carry_out_regshift (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), SHIFT_TYPE_LSR, current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->hardware.h_cbit);
667   tmp_result = SRLSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)));
668 current_cpu->thumb_h_gr_t_set (FLD (f_rd), tmp_result);
669 {
670 {
671 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
672 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
673 }
674 current_cpu->hardware.h_cbit = tmp_carry_out;
675 }
676 }
677
678 #undef FLD
679     }
680     NEXT (vpc);
681
682 // ********** asr $rd,$rs
683
684   CASE (INSN_ALU_ASR):
685     {
686       thumb_scache* abuf = vpc;
687 #define FLD(f) abuf->fields.sfmt_addi.f
688       PCADDR pc = abuf->addr;
689       vpc = vpc + 1;
690       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
691
692 {
693   BI tmp_carry_out;
694   SI tmp_result;
695   tmp_carry_out = current_cpu->compute_carry_out_regshift (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), SHIFT_TYPE_ASR, current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->hardware.h_cbit);
696   tmp_result = SRASI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)));
697 current_cpu->thumb_h_gr_t_set (FLD (f_rd), tmp_result);
698 {
699 {
700 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
701 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
702 }
703 current_cpu->hardware.h_cbit = tmp_carry_out;
704 }
705 }
706
707 #undef FLD
708     }
709     NEXT (vpc);
710
711 // ********** ror $rd,$rs
712
713   CASE (INSN_ALU_ROR):
714     {
715       thumb_scache* abuf = vpc;
716 #define FLD(f) abuf->fields.sfmt_addi.f
717       PCADDR pc = abuf->addr;
718       vpc = vpc + 1;
719       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
720
721 {
722   BI tmp_carry_out;
723   SI tmp_result;
724   tmp_carry_out = current_cpu->compute_carry_out_regshift (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), SHIFT_TYPE_ROR, current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->hardware.h_cbit);
725   tmp_result = RORSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)));
726 current_cpu->thumb_h_gr_t_set (FLD (f_rd), tmp_result);
727 {
728 {
729 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
730 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
731 }
732 current_cpu->hardware.h_cbit = tmp_carry_out;
733 }
734 }
735
736 #undef FLD
737     }
738     NEXT (vpc);
739
740 // ********** adc $rd,$rs
741
742   CASE (INSN_ALU_ADC):
743     {
744       thumb_scache* abuf = vpc;
745 #define FLD(f) abuf->fields.sfmt_addi.f
746       PCADDR pc = abuf->addr;
747       vpc = vpc + 1;
748       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
749
750 {
751   SI tmp_result;
752   tmp_result = ADDCSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->hardware.h_cbit);
753 {
754   SI tmp_result;
755   tmp_result = ADDCSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->hardware.h_cbit);
756 {
757 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
758 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
759 }
760 current_cpu->hardware.h_cbit = ADDCFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->hardware.h_cbit);
761 current_cpu->hardware.h_vbit = ADDOFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), current_cpu->hardware.h_cbit);
762 }
763 current_cpu->thumb_h_gr_t_set (FLD (f_rd), tmp_result);
764 }
765
766 #undef FLD
767     }
768     NEXT (vpc);
769
770 // ********** sbc $rd,$rs
771
772   CASE (INSN_ALU_SBC):
773     {
774       thumb_scache* abuf = vpc;
775 #define FLD(f) abuf->fields.sfmt_addi.f
776       PCADDR pc = abuf->addr;
777       vpc = vpc + 1;
778       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
779
780 {
781   SI tmp_result;
782   tmp_result = SUBCSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), NOTBI (current_cpu->hardware.h_cbit));
783 {
784   SI tmp_result;
785   tmp_result = SUBCSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), NOTBI (current_cpu->hardware.h_cbit));
786 {
787 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
788 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
789 }
790 current_cpu->hardware.h_cbit = NOTBI (SUBCFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), NOTBI (current_cpu->hardware.h_cbit)));
791 current_cpu->hardware.h_vbit = SUBOFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), NOTBI (current_cpu->hardware.h_cbit));
792 }
793 current_cpu->thumb_h_gr_t_set (FLD (f_rd), tmp_result);
794 }
795
796 #undef FLD
797     }
798     NEXT (vpc);
799
800 // ********** tst $rd,$rs
801
802   CASE (INSN_ALU_TST):
803     {
804       thumb_scache* abuf = vpc;
805 #define FLD(f) abuf->fields.sfmt_addi.f
806       PCADDR pc = abuf->addr;
807       vpc = vpc + 1;
808       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
809
810 {
811   SI tmp_x;
812   tmp_x = ANDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)));
813 {
814 current_cpu->hardware.h_zbit = EQSI (tmp_x, 0);
815 current_cpu->hardware.h_nbit = LTSI (tmp_x, 0);
816 }
817 }
818
819 #undef FLD
820     }
821     NEXT (vpc);
822
823 // ********** neg $rd,$rs
824
825   CASE (INSN_ALU_NEG):
826     {
827       thumb_scache* abuf = vpc;
828 #define FLD(f) abuf->fields.sfmt_addi.f
829       PCADDR pc = abuf->addr;
830       vpc = vpc + 1;
831       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
832
833 {
834   SI tmp_result;
835   tmp_result = NEGSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)));
836 {
837   SI tmp_result;
838   tmp_result = SUBCSI (0, current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 0);
839 {
840 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
841 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
842 }
843 current_cpu->hardware.h_cbit = NOTBI (SUBCFSI (0, current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 0));
844 current_cpu->hardware.h_vbit = SUBOFSI (0, current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 0);
845 }
846 current_cpu->thumb_h_gr_t_set (FLD (f_rd), tmp_result);
847 }
848
849 #undef FLD
850     }
851     NEXT (vpc);
852
853 // ********** cmp $rd,$rs
854
855   CASE (INSN_ALU_CMP):
856     {
857       thumb_scache* abuf = vpc;
858 #define FLD(f) abuf->fields.sfmt_addi.f
859       PCADDR pc = abuf->addr;
860       vpc = vpc + 1;
861       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
862
863 {
864   SI tmp_result;
865   tmp_result = SUBCSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 0);
866 {
867 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
868 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
869 }
870 current_cpu->hardware.h_cbit = NOTBI (SUBCFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 0));
871 current_cpu->hardware.h_vbit = SUBOFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 0);
872 }
873
874 #undef FLD
875     }
876     NEXT (vpc);
877
878 // ********** cmn $rd,$rs
879
880   CASE (INSN_ALU_CMN):
881     {
882       thumb_scache* abuf = vpc;
883 #define FLD(f) abuf->fields.sfmt_addi.f
884       PCADDR pc = abuf->addr;
885       vpc = vpc + 1;
886       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
887
888 {
889   SI tmp_result;
890   tmp_result = ADDCSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 0);
891 {
892 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
893 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
894 }
895 current_cpu->hardware.h_cbit = ADDCFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 0);
896 current_cpu->hardware.h_vbit = ADDOFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 0);
897 }
898
899 #undef FLD
900     }
901     NEXT (vpc);
902
903 // ********** orr $rd,$rs
904
905   CASE (INSN_ALU_ORR):
906     {
907       thumb_scache* abuf = vpc;
908 #define FLD(f) abuf->fields.sfmt_addi.f
909       PCADDR pc = abuf->addr;
910       vpc = vpc + 1;
911       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
912
913 {
914 current_cpu->thumb_h_gr_t_set (FLD (f_rd), ORSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs))));
915 {
916 current_cpu->hardware.h_zbit = EQSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
917 current_cpu->hardware.h_nbit = LTSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
918 }
919 }
920
921 #undef FLD
922     }
923     NEXT (vpc);
924
925 // ********** mul $rd,$rs
926
927   CASE (INSN_ALU_MUL):
928     {
929       thumb_scache* abuf = vpc;
930 #define FLD(f) abuf->fields.sfmt_addi.f
931       PCADDR pc = abuf->addr;
932       vpc = vpc + 1;
933       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
934
935 {
936 current_cpu->thumb_h_gr_t_set (FLD (f_rd), MULSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs))));
937 {
938 current_cpu->hardware.h_zbit = EQSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
939 current_cpu->hardware.h_nbit = LTSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
940 }
941 }
942
943 #undef FLD
944     }
945     NEXT (vpc);
946
947 // ********** bic $rd,$rs
948
949   CASE (INSN_ALU_BIC):
950     {
951       thumb_scache* abuf = vpc;
952 #define FLD(f) abuf->fields.sfmt_addi.f
953       PCADDR pc = abuf->addr;
954       vpc = vpc + 1;
955       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
956
957 {
958 current_cpu->thumb_h_gr_t_set (FLD (f_rd), ANDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), INVSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)))));
959 {
960 current_cpu->hardware.h_zbit = EQSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
961 current_cpu->hardware.h_nbit = LTSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
962 }
963 }
964
965 #undef FLD
966     }
967     NEXT (vpc);
968
969 // ********** mvn $rd,$rs
970
971   CASE (INSN_ALU_MVN):
972     {
973       thumb_scache* abuf = vpc;
974 #define FLD(f) abuf->fields.sfmt_addi.f
975       PCADDR pc = abuf->addr;
976       vpc = vpc + 1;
977       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
978
979 {
980 current_cpu->thumb_h_gr_t_set (FLD (f_rd), INVSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs))));
981 {
982 current_cpu->hardware.h_zbit = EQSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
983 current_cpu->hardware.h_nbit = LTSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), 0);
984 }
985 }
986
987 #undef FLD
988     }
989     NEXT (vpc);
990
991 // ********** add $rd,$hs
992
993   CASE (INSN_ADD_RD_HS):
994     {
995       thumb_scache* abuf = vpc;
996 #define FLD(f) abuf->fields.sfmt_addi.f
997       PCADDR pc = abuf->addr;
998       vpc = vpc + 1;
999       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1000
1001 current_cpu->thumb_h_gr_t_set (FLD (f_rd), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_hiregs_get (FLD (f_rs))));
1002
1003 #undef FLD
1004     }
1005     NEXT (vpc);
1006
1007 // ********** add $hd,$rs
1008
1009   CASE (INSN_ADD_HD_RS):
1010     {
1011       thumb_scache* abuf = vpc;
1012 #define FLD(f) abuf->fields.sfmt_addi.f
1013       PCADDR pc = abuf->addr;
1014       PCADDR npc;
1015       branch_status br_status = BRANCH_UNTAKEN;
1016       vpc = vpc + 1;
1017       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1018
1019 if (EQSI (FLD (f_rd), 7)) {
1020 npc = ADDSI (current_cpu->thumb_h_hiregs_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs))); br_status = BRANCH_UNCACHEABLE;
1021 } else {
1022 current_cpu->thumb_h_hiregs_set (FLD (f_rd), ADDSI (current_cpu->thumb_h_hiregs_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs))));
1023 }
1024
1025       pbb_br_npc = npc;
1026       pbb_br_status = br_status;
1027 #undef FLD
1028     }
1029     NEXT (vpc);
1030
1031 // ********** add $hd,$hs
1032
1033   CASE (INSN_ADD_HD_HS):
1034     {
1035       thumb_scache* abuf = vpc;
1036 #define FLD(f) abuf->fields.sfmt_addi.f
1037       PCADDR pc = abuf->addr;
1038       PCADDR npc;
1039       branch_status br_status = BRANCH_UNTAKEN;
1040       vpc = vpc + 1;
1041       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1042
1043 if (EQSI (FLD (f_rd), 7)) {
1044 npc = ADDSI (current_cpu->thumb_h_hiregs_get (FLD (f_rd)), current_cpu->thumb_h_hiregs_get (FLD (f_rs))); br_status = BRANCH_UNCACHEABLE;
1045 } else {
1046 current_cpu->thumb_h_hiregs_set (FLD (f_rd), ADDSI (current_cpu->thumb_h_hiregs_get (FLD (f_rd)), current_cpu->thumb_h_hiregs_get (FLD (f_rs))));
1047 }
1048
1049       pbb_br_npc = npc;
1050       pbb_br_status = br_status;
1051 #undef FLD
1052     }
1053     NEXT (vpc);
1054
1055 // ********** cmp $rd,$hs
1056
1057   CASE (INSN_CMP_RD_HS):
1058     {
1059       thumb_scache* abuf = vpc;
1060 #define FLD(f) abuf->fields.sfmt_addi.f
1061       PCADDR pc = abuf->addr;
1062       vpc = vpc + 1;
1063       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1064
1065 {
1066   SI tmp_result;
1067   tmp_result = SUBCSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_hiregs_get (FLD (f_rs)), 0);
1068 {
1069 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
1070 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
1071 }
1072 current_cpu->hardware.h_cbit = NOTBI (SUBCFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_hiregs_get (FLD (f_rs)), 0));
1073 current_cpu->hardware.h_vbit = SUBOFSI (current_cpu->thumb_h_gr_t_get (FLD (f_rd)), current_cpu->thumb_h_hiregs_get (FLD (f_rs)), 0);
1074 }
1075
1076 #undef FLD
1077     }
1078     NEXT (vpc);
1079
1080 // ********** cmp $hd,$rs
1081
1082   CASE (INSN_CMP_HD_RS):
1083     {
1084       thumb_scache* abuf = vpc;
1085 #define FLD(f) abuf->fields.sfmt_addi.f
1086       PCADDR pc = abuf->addr;
1087       vpc = vpc + 1;
1088       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1089
1090 {
1091   SI tmp_result;
1092   tmp_result = SUBCSI (current_cpu->thumb_h_hiregs_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 0);
1093 {
1094 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
1095 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
1096 }
1097 current_cpu->hardware.h_cbit = NOTBI (SUBCFSI (current_cpu->thumb_h_hiregs_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 0));
1098 current_cpu->hardware.h_vbit = SUBOFSI (current_cpu->thumb_h_hiregs_get (FLD (f_rd)), current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 0);
1099 }
1100
1101 #undef FLD
1102     }
1103     NEXT (vpc);
1104
1105 // ********** cmp $hd,$hs
1106
1107   CASE (INSN_CMP_HD_HS):
1108     {
1109       thumb_scache* abuf = vpc;
1110 #define FLD(f) abuf->fields.sfmt_addi.f
1111       PCADDR pc = abuf->addr;
1112       vpc = vpc + 1;
1113       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1114
1115 {
1116   SI tmp_result;
1117   tmp_result = SUBCSI (current_cpu->thumb_h_hiregs_get (FLD (f_rd)), current_cpu->thumb_h_hiregs_get (FLD (f_rs)), 0);
1118 {
1119 current_cpu->hardware.h_zbit = EQSI (tmp_result, 0);
1120 current_cpu->hardware.h_nbit = LTSI (tmp_result, 0);
1121 }
1122 current_cpu->hardware.h_cbit = NOTBI (SUBCFSI (current_cpu->thumb_h_hiregs_get (FLD (f_rd)), current_cpu->thumb_h_hiregs_get (FLD (f_rs)), 0));
1123 current_cpu->hardware.h_vbit = SUBOFSI (current_cpu->thumb_h_hiregs_get (FLD (f_rd)), current_cpu->thumb_h_hiregs_get (FLD (f_rs)), 0);
1124 }
1125
1126 #undef FLD
1127     }
1128     NEXT (vpc);
1129
1130 // ********** mov $rd,$hs
1131
1132   CASE (INSN_MOV_RD_HS):
1133     {
1134       thumb_scache* abuf = vpc;
1135 #define FLD(f) abuf->fields.sfmt_addi.f
1136       PCADDR pc = abuf->addr;
1137       vpc = vpc + 1;
1138       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1139
1140 current_cpu->thumb_h_gr_t_set (FLD (f_rd), current_cpu->thumb_h_hiregs_get (FLD (f_rs)));
1141
1142 #undef FLD
1143     }
1144     NEXT (vpc);
1145
1146 // ********** mov $hd,$rs
1147
1148   CASE (INSN_MOV_HD_RS):
1149     {
1150       thumb_scache* abuf = vpc;
1151 #define FLD(f) abuf->fields.sfmt_addi.f
1152       PCADDR pc = abuf->addr;
1153       PCADDR npc;
1154       branch_status br_status = BRANCH_UNTAKEN;
1155       vpc = vpc + 1;
1156       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1157
1158 if (EQSI (FLD (f_rd), 7)) {
1159 npc = current_cpu->thumb_h_gr_t_get (FLD (f_rs)); br_status = BRANCH_UNCACHEABLE;
1160 } else {
1161 current_cpu->thumb_h_hiregs_set (FLD (f_rd), current_cpu->thumb_h_gr_t_get (FLD (f_rs)));
1162 }
1163
1164       pbb_br_npc = npc;
1165       pbb_br_status = br_status;
1166 #undef FLD
1167     }
1168     NEXT (vpc);
1169
1170 // ********** mov $hd,$hs
1171
1172   CASE (INSN_MOV_HD_HS):
1173     {
1174       thumb_scache* abuf = vpc;
1175 #define FLD(f) abuf->fields.sfmt_addi.f
1176       PCADDR pc = abuf->addr;
1177       PCADDR npc;
1178       branch_status br_status = BRANCH_UNTAKEN;
1179       vpc = vpc + 1;
1180       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1181
1182 if (EQSI (FLD (f_rd), 7)) {
1183 npc = current_cpu->thumb_h_hiregs_get (FLD (f_rs)); br_status = BRANCH_UNCACHEABLE;
1184 } else {
1185 current_cpu->thumb_h_hiregs_set (FLD (f_rd), current_cpu->thumb_h_hiregs_get (FLD (f_rs)));
1186 }
1187
1188       pbb_br_npc = npc;
1189       pbb_br_status = br_status;
1190 #undef FLD
1191     }
1192     NEXT (vpc);
1193
1194 // ********** bx $rs
1195
1196   CASE (INSN_BX_RS):
1197     {
1198       thumb_scache* abuf = vpc;
1199 #define FLD(f) abuf->fields.sfmt_addi.f
1200       PCADDR pc = abuf->addr;
1201       PCADDR npc;
1202       branch_status br_status = BRANCH_UNTAKEN;
1203       vpc = vpc + 1;
1204       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1205
1206 {
1207 npc = current_cpu->thumb_h_gr_t_get (FLD (f_rs)); br_status = BRANCH_UNCACHEABLE;
1208 if (NOTSI (ANDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rs)), 1))) {
1209 current_cpu->h_tbit_set (0);
1210 }
1211 }
1212
1213       pbb_br_npc = npc;
1214       pbb_br_status = br_status;
1215 #undef FLD
1216     }
1217     NEXT (vpc);
1218
1219 // ********** bx $hs
1220
1221   CASE (INSN_BX_HS):
1222     {
1223       thumb_scache* abuf = vpc;
1224 #define FLD(f) abuf->fields.sfmt_addi.f
1225       PCADDR pc = abuf->addr;
1226       PCADDR npc;
1227       branch_status br_status = BRANCH_UNTAKEN;
1228       vpc = vpc + 1;
1229       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1230
1231 {
1232 npc = current_cpu->thumb_h_hiregs_get (FLD (f_rs)); br_status = BRANCH_UNCACHEABLE;
1233 if (NOTSI (ANDSI (current_cpu->thumb_h_hiregs_get (FLD (f_rs)), 1))) {
1234 current_cpu->h_tbit_set (0);
1235 }
1236 }
1237
1238       pbb_br_npc = npc;
1239       pbb_br_status = br_status;
1240 #undef FLD
1241     }
1242     NEXT (vpc);
1243
1244 // ********** ldr ${bit10-rd},[pc,#$word8]
1245
1246   CASE (INSN_LDR_PC):
1247     {
1248       thumb_scache* abuf = vpc;
1249 #define FLD(f) abuf->fields.sfmt_ldr_pc.f
1250       PCADDR pc = abuf->addr;
1251       vpc = vpc + 1;
1252       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1253
1254 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rd), current_cpu->GETMEMSI (pc, ADDSI (ANDSI (ADDSI (pc, 4), -4), FLD (f_word8))));
1255
1256 #undef FLD
1257     }
1258     NEXT (vpc);
1259
1260 // ********** str $rd,[$rb,$ro]
1261
1262   CASE (INSN_STR):
1263     {
1264       thumb_scache* abuf = vpc;
1265 #define FLD(f) abuf->fields.sfmt_str.f
1266       PCADDR pc = abuf->addr;
1267       vpc = vpc + 1;
1268       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1269
1270 current_cpu->SETMEMSI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), current_cpu->thumb_h_gr_t_get (FLD (f_ro))), current_cpu->thumb_h_gr_t_get (FLD (f_rd)));
1271
1272 #undef FLD
1273     }
1274     NEXT (vpc);
1275
1276 // ********** strb $rd,[$rb,$ro]
1277
1278   CASE (INSN_STRB):
1279     {
1280       thumb_scache* abuf = vpc;
1281 #define FLD(f) abuf->fields.sfmt_str.f
1282       PCADDR pc = abuf->addr;
1283       vpc = vpc + 1;
1284       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1285
1286 current_cpu->SETMEMQI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), current_cpu->thumb_h_gr_t_get (FLD (f_ro))), current_cpu->thumb_h_gr_t_get (FLD (f_rd)));
1287
1288 #undef FLD
1289     }
1290     NEXT (vpc);
1291
1292 // ********** ldr $rd,[$rb,$ro]
1293
1294   CASE (INSN_LDR):
1295     {
1296       thumb_scache* abuf = vpc;
1297 #define FLD(f) abuf->fields.sfmt_str.f
1298       PCADDR pc = abuf->addr;
1299       vpc = vpc + 1;
1300       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1301
1302 current_cpu->thumb_h_gr_t_set (FLD (f_rd), current_cpu->GETMEMSI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), current_cpu->thumb_h_gr_t_get (FLD (f_ro)))));
1303
1304 #undef FLD
1305     }
1306     NEXT (vpc);
1307
1308 // ********** ldrb $rd,[$rb,$ro]
1309
1310   CASE (INSN_LDRB):
1311     {
1312       thumb_scache* abuf = vpc;
1313 #define FLD(f) abuf->fields.sfmt_str.f
1314       PCADDR pc = abuf->addr;
1315       vpc = vpc + 1;
1316       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1317
1318 current_cpu->thumb_h_gr_t_set (FLD (f_rd), ZEXTQISI (current_cpu->GETMEMQI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), current_cpu->thumb_h_gr_t_get (FLD (f_ro))))));
1319
1320 #undef FLD
1321     }
1322     NEXT (vpc);
1323
1324 // ********** strh $rd,[$rb,$ro]
1325
1326   CASE (INSN_STRH):
1327     {
1328       thumb_scache* abuf = vpc;
1329 #define FLD(f) abuf->fields.sfmt_str.f
1330       PCADDR pc = abuf->addr;
1331       vpc = vpc + 1;
1332       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1333
1334 current_cpu->SETMEMHI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), current_cpu->thumb_h_gr_t_get (FLD (f_ro))), current_cpu->thumb_h_gr_t_get (FLD (f_rd)));
1335
1336 #undef FLD
1337     }
1338     NEXT (vpc);
1339
1340 // ********** ldrh $rd,[$rb,$ro]
1341
1342   CASE (INSN_LDRH):
1343     {
1344       thumb_scache* abuf = vpc;
1345 #define FLD(f) abuf->fields.sfmt_str.f
1346       PCADDR pc = abuf->addr;
1347       vpc = vpc + 1;
1348       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1349
1350 current_cpu->thumb_h_gr_t_set (FLD (f_rd), ZEXTHISI (current_cpu->GETMEMHI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), current_cpu->thumb_h_gr_t_get (FLD (f_ro))))));
1351
1352 #undef FLD
1353     }
1354     NEXT (vpc);
1355
1356 // ********** ldsb $rd,[$rb,$ro]
1357
1358   CASE (INSN_LDSB):
1359     {
1360       thumb_scache* abuf = vpc;
1361 #define FLD(f) abuf->fields.sfmt_str.f
1362       PCADDR pc = abuf->addr;
1363       vpc = vpc + 1;
1364       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1365
1366 current_cpu->thumb_h_gr_t_set (FLD (f_rd), EXTQISI (current_cpu->GETMEMQI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), current_cpu->thumb_h_gr_t_get (FLD (f_ro))))));
1367
1368 #undef FLD
1369     }
1370     NEXT (vpc);
1371
1372 // ********** ldsh $rd,[$rb,$ro]
1373
1374   CASE (INSN_LDSH):
1375     {
1376       thumb_scache* abuf = vpc;
1377 #define FLD(f) abuf->fields.sfmt_str.f
1378       PCADDR pc = abuf->addr;
1379       vpc = vpc + 1;
1380       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1381
1382 current_cpu->thumb_h_gr_t_set (FLD (f_rd), EXTHISI (current_cpu->GETMEMHI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), current_cpu->thumb_h_gr_t_get (FLD (f_ro))))));
1383
1384 #undef FLD
1385     }
1386     NEXT (vpc);
1387
1388 // ********** str $rd,[$rb,#${offset5-7}]
1389
1390   CASE (INSN_STR_IMM):
1391     {
1392       thumb_scache* abuf = vpc;
1393 #define FLD(f) abuf->fields.sfmt_str_imm.f
1394       PCADDR pc = abuf->addr;
1395       vpc = vpc + 1;
1396       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1397
1398 current_cpu->SETMEMSI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), FLD (f_offset5_7)), current_cpu->thumb_h_gr_t_get (FLD (f_rd)));
1399
1400 #undef FLD
1401     }
1402     NEXT (vpc);
1403
1404 // ********** ldr $rd,[$rb,#${offset5-7}]
1405
1406   CASE (INSN_LDR_IMM):
1407     {
1408       thumb_scache* abuf = vpc;
1409 #define FLD(f) abuf->fields.sfmt_str_imm.f
1410       PCADDR pc = abuf->addr;
1411       vpc = vpc + 1;
1412       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1413
1414 current_cpu->thumb_h_gr_t_set (FLD (f_rd), current_cpu->GETMEMSI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), FLD (f_offset5_7))));
1415
1416 #undef FLD
1417     }
1418     NEXT (vpc);
1419
1420 // ********** strb $rd,[$rb,#$offset5]
1421
1422   CASE (INSN_STRB_IMM):
1423     {
1424       thumb_scache* abuf = vpc;
1425 #define FLD(f) abuf->fields.sfmt_strb_imm.f
1426       PCADDR pc = abuf->addr;
1427       vpc = vpc + 1;
1428       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1429
1430 current_cpu->SETMEMQI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), FLD (f_offset5)), current_cpu->thumb_h_gr_t_get (FLD (f_rd)));
1431
1432 #undef FLD
1433     }
1434     NEXT (vpc);
1435
1436 // ********** ldrb $rd,[$rb,#$offset5]
1437
1438   CASE (INSN_LDRB_IMM):
1439     {
1440       thumb_scache* abuf = vpc;
1441 #define FLD(f) abuf->fields.sfmt_strb_imm.f
1442       PCADDR pc = abuf->addr;
1443       vpc = vpc + 1;
1444       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1445
1446 current_cpu->thumb_h_gr_t_set (FLD (f_rd), ZEXTQISI (current_cpu->GETMEMQI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), FLD (f_offset5)))));
1447
1448 #undef FLD
1449     }
1450     NEXT (vpc);
1451
1452 // ********** strh $rd,[$rb,#${offset5-6}]
1453
1454   CASE (INSN_STRH_IMM):
1455     {
1456       thumb_scache* abuf = vpc;
1457 #define FLD(f) abuf->fields.sfmt_strh_imm.f
1458       PCADDR pc = abuf->addr;
1459       vpc = vpc + 1;
1460       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1461
1462 current_cpu->SETMEMHI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), FLD (f_offset5_6)), current_cpu->thumb_h_gr_t_get (FLD (f_rd)));
1463
1464 #undef FLD
1465     }
1466     NEXT (vpc);
1467
1468 // ********** ldrh $rd,[$rb,#${offset5-6}]
1469
1470   CASE (INSN_LDRH_IMM):
1471     {
1472       thumb_scache* abuf = vpc;
1473 #define FLD(f) abuf->fields.sfmt_strh_imm.f
1474       PCADDR pc = abuf->addr;
1475       vpc = vpc + 1;
1476       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1477
1478 current_cpu->thumb_h_gr_t_set (FLD (f_rd), ZEXTHISI (current_cpu->GETMEMHI (pc, ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_rb)), FLD (f_offset5_6)))));
1479
1480 #undef FLD
1481     }
1482     NEXT (vpc);
1483
1484 // ********** str ${bit10-rd},[sp,#$word8]
1485
1486   CASE (INSN_STR_SPREL):
1487     {
1488       thumb_scache* abuf = vpc;
1489 #define FLD(f) abuf->fields.sfmt_ldr_pc.f
1490       PCADDR pc = abuf->addr;
1491       vpc = vpc + 1;
1492       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1493
1494 current_cpu->SETMEMSI (pc, ADDSI (current_cpu->thumb_h_sp_t_get (), FLD (f_word8)), current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rd)));
1495
1496 #undef FLD
1497     }
1498     NEXT (vpc);
1499
1500 // ********** ldr ${bit10-rd},[sp,#$word8]
1501
1502   CASE (INSN_LDR_SPREL):
1503     {
1504       thumb_scache* abuf = vpc;
1505 #define FLD(f) abuf->fields.sfmt_ldr_pc.f
1506       PCADDR pc = abuf->addr;
1507       vpc = vpc + 1;
1508       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1509
1510 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rd), current_cpu->GETMEMSI (pc, ADDSI (current_cpu->thumb_h_sp_t_get (), FLD (f_word8))));
1511
1512 #undef FLD
1513     }
1514     NEXT (vpc);
1515
1516 // ********** add ${bit10-rd},pc,$word8
1517
1518   CASE (INSN_LDA_PC):
1519     {
1520       thumb_scache* abuf = vpc;
1521 #define FLD(f) abuf->fields.sfmt_ldr_pc.f
1522       PCADDR pc = abuf->addr;
1523       vpc = vpc + 1;
1524       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1525
1526 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rd), ADDSI (ANDSI (ADDSI (pc, 4), -4), FLD (f_word8)));
1527
1528 #undef FLD
1529     }
1530     NEXT (vpc);
1531
1532 // ********** add ${bit10-rd},sp,$word8
1533
1534   CASE (INSN_LDA_SP):
1535     {
1536       thumb_scache* abuf = vpc;
1537 #define FLD(f) abuf->fields.sfmt_ldr_pc.f
1538       PCADDR pc = abuf->addr;
1539       vpc = vpc + 1;
1540       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1541
1542 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rd), ADDSI (current_cpu->thumb_h_sp_t_get (), FLD (f_word8)));
1543
1544 #undef FLD
1545     }
1546     NEXT (vpc);
1547
1548 // ********** add sp,#$sword7
1549
1550   CASE (INSN_ADD_SP):
1551     {
1552       thumb_scache* abuf = vpc;
1553 #define FLD(f) abuf->fields.sfmt_add_sp.f
1554       PCADDR pc = abuf->addr;
1555       vpc = vpc + 1;
1556       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1557
1558 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), FLD (f_sword7)));
1559
1560 #undef FLD
1561     }
1562     NEXT (vpc);
1563
1564 // ********** add sp,#-$sword7
1565
1566   CASE (INSN_SUB_SP):
1567     {
1568       thumb_scache* abuf = vpc;
1569 #define FLD(f) abuf->fields.sfmt_add_sp.f
1570       PCADDR pc = abuf->addr;
1571       vpc = vpc + 1;
1572       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1573
1574 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), FLD (f_sword7)));
1575
1576 #undef FLD
1577     }
1578     NEXT (vpc);
1579
1580 // ********** push {$rlist}
1581
1582   CASE (INSN_PUSH):
1583     {
1584       thumb_scache* abuf = vpc;
1585 #define FLD(f) abuf->fields.sfmt_stmia.f
1586       PCADDR pc = abuf->addr;
1587       vpc = vpc + 1;
1588       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1589
1590 {
1591 if (ANDSI (FLD (f_rlist), SLLSI (1, 7))) {
1592 {
1593 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1594 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 7)));
1595 }
1596 }
1597 if (ANDSI (FLD (f_rlist), SLLSI (1, 6))) {
1598 {
1599 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1600 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 6)));
1601 }
1602 }
1603 if (ANDSI (FLD (f_rlist), SLLSI (1, 5))) {
1604 {
1605 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1606 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 5)));
1607 }
1608 }
1609 if (ANDSI (FLD (f_rlist), SLLSI (1, 4))) {
1610 {
1611 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1612 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 4)));
1613 }
1614 }
1615 if (ANDSI (FLD (f_rlist), SLLSI (1, 3))) {
1616 {
1617 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1618 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 3)));
1619 }
1620 }
1621 if (ANDSI (FLD (f_rlist), SLLSI (1, 2))) {
1622 {
1623 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1624 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 2)));
1625 }
1626 }
1627 if (ANDSI (FLD (f_rlist), SLLSI (1, 1))) {
1628 {
1629 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1630 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 1)));
1631 }
1632 }
1633 if (ANDSI (FLD (f_rlist), SLLSI (1, 0))) {
1634 {
1635 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1636 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 0)));
1637 }
1638 }
1639 }
1640
1641 #undef FLD
1642     }
1643     NEXT (vpc);
1644
1645 // ********** push {${rlist-lr}}
1646
1647   CASE (INSN_PUSH_LR):
1648     {
1649       thumb_scache* abuf = vpc;
1650 #define FLD(f) abuf->fields.sfmt_stmia.f
1651       PCADDR pc = abuf->addr;
1652       vpc = vpc + 1;
1653       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1654
1655 {
1656 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1657 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_lr_t_get ());
1658 if (ANDSI (FLD (f_rlist), SLLSI (1, 7))) {
1659 {
1660 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1661 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 7)));
1662 }
1663 }
1664 if (ANDSI (FLD (f_rlist), SLLSI (1, 6))) {
1665 {
1666 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1667 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 6)));
1668 }
1669 }
1670 if (ANDSI (FLD (f_rlist), SLLSI (1, 5))) {
1671 {
1672 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1673 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 5)));
1674 }
1675 }
1676 if (ANDSI (FLD (f_rlist), SLLSI (1, 4))) {
1677 {
1678 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1679 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 4)));
1680 }
1681 }
1682 if (ANDSI (FLD (f_rlist), SLLSI (1, 3))) {
1683 {
1684 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1685 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 3)));
1686 }
1687 }
1688 if (ANDSI (FLD (f_rlist), SLLSI (1, 2))) {
1689 {
1690 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1691 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 2)));
1692 }
1693 }
1694 if (ANDSI (FLD (f_rlist), SLLSI (1, 1))) {
1695 {
1696 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1697 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 1)));
1698 }
1699 }
1700 if (ANDSI (FLD (f_rlist), SLLSI (1, 0))) {
1701 {
1702 current_cpu->thumb_h_sp_t_set (SUBSI (current_cpu->thumb_h_sp_t_get (), 4));
1703 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_sp_t_get (), current_cpu->thumb_h_gr_t_get (((UINT) 0)));
1704 }
1705 }
1706 }
1707
1708 #undef FLD
1709     }
1710     NEXT (vpc);
1711
1712 // ********** pop {$rlist}
1713
1714   CASE (INSN_POP):
1715     {
1716       thumb_scache* abuf = vpc;
1717 #define FLD(f) abuf->fields.sfmt_stmia.f
1718       PCADDR pc = abuf->addr;
1719       vpc = vpc + 1;
1720       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1721
1722 {
1723 if (ANDSI (FLD (f_rlist), SLLSI (1, 0))) {
1724 {
1725 current_cpu->thumb_h_gr_t_set (((UINT) 0), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1726 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1727 }
1728 }
1729 if (ANDSI (FLD (f_rlist), SLLSI (1, 1))) {
1730 {
1731 current_cpu->thumb_h_gr_t_set (((UINT) 1), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1732 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1733 }
1734 }
1735 if (ANDSI (FLD (f_rlist), SLLSI (1, 2))) {
1736 {
1737 current_cpu->thumb_h_gr_t_set (((UINT) 2), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1738 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1739 }
1740 }
1741 if (ANDSI (FLD (f_rlist), SLLSI (1, 3))) {
1742 {
1743 current_cpu->thumb_h_gr_t_set (((UINT) 3), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1744 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1745 }
1746 }
1747 if (ANDSI (FLD (f_rlist), SLLSI (1, 4))) {
1748 {
1749 current_cpu->thumb_h_gr_t_set (((UINT) 4), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1750 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1751 }
1752 }
1753 if (ANDSI (FLD (f_rlist), SLLSI (1, 5))) {
1754 {
1755 current_cpu->thumb_h_gr_t_set (((UINT) 5), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1756 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1757 }
1758 }
1759 if (ANDSI (FLD (f_rlist), SLLSI (1, 6))) {
1760 {
1761 current_cpu->thumb_h_gr_t_set (((UINT) 6), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1762 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1763 }
1764 }
1765 if (ANDSI (FLD (f_rlist), SLLSI (1, 7))) {
1766 {
1767 current_cpu->thumb_h_gr_t_set (((UINT) 7), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1768 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1769 }
1770 }
1771 }
1772
1773 #undef FLD
1774     }
1775     NEXT (vpc);
1776
1777 // ********** pop {${rlist-pc}}
1778
1779   CASE (INSN_POP_PC):
1780     {
1781       thumb_scache* abuf = vpc;
1782 #define FLD(f) abuf->fields.sfmt_stmia.f
1783       PCADDR pc = abuf->addr;
1784       PCADDR npc;
1785       branch_status br_status = BRANCH_UNTAKEN;
1786       vpc = vpc + 1;
1787       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1788
1789 {
1790 if (ANDSI (FLD (f_rlist), SLLSI (1, 0))) {
1791 {
1792 current_cpu->thumb_h_gr_t_set (((UINT) 0), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1793 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1794 }
1795 }
1796 if (ANDSI (FLD (f_rlist), SLLSI (1, 1))) {
1797 {
1798 current_cpu->thumb_h_gr_t_set (((UINT) 1), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1799 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1800 }
1801 }
1802 if (ANDSI (FLD (f_rlist), SLLSI (1, 2))) {
1803 {
1804 current_cpu->thumb_h_gr_t_set (((UINT) 2), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1805 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1806 }
1807 }
1808 if (ANDSI (FLD (f_rlist), SLLSI (1, 3))) {
1809 {
1810 current_cpu->thumb_h_gr_t_set (((UINT) 3), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1811 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1812 }
1813 }
1814 if (ANDSI (FLD (f_rlist), SLLSI (1, 4))) {
1815 {
1816 current_cpu->thumb_h_gr_t_set (((UINT) 4), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1817 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1818 }
1819 }
1820 if (ANDSI (FLD (f_rlist), SLLSI (1, 5))) {
1821 {
1822 current_cpu->thumb_h_gr_t_set (((UINT) 5), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1823 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1824 }
1825 }
1826 if (ANDSI (FLD (f_rlist), SLLSI (1, 6))) {
1827 {
1828 current_cpu->thumb_h_gr_t_set (((UINT) 6), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1829 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1830 }
1831 }
1832 if (ANDSI (FLD (f_rlist), SLLSI (1, 7))) {
1833 {
1834 current_cpu->thumb_h_gr_t_set (((UINT) 7), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()));
1835 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1836 }
1837 }
1838 npc = current_cpu->GETMEMSI (pc, current_cpu->thumb_h_sp_t_get ()); br_status = BRANCH_UNCACHEABLE;
1839 current_cpu->thumb_h_sp_t_set (ADDSI (current_cpu->thumb_h_sp_t_get (), 4));
1840 }
1841
1842       pbb_br_npc = npc;
1843       pbb_br_status = br_status;
1844 #undef FLD
1845     }
1846     NEXT (vpc);
1847
1848 // ********** stmia $rb!,{$rlist}
1849
1850   CASE (INSN_STMIA):
1851     {
1852       thumb_scache* abuf = vpc;
1853 #define FLD(f) abuf->fields.sfmt_stmia.f
1854       PCADDR pc = abuf->addr;
1855       vpc = vpc + 1;
1856       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1857
1858 {
1859 if (ANDSI (FLD (f_rlist), SLLSI (1, 0))) {
1860 {
1861 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), current_cpu->thumb_h_gr_t_get (((UINT) 0)));
1862 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1863 }
1864 }
1865 if (ANDSI (FLD (f_rlist), SLLSI (1, 1))) {
1866 {
1867 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), current_cpu->thumb_h_gr_t_get (((UINT) 1)));
1868 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1869 }
1870 }
1871 if (ANDSI (FLD (f_rlist), SLLSI (1, 2))) {
1872 {
1873 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), current_cpu->thumb_h_gr_t_get (((UINT) 2)));
1874 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1875 }
1876 }
1877 if (ANDSI (FLD (f_rlist), SLLSI (1, 3))) {
1878 {
1879 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), current_cpu->thumb_h_gr_t_get (((UINT) 3)));
1880 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1881 }
1882 }
1883 if (ANDSI (FLD (f_rlist), SLLSI (1, 4))) {
1884 {
1885 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), current_cpu->thumb_h_gr_t_get (((UINT) 4)));
1886 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1887 }
1888 }
1889 if (ANDSI (FLD (f_rlist), SLLSI (1, 5))) {
1890 {
1891 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), current_cpu->thumb_h_gr_t_get (((UINT) 5)));
1892 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1893 }
1894 }
1895 if (ANDSI (FLD (f_rlist), SLLSI (1, 6))) {
1896 {
1897 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), current_cpu->thumb_h_gr_t_get (((UINT) 6)));
1898 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1899 }
1900 }
1901 if (ANDSI (FLD (f_rlist), SLLSI (1, 7))) {
1902 {
1903 current_cpu->SETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), current_cpu->thumb_h_gr_t_get (((UINT) 7)));
1904 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1905 }
1906 }
1907 }
1908
1909 #undef FLD
1910     }
1911     NEXT (vpc);
1912
1913 // ********** ldmia $rb!,{$rlist}
1914
1915   CASE (INSN_LDMIA):
1916     {
1917       thumb_scache* abuf = vpc;
1918 #define FLD(f) abuf->fields.sfmt_stmia.f
1919       PCADDR pc = abuf->addr;
1920       vpc = vpc + 1;
1921       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1922
1923 {
1924 if (ANDSI (FLD (f_rlist), SLLSI (1, 0))) {
1925 {
1926 current_cpu->thumb_h_gr_t_set (((UINT) 0), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb))));
1927 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1928 }
1929 }
1930 if (ANDSI (FLD (f_rlist), SLLSI (1, 1))) {
1931 {
1932 current_cpu->thumb_h_gr_t_set (((UINT) 1), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb))));
1933 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1934 }
1935 }
1936 if (ANDSI (FLD (f_rlist), SLLSI (1, 2))) {
1937 {
1938 current_cpu->thumb_h_gr_t_set (((UINT) 2), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb))));
1939 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1940 }
1941 }
1942 if (ANDSI (FLD (f_rlist), SLLSI (1, 3))) {
1943 {
1944 current_cpu->thumb_h_gr_t_set (((UINT) 3), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb))));
1945 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1946 }
1947 }
1948 if (ANDSI (FLD (f_rlist), SLLSI (1, 4))) {
1949 {
1950 current_cpu->thumb_h_gr_t_set (((UINT) 4), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb))));
1951 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1952 }
1953 }
1954 if (ANDSI (FLD (f_rlist), SLLSI (1, 5))) {
1955 {
1956 current_cpu->thumb_h_gr_t_set (((UINT) 5), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb))));
1957 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1958 }
1959 }
1960 if (ANDSI (FLD (f_rlist), SLLSI (1, 6))) {
1961 {
1962 current_cpu->thumb_h_gr_t_set (((UINT) 6), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb))));
1963 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1964 }
1965 }
1966 if (ANDSI (FLD (f_rlist), SLLSI (1, 7))) {
1967 {
1968 current_cpu->thumb_h_gr_t_set (((UINT) 7), current_cpu->GETMEMSI (pc, current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb))));
1969 current_cpu->thumb_h_gr_t_set (FLD (f_bit10_rb), ADDSI (current_cpu->thumb_h_gr_t_get (FLD (f_bit10_rb)), 4));
1970 }
1971 }
1972 }
1973
1974 #undef FLD
1975     }
1976     NEXT (vpc);
1977
1978 // ********** beq $soffset8
1979
1980   CASE (INSN_BEQ):
1981     {
1982       thumb_scache* abuf = vpc;
1983 #define FLD(f) abuf->fields.sfmt_beq.f
1984       PCADDR pc = abuf->addr;
1985       PCADDR npc;
1986       branch_status br_status = BRANCH_UNTAKEN;
1987       vpc = vpc + 1;
1988       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
1989
1990 if (current_cpu->hardware.h_zbit) {
1991 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
1992 }
1993
1994       pbb_br_npc = npc;
1995       pbb_br_status = br_status;
1996 #undef FLD
1997     }
1998     NEXT (vpc);
1999
2000 // ********** bne $soffset8
2001
2002   CASE (INSN_BNE):
2003     {
2004       thumb_scache* abuf = vpc;
2005 #define FLD(f) abuf->fields.sfmt_beq.f
2006       PCADDR pc = abuf->addr;
2007       PCADDR npc;
2008       branch_status br_status = BRANCH_UNTAKEN;
2009       vpc = vpc + 1;
2010       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2011
2012 if (NOTBI (current_cpu->hardware.h_zbit)) {
2013 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2014 }
2015
2016       pbb_br_npc = npc;
2017       pbb_br_status = br_status;
2018 #undef FLD
2019     }
2020     NEXT (vpc);
2021
2022 // ********** bcs $soffset8
2023
2024   CASE (INSN_BCS):
2025     {
2026       thumb_scache* abuf = vpc;
2027 #define FLD(f) abuf->fields.sfmt_beq.f
2028       PCADDR pc = abuf->addr;
2029       PCADDR npc;
2030       branch_status br_status = BRANCH_UNTAKEN;
2031       vpc = vpc + 1;
2032       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2033
2034 if (current_cpu->hardware.h_cbit) {
2035 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2036 }
2037
2038       pbb_br_npc = npc;
2039       pbb_br_status = br_status;
2040 #undef FLD
2041     }
2042     NEXT (vpc);
2043
2044 // ********** bcc $soffset8
2045
2046   CASE (INSN_BCC):
2047     {
2048       thumb_scache* abuf = vpc;
2049 #define FLD(f) abuf->fields.sfmt_beq.f
2050       PCADDR pc = abuf->addr;
2051       PCADDR npc;
2052       branch_status br_status = BRANCH_UNTAKEN;
2053       vpc = vpc + 1;
2054       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2055
2056 if (NOTBI (current_cpu->hardware.h_cbit)) {
2057 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2058 }
2059
2060       pbb_br_npc = npc;
2061       pbb_br_status = br_status;
2062 #undef FLD
2063     }
2064     NEXT (vpc);
2065
2066 // ********** bmi $soffset8
2067
2068   CASE (INSN_BMI):
2069     {
2070       thumb_scache* abuf = vpc;
2071 #define FLD(f) abuf->fields.sfmt_beq.f
2072       PCADDR pc = abuf->addr;
2073       PCADDR npc;
2074       branch_status br_status = BRANCH_UNTAKEN;
2075       vpc = vpc + 1;
2076       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2077
2078 if (current_cpu->hardware.h_nbit) {
2079 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2080 }
2081
2082       pbb_br_npc = npc;
2083       pbb_br_status = br_status;
2084 #undef FLD
2085     }
2086     NEXT (vpc);
2087
2088 // ********** bpl $soffset8
2089
2090   CASE (INSN_BPL):
2091     {
2092       thumb_scache* abuf = vpc;
2093 #define FLD(f) abuf->fields.sfmt_beq.f
2094       PCADDR pc = abuf->addr;
2095       PCADDR npc;
2096       branch_status br_status = BRANCH_UNTAKEN;
2097       vpc = vpc + 1;
2098       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2099
2100 if (NOTBI (current_cpu->hardware.h_nbit)) {
2101 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2102 }
2103
2104       pbb_br_npc = npc;
2105       pbb_br_status = br_status;
2106 #undef FLD
2107     }
2108     NEXT (vpc);
2109
2110 // ********** bvs $soffset8
2111
2112   CASE (INSN_BVS):
2113     {
2114       thumb_scache* abuf = vpc;
2115 #define FLD(f) abuf->fields.sfmt_beq.f
2116       PCADDR pc = abuf->addr;
2117       PCADDR npc;
2118       branch_status br_status = BRANCH_UNTAKEN;
2119       vpc = vpc + 1;
2120       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2121
2122 if (current_cpu->hardware.h_vbit) {
2123 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2124 }
2125
2126       pbb_br_npc = npc;
2127       pbb_br_status = br_status;
2128 #undef FLD
2129     }
2130     NEXT (vpc);
2131
2132 // ********** bvc $soffset8
2133
2134   CASE (INSN_BVC):
2135     {
2136       thumb_scache* abuf = vpc;
2137 #define FLD(f) abuf->fields.sfmt_beq.f
2138       PCADDR pc = abuf->addr;
2139       PCADDR npc;
2140       branch_status br_status = BRANCH_UNTAKEN;
2141       vpc = vpc + 1;
2142       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2143
2144 if (NOTBI (current_cpu->hardware.h_vbit)) {
2145 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2146 }
2147
2148       pbb_br_npc = npc;
2149       pbb_br_status = br_status;
2150 #undef FLD
2151     }
2152     NEXT (vpc);
2153
2154 // ********** bhi $soffset8
2155
2156   CASE (INSN_BHI):
2157     {
2158       thumb_scache* abuf = vpc;
2159 #define FLD(f) abuf->fields.sfmt_beq.f
2160       PCADDR pc = abuf->addr;
2161       PCADDR npc;
2162       branch_status br_status = BRANCH_UNTAKEN;
2163       vpc = vpc + 1;
2164       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2165
2166 if (ANDBI (current_cpu->hardware.h_cbit, NOTBI (current_cpu->hardware.h_zbit))) {
2167 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2168 }
2169
2170       pbb_br_npc = npc;
2171       pbb_br_status = br_status;
2172 #undef FLD
2173     }
2174     NEXT (vpc);
2175
2176 // ********** bls $soffset8
2177
2178   CASE (INSN_BLS):
2179     {
2180       thumb_scache* abuf = vpc;
2181 #define FLD(f) abuf->fields.sfmt_beq.f
2182       PCADDR pc = abuf->addr;
2183       PCADDR npc;
2184       branch_status br_status = BRANCH_UNTAKEN;
2185       vpc = vpc + 1;
2186       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2187
2188 if (ORBI (NOTBI (current_cpu->hardware.h_cbit), current_cpu->hardware.h_zbit)) {
2189 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2190 }
2191
2192       pbb_br_npc = npc;
2193       pbb_br_status = br_status;
2194 #undef FLD
2195     }
2196     NEXT (vpc);
2197
2198 // ********** bge $soffset8
2199
2200   CASE (INSN_BGE):
2201     {
2202       thumb_scache* abuf = vpc;
2203 #define FLD(f) abuf->fields.sfmt_beq.f
2204       PCADDR pc = abuf->addr;
2205       PCADDR npc;
2206       branch_status br_status = BRANCH_UNTAKEN;
2207       vpc = vpc + 1;
2208       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2209
2210 if (NOTBI (XORBI (current_cpu->hardware.h_nbit, current_cpu->hardware.h_vbit))) {
2211 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2212 }
2213
2214       pbb_br_npc = npc;
2215       pbb_br_status = br_status;
2216 #undef FLD
2217     }
2218     NEXT (vpc);
2219
2220 // ********** blt $soffset8
2221
2222   CASE (INSN_BLT):
2223     {
2224       thumb_scache* abuf = vpc;
2225 #define FLD(f) abuf->fields.sfmt_beq.f
2226       PCADDR pc = abuf->addr;
2227       PCADDR npc;
2228       branch_status br_status = BRANCH_UNTAKEN;
2229       vpc = vpc + 1;
2230       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2231
2232 if (XORBI (current_cpu->hardware.h_nbit, current_cpu->hardware.h_vbit)) {
2233 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2234 }
2235
2236       pbb_br_npc = npc;
2237       pbb_br_status = br_status;
2238 #undef FLD
2239     }
2240     NEXT (vpc);
2241
2242 // ********** bgt $soffset8
2243
2244   CASE (INSN_BGT):
2245     {
2246       thumb_scache* abuf = vpc;
2247 #define FLD(f) abuf->fields.sfmt_beq.f
2248       PCADDR pc = abuf->addr;
2249       PCADDR npc;
2250       branch_status br_status = BRANCH_UNTAKEN;
2251       vpc = vpc + 1;
2252       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2253
2254 if (NOTBI (ORBI (current_cpu->hardware.h_zbit, XORBI (current_cpu->hardware.h_nbit, current_cpu->hardware.h_vbit)))) {
2255 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2256 }
2257
2258       pbb_br_npc = npc;
2259       pbb_br_status = br_status;
2260 #undef FLD
2261     }
2262     NEXT (vpc);
2263
2264 // ********** ble $soffset8
2265
2266   CASE (INSN_BLE):
2267     {
2268       thumb_scache* abuf = vpc;
2269 #define FLD(f) abuf->fields.sfmt_beq.f
2270       PCADDR pc = abuf->addr;
2271       PCADDR npc;
2272       branch_status br_status = BRANCH_UNTAKEN;
2273       vpc = vpc + 1;
2274       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2275
2276 if (ORBI (current_cpu->hardware.h_zbit, XORBI (current_cpu->hardware.h_nbit, current_cpu->hardware.h_vbit))) {
2277 npc = FLD (i_soffset8); br_status = BRANCH_CACHEABLE;
2278 }
2279
2280       pbb_br_npc = npc;
2281       pbb_br_status = br_status;
2282 #undef FLD
2283     }
2284     NEXT (vpc);
2285
2286 // ********** swi $value8
2287
2288   CASE (INSN_SWI):
2289     {
2290       thumb_scache* abuf = vpc;
2291 #define FLD(f) abuf->fields.sfmt_swi.f
2292       PCADDR pc = abuf->addr;
2293       PCADDR npc;
2294       branch_status br_status = BRANCH_UNTAKEN;
2295       vpc = vpc + 1;
2296       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2297
2298 npc = current_cpu->thumb_swi (pc, FLD (f_value8)); br_status = BRANCH_UNCACHEABLE;
2299
2300       pbb_br_npc = npc;
2301       pbb_br_status = br_status;
2302 #undef FLD
2303     }
2304     NEXT (vpc);
2305
2306 // ********** b $offset11
2307
2308   CASE (INSN_B):
2309     {
2310       thumb_scache* abuf = vpc;
2311 #define FLD(f) abuf->fields.sfmt_b.f
2312       PCADDR pc = abuf->addr;
2313       PCADDR npc;
2314       branch_status br_status = BRANCH_UNTAKEN;
2315       vpc = vpc + 1;
2316       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2317
2318 npc = FLD (i_offset11); br_status = BRANCH_CACHEABLE;
2319
2320       pbb_br_npc = npc;
2321       pbb_br_status = br_status;
2322 #undef FLD
2323     }
2324     NEXT (vpc);
2325
2326 // ********** bl-hi ${lbwl-hi}
2327
2328   CASE (INSN_BL_HI):
2329     {
2330       thumb_scache* abuf = vpc;
2331 #define FLD(f) abuf->fields.sfmt_bl_hi.f
2332       PCADDR pc = abuf->addr;
2333       vpc = vpc + 1;
2334       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2335
2336 current_cpu->thumb_h_lr_t_set (ADDSI (ADDSI (pc, 4), SLLSI (FLD (f_lbwl_hi), 12)));
2337
2338 #undef FLD
2339     }
2340     NEXT (vpc);
2341
2342 // ********** bl-lo ${lbwl-lo}
2343
2344   CASE (INSN_BL_LO):
2345     {
2346       thumb_scache* abuf = vpc;
2347 #define FLD(f) abuf->fields.sfmt_bl_lo.f
2348       PCADDR pc = abuf->addr;
2349       PCADDR npc;
2350       branch_status br_status = BRANCH_UNTAKEN;
2351       vpc = vpc + 1;
2352       current_cpu->hardware.h_gr[((UINT) 15)] = ADDSI (pc, 4);
2353
2354 {
2355   SI tmp_cur_pc;
2356   tmp_cur_pc = pc;
2357 npc = ADDSI (current_cpu->thumb_h_lr_t_get (), SLLSI (FLD (f_lbwl_lo), 1)); br_status = BRANCH_UNCACHEABLE;
2358 current_cpu->thumb_h_lr_t_set (ORSI (ADDSI (tmp_cur_pc, 2), 1));
2359 }
2360
2361       pbb_br_npc = npc;
2362       pbb_br_status = br_status;
2363 #undef FLD
2364     }
2365     NEXT (vpc);
2366
2367
2368 #ifdef __GNUC__
2369     end_switch: ;
2370 #else
2371     default: abort();
2372 #endif
2373   }
2374
2375   // Save vpc for next time.
2376   current_cpu->thumb_engine.set_next_vpc (vpc);
2377 }
2378