OSDN Git Service

Regenerate cgen files, update copyright year.
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / cgen-cpu / sh / sh2a-nofpu-sem.cxx
1 /* Simulator instruction semantics for sh2a_nofpu.
2
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
4
5 Copyright (C) 2000-2010 Red Hat, Inc.
6
7 This file is part of the Red Hat simulators.
8
9
10 */
11
12
13 #if HAVE_CONFIG_H
14 #include "config.h"
15 #endif
16 #include "sh2a_nofpu.h"
17
18 using namespace sh2a_nofpu; // FIXME: namespace organization still wip
19 using namespace sh2a_nofpu; // FIXME: namespace organization still wip
20 #define GET_ATTR(name) GET_ATTR_##name ()
21
22
23 // ********** x-invalid: --invalid--
24
25 void
26 sh2a_nofpu_sem_x_invalid (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
27         sh2a_nofpu::write_stacks &buf)
28 {
29 #define FLD(f) abuf->fields.fmt_empty.f
30   sem_status status = SEM_STATUS_NORMAL;
31   sh2a_nofpu_scache* abuf = sem;
32   unsigned long long written = 0;
33   PCADDR pc = abuf->addr;
34   PCADDR npc = pc + 0;
35
36   {
37     current_cpu->invalid_insn (pc);
38     assert (0);
39     /* NOTREACHED */
40   }
41
42   current_cpu->done_insn (npc, status);
43 #undef FLD
44 }
45
46 // ********** add-compact: add $rm, $rn
47
48 void
49 sh2a_nofpu_sem_add_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
50         sh2a_nofpu::write_stacks &buf)
51 {
52 #define FLD(f) abuf->fields.sfmt_macl_compact.f
53   sem_status status = SEM_STATUS_NORMAL;
54   sh2a_nofpu_scache* abuf = sem;
55   unsigned long long written = 0;
56   PCADDR pc = abuf->addr;
57   PCADDR npc = pc + 2;
58
59   {
60     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
61     if (UNLIKELY(current_cpu->trace_result_p))
62       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
63     current_cpu->h_grc_set (FLD (f_rn), opval);
64   }
65
66   current_cpu->done_insn (npc, status);
67 #undef FLD
68 }
69
70 // ********** addi-compact: add #$imm8, $rn
71
72 void
73 sh2a_nofpu_sem_addi_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
74         sh2a_nofpu::write_stacks &buf)
75 {
76 #define FLD(f) abuf->fields.sfmt_addi_compact.f
77   sem_status status = SEM_STATUS_NORMAL;
78   sh2a_nofpu_scache* abuf = sem;
79   unsigned long long written = 0;
80   PCADDR pc = abuf->addr;
81   PCADDR npc = pc + 2;
82
83   {
84     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), EXTQISI (ANDQI (FLD (f_imm8), 255)));
85     if (UNLIKELY(current_cpu->trace_result_p))
86       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
87     current_cpu->h_grc_set (FLD (f_rn), opval);
88   }
89
90   current_cpu->done_insn (npc, status);
91 #undef FLD
92 }
93
94 // ********** addc-compact: addc $rm, $rn
95
96 void
97 sh2a_nofpu_sem_addc_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
98         sh2a_nofpu::write_stacks &buf)
99 {
100 #define FLD(f) abuf->fields.sfmt_macl_compact.f
101   sem_status status = SEM_STATUS_NORMAL;
102   sh2a_nofpu_scache* abuf = sem;
103   unsigned long long written = 0;
104   PCADDR pc = abuf->addr;
105   PCADDR npc = pc + 2;
106
107 {
108   BI tmp_flag;
109   tmp_flag = ADDCFSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
110   {
111     SI opval = ADDCSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
112     if (UNLIKELY(current_cpu->trace_result_p))
113       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
114     current_cpu->h_grc_set (FLD (f_rn), opval);
115   }
116   {
117     BI opval = tmp_flag;
118     if (UNLIKELY(current_cpu->trace_result_p))
119       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
120     current_cpu->h_tbit_set (opval);
121   }
122 }
123
124   current_cpu->done_insn (npc, status);
125 #undef FLD
126 }
127
128 // ********** addv-compact: addv $rm, $rn
129
130 void
131 sh2a_nofpu_sem_addv_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
132         sh2a_nofpu::write_stacks &buf)
133 {
134 #define FLD(f) abuf->fields.sfmt_macl_compact.f
135   sem_status status = SEM_STATUS_NORMAL;
136   sh2a_nofpu_scache* abuf = sem;
137   unsigned long long written = 0;
138   PCADDR pc = abuf->addr;
139   PCADDR npc = pc + 2;
140
141 {
142   BI tmp_t;
143   tmp_t = ADDOFSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)), 0);
144   {
145     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
146     if (UNLIKELY(current_cpu->trace_result_p))
147       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
148     current_cpu->h_grc_set (FLD (f_rn), opval);
149   }
150   {
151     BI opval = tmp_t;
152     if (UNLIKELY(current_cpu->trace_result_p))
153       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
154     current_cpu->h_tbit_set (opval);
155   }
156 }
157
158   current_cpu->done_insn (npc, status);
159 #undef FLD
160 }
161
162 // ********** and-compact: and $rm64, $rn64
163
164 void
165 sh2a_nofpu_sem_and_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
166         sh2a_nofpu::write_stacks &buf)
167 {
168 #define FLD(f) abuf->fields.sfmt_and_compact.f
169   sem_status status = SEM_STATUS_NORMAL;
170   sh2a_nofpu_scache* abuf = sem;
171   unsigned long long written = 0;
172   PCADDR pc = abuf->addr;
173   PCADDR npc = pc + 2;
174
175   {
176     DI opval = ANDDI (current_cpu->h_gr_get (FLD (f_rm)), current_cpu->h_gr_get (FLD (f_rn)));
177     if (UNLIKELY(current_cpu->trace_result_p))
178       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
179     current_cpu->h_gr_set (FLD (f_rn), opval);
180   }
181
182   current_cpu->done_insn (npc, status);
183 #undef FLD
184 }
185
186 // ********** andi-compact: and #$uimm8, r0
187
188 void
189 sh2a_nofpu_sem_andi_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
190         sh2a_nofpu::write_stacks &buf)
191 {
192 #define FLD(f) abuf->fields.sfmt_andi_compact.f
193   sem_status status = SEM_STATUS_NORMAL;
194   sh2a_nofpu_scache* abuf = sem;
195   unsigned long long written = 0;
196   PCADDR pc = abuf->addr;
197   PCADDR npc = pc + 2;
198
199   {
200     SI opval = ANDSI (current_cpu->h_grc_get (((UINT) 0)), ZEXTSIDI (FLD (f_imm8)));
201     if (UNLIKELY(current_cpu->trace_result_p))
202       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
203     current_cpu->h_grc_set (((UINT) 0), opval);
204   }
205
206   current_cpu->done_insn (npc, status);
207 #undef FLD
208 }
209
210 // ********** andb-compact: and.b #$imm8, @(r0, gbr)
211
212 void
213 sh2a_nofpu_sem_andb_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
214         sh2a_nofpu::write_stacks &buf)
215 {
216 #define FLD(f) abuf->fields.sfmt_andi_compact.f
217   sem_status status = SEM_STATUS_NORMAL;
218   sh2a_nofpu_scache* abuf = sem;
219   unsigned long long written = 0;
220   PCADDR pc = abuf->addr;
221   PCADDR npc = pc + 2;
222
223 {
224   DI tmp_addr;
225   UQI tmp_data;
226   tmp_addr = ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_gbr_get ());
227   tmp_data = ANDQI (current_cpu->GETMEMUQI (pc, tmp_addr), FLD (f_imm8));
228   {
229     UQI opval = tmp_data;
230     if (UNLIKELY(current_cpu->trace_result_p))
231       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
232     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
233   }
234 }
235
236   current_cpu->done_insn (npc, status);
237 #undef FLD
238 }
239
240 // ********** bf-compact: bf $disp8
241
242 void
243 sh2a_nofpu_sem_bf_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
244         sh2a_nofpu::write_stacks &buf)
245 {
246 #define FLD(f) abuf->fields.sfmt_bf_compact.f
247   sem_status status = SEM_STATUS_NORMAL;
248   sh2a_nofpu_scache* abuf = sem;
249   unsigned long long written = 0;
250   PCADDR pc = abuf->addr;
251   PCADDR npc = pc + 2;
252
253 if (NOTBI (current_cpu->h_tbit_get ())) {
254   {
255     UDI opval = FLD (i_disp8);
256     written |= (1ULL << 2);
257     if (UNLIKELY(current_cpu->trace_result_p))
258       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
259     current_cpu->branch (opval, npc, status);
260   }
261 }
262
263   abuf->written = written;
264   current_cpu->done_cti_insn (npc, status);
265 #undef FLD
266 }
267
268 // ********** bfs-compact: bf/s $disp8
269
270 void
271 sh2a_nofpu_sem_bfs_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
272         sh2a_nofpu::write_stacks &buf)
273 {
274 #define FLD(f) abuf->fields.sfmt_bf_compact.f
275   sem_status status = SEM_STATUS_NORMAL;
276   sh2a_nofpu_scache* abuf = sem;
277   unsigned long long written = 0;
278   PCADDR pc = abuf->addr;
279   PCADDR npc = pc + 2;
280
281 if (NOTBI (current_cpu->h_tbit_get ())) {
282 {
283   {
284     UDI opval = ADDDI (pc, 2);
285     written |= (1ULL << 3);
286     if (UNLIKELY(current_cpu->trace_result_p))
287       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
288     current_cpu->branch (opval, npc, status);
289   }
290 current_cpu->save_delayed_pc (FLD (i_disp8));
291   {
292     UDI opval = FLD (i_disp8);
293     buf.h_pc_writes [(tick + 1) % sh2a_nofpu::pipe_sz].push (sh2a_nofpu::write<UDI>(pc, opval));
294     if (UNLIKELY(current_cpu->trace_result_p))
295       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
296   }
297 }
298 }
299
300   abuf->written = written;
301   current_cpu->done_cti_insn (npc, status);
302 #undef FLD
303 }
304
305 // ********** bra-compact: bra $disp12
306
307 void
308 sh2a_nofpu_sem_bra_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
309         sh2a_nofpu::write_stacks &buf)
310 {
311 #define FLD(f) abuf->fields.sfmt_bra_compact.f
312   sem_status status = SEM_STATUS_NORMAL;
313   sh2a_nofpu_scache* abuf = sem;
314   unsigned long long written = 0;
315   PCADDR pc = abuf->addr;
316   PCADDR npc = pc + 2;
317
318 {
319   {
320     UDI opval = ADDDI (pc, 2);
321     if (UNLIKELY(current_cpu->trace_result_p))
322       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
323     current_cpu->branch (opval, npc, status);
324   }
325 current_cpu->save_delayed_pc (FLD (i_disp12));
326   {
327     UDI opval = FLD (i_disp12);
328     buf.h_pc_writes [(tick + 1) % sh2a_nofpu::pipe_sz].push (sh2a_nofpu::write<UDI>(pc, opval));
329     if (UNLIKELY(current_cpu->trace_result_p))
330       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
331   }
332 }
333
334   current_cpu->done_cti_insn (npc, status);
335 #undef FLD
336 }
337
338 // ********** braf-compact: braf $rn
339
340 void
341 sh2a_nofpu_sem_braf_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
342         sh2a_nofpu::write_stacks &buf)
343 {
344 #define FLD(f) abuf->fields.sfmt_divu_compact.f
345   sem_status status = SEM_STATUS_NORMAL;
346   sh2a_nofpu_scache* abuf = sem;
347   unsigned long long written = 0;
348   PCADDR pc = abuf->addr;
349   PCADDR npc = pc + 2;
350
351 {
352   {
353     UDI opval = ADDDI (pc, 2);
354     if (UNLIKELY(current_cpu->trace_result_p))
355       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
356     current_cpu->branch (opval, npc, status);
357   }
358 current_cpu->save_delayed_pc (ADDDI (EXTSIDI (current_cpu->h_grc_get (FLD (f_rn))), ADDDI (pc, 4)));
359   {
360     UDI opval = ADDDI (EXTSIDI (current_cpu->h_grc_get (FLD (f_rn))), ADDDI (pc, 4));
361     buf.h_pc_writes [(tick + 1) % sh2a_nofpu::pipe_sz].push (sh2a_nofpu::write<UDI>(pc, opval));
362     if (UNLIKELY(current_cpu->trace_result_p))
363       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
364   }
365 }
366
367   current_cpu->done_cti_insn (npc, status);
368 #undef FLD
369 }
370
371 // ********** bsr-compact: bsr $disp12
372
373 void
374 sh2a_nofpu_sem_bsr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
375         sh2a_nofpu::write_stacks &buf)
376 {
377 #define FLD(f) abuf->fields.sfmt_bra_compact.f
378   sem_status status = SEM_STATUS_NORMAL;
379   sh2a_nofpu_scache* abuf = sem;
380   unsigned long long written = 0;
381   PCADDR pc = abuf->addr;
382   PCADDR npc = pc + 2;
383
384 {
385   {
386     SI opval = ADDDI (pc, 4);
387     buf.h_pr_writes [(tick + 1) % sh2a_nofpu::pipe_sz].push (sh2a_nofpu::write<SI>(pc, opval));
388     if (UNLIKELY(current_cpu->trace_result_p))
389       current_cpu->trace_stream << "pr" << ":=0x" << hex << opval << dec << "  ";
390   }
391   {
392     UDI opval = ADDDI (pc, 2);
393     if (UNLIKELY(current_cpu->trace_result_p))
394       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
395     current_cpu->branch (opval, npc, status);
396   }
397 current_cpu->save_delayed_pc (FLD (i_disp12));
398   {
399     UDI opval = FLD (i_disp12);
400     buf.h_pc_writes [(tick + 1) % sh2a_nofpu::pipe_sz].push (sh2a_nofpu::write<UDI>(pc, opval));
401     if (UNLIKELY(current_cpu->trace_result_p))
402       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
403   }
404 }
405
406   current_cpu->done_cti_insn (npc, status);
407 #undef FLD
408 }
409
410 // ********** bsrf-compact: bsrf $rn
411
412 void
413 sh2a_nofpu_sem_bsrf_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
414         sh2a_nofpu::write_stacks &buf)
415 {
416 #define FLD(f) abuf->fields.sfmt_divu_compact.f
417   sem_status status = SEM_STATUS_NORMAL;
418   sh2a_nofpu_scache* abuf = sem;
419   unsigned long long written = 0;
420   PCADDR pc = abuf->addr;
421   PCADDR npc = pc + 2;
422
423 {
424   {
425     SI opval = ADDDI (pc, 4);
426     buf.h_pr_writes [(tick + 1) % sh2a_nofpu::pipe_sz].push (sh2a_nofpu::write<SI>(pc, opval));
427     if (UNLIKELY(current_cpu->trace_result_p))
428       current_cpu->trace_stream << "pr" << ":=0x" << hex << opval << dec << "  ";
429   }
430   {
431     UDI opval = ADDDI (pc, 2);
432     if (UNLIKELY(current_cpu->trace_result_p))
433       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
434     current_cpu->branch (opval, npc, status);
435   }
436 current_cpu->save_delayed_pc (ADDDI (EXTSIDI (current_cpu->h_grc_get (FLD (f_rn))), ADDDI (pc, 4)));
437   {
438     UDI opval = ADDDI (EXTSIDI (current_cpu->h_grc_get (FLD (f_rn))), ADDDI (pc, 4));
439     buf.h_pc_writes [(tick + 1) % sh2a_nofpu::pipe_sz].push (sh2a_nofpu::write<UDI>(pc, opval));
440     if (UNLIKELY(current_cpu->trace_result_p))
441       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
442   }
443 }
444
445   current_cpu->done_cti_insn (npc, status);
446 #undef FLD
447 }
448
449 // ********** bt-compact: bt $disp8
450
451 void
452 sh2a_nofpu_sem_bt_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
453         sh2a_nofpu::write_stacks &buf)
454 {
455 #define FLD(f) abuf->fields.sfmt_bf_compact.f
456   sem_status status = SEM_STATUS_NORMAL;
457   sh2a_nofpu_scache* abuf = sem;
458   unsigned long long written = 0;
459   PCADDR pc = abuf->addr;
460   PCADDR npc = pc + 2;
461
462 if (current_cpu->h_tbit_get ()) {
463   {
464     UDI opval = FLD (i_disp8);
465     written |= (1ULL << 2);
466     if (UNLIKELY(current_cpu->trace_result_p))
467       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
468     current_cpu->branch (opval, npc, status);
469   }
470 }
471
472   abuf->written = written;
473   current_cpu->done_cti_insn (npc, status);
474 #undef FLD
475 }
476
477 // ********** bts-compact: bt/s $disp8
478
479 void
480 sh2a_nofpu_sem_bts_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
481         sh2a_nofpu::write_stacks &buf)
482 {
483 #define FLD(f) abuf->fields.sfmt_bf_compact.f
484   sem_status status = SEM_STATUS_NORMAL;
485   sh2a_nofpu_scache* abuf = sem;
486   unsigned long long written = 0;
487   PCADDR pc = abuf->addr;
488   PCADDR npc = pc + 2;
489
490 if (current_cpu->h_tbit_get ()) {
491 {
492   {
493     UDI opval = ADDDI (pc, 2);
494     written |= (1ULL << 3);
495     if (UNLIKELY(current_cpu->trace_result_p))
496       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
497     current_cpu->branch (opval, npc, status);
498   }
499 current_cpu->save_delayed_pc (FLD (i_disp8));
500   {
501     UDI opval = FLD (i_disp8);
502     buf.h_pc_writes [(tick + 1) % sh2a_nofpu::pipe_sz].push (sh2a_nofpu::write<UDI>(pc, opval));
503     if (UNLIKELY(current_cpu->trace_result_p))
504       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
505   }
506 }
507 }
508
509   abuf->written = written;
510   current_cpu->done_cti_insn (npc, status);
511 #undef FLD
512 }
513
514 // ********** clrmac-compact: clrmac
515
516 void
517 sh2a_nofpu_sem_clrmac_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
518         sh2a_nofpu::write_stacks &buf)
519 {
520 #define FLD(f) abuf->fields.fmt_empty.f
521   sem_status status = SEM_STATUS_NORMAL;
522   sh2a_nofpu_scache* abuf = sem;
523   unsigned long long written = 0;
524   PCADDR pc = abuf->addr;
525   PCADDR npc = pc + 2;
526
527 {
528   {
529     SI opval = 0;
530     if (UNLIKELY(current_cpu->trace_result_p))
531       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
532     current_cpu->h_macl_set (opval);
533   }
534   {
535     SI opval = 0;
536     if (UNLIKELY(current_cpu->trace_result_p))
537       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
538     current_cpu->h_mach_set (opval);
539   }
540 }
541
542   current_cpu->done_insn (npc, status);
543 #undef FLD
544 }
545
546 // ********** clrt-compact: clrt
547
548 void
549 sh2a_nofpu_sem_clrt_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
550         sh2a_nofpu::write_stacks &buf)
551 {
552 #define FLD(f) abuf->fields.fmt_empty.f
553   sem_status status = SEM_STATUS_NORMAL;
554   sh2a_nofpu_scache* abuf = sem;
555   unsigned long long written = 0;
556   PCADDR pc = abuf->addr;
557   PCADDR npc = pc + 2;
558
559   {
560     BI opval = 0;
561     if (UNLIKELY(current_cpu->trace_result_p))
562       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
563     current_cpu->h_tbit_set (opval);
564   }
565
566   current_cpu->done_insn (npc, status);
567 #undef FLD
568 }
569
570 // ********** cmpeq-compact: cmp/eq $rm, $rn
571
572 void
573 sh2a_nofpu_sem_cmpeq_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
574         sh2a_nofpu::write_stacks &buf)
575 {
576 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
577   sem_status status = SEM_STATUS_NORMAL;
578   sh2a_nofpu_scache* abuf = sem;
579   unsigned long long written = 0;
580   PCADDR pc = abuf->addr;
581   PCADDR npc = pc + 2;
582
583   {
584     BI opval = EQSI (current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_grc_get (FLD (f_rn)));
585     if (UNLIKELY(current_cpu->trace_result_p))
586       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
587     current_cpu->h_tbit_set (opval);
588   }
589
590   current_cpu->done_insn (npc, status);
591 #undef FLD
592 }
593
594 // ********** cmpeqi-compact: cmp/eq #$imm8, r0
595
596 void
597 sh2a_nofpu_sem_cmpeqi_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
598         sh2a_nofpu::write_stacks &buf)
599 {
600 #define FLD(f) abuf->fields.sfmt_andi_compact.f
601   sem_status status = SEM_STATUS_NORMAL;
602   sh2a_nofpu_scache* abuf = sem;
603   unsigned long long written = 0;
604   PCADDR pc = abuf->addr;
605   PCADDR npc = pc + 2;
606
607   {
608     BI opval = EQSI (current_cpu->h_grc_get (((UINT) 0)), EXTQISI (ANDQI (FLD (f_imm8), 255)));
609     if (UNLIKELY(current_cpu->trace_result_p))
610       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
611     current_cpu->h_tbit_set (opval);
612   }
613
614   current_cpu->done_insn (npc, status);
615 #undef FLD
616 }
617
618 // ********** cmpge-compact: cmp/ge $rm, $rn
619
620 void
621 sh2a_nofpu_sem_cmpge_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
622         sh2a_nofpu::write_stacks &buf)
623 {
624 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
625   sem_status status = SEM_STATUS_NORMAL;
626   sh2a_nofpu_scache* abuf = sem;
627   unsigned long long written = 0;
628   PCADDR pc = abuf->addr;
629   PCADDR npc = pc + 2;
630
631   {
632     BI opval = GESI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
633     if (UNLIKELY(current_cpu->trace_result_p))
634       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
635     current_cpu->h_tbit_set (opval);
636   }
637
638   current_cpu->done_insn (npc, status);
639 #undef FLD
640 }
641
642 // ********** cmpgt-compact: cmp/gt $rm, $rn
643
644 void
645 sh2a_nofpu_sem_cmpgt_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
646         sh2a_nofpu::write_stacks &buf)
647 {
648 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
649   sem_status status = SEM_STATUS_NORMAL;
650   sh2a_nofpu_scache* abuf = sem;
651   unsigned long long written = 0;
652   PCADDR pc = abuf->addr;
653   PCADDR npc = pc + 2;
654
655   {
656     BI opval = GTSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
657     if (UNLIKELY(current_cpu->trace_result_p))
658       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
659     current_cpu->h_tbit_set (opval);
660   }
661
662   current_cpu->done_insn (npc, status);
663 #undef FLD
664 }
665
666 // ********** cmphi-compact: cmp/hi $rm, $rn
667
668 void
669 sh2a_nofpu_sem_cmphi_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
670         sh2a_nofpu::write_stacks &buf)
671 {
672 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
673   sem_status status = SEM_STATUS_NORMAL;
674   sh2a_nofpu_scache* abuf = sem;
675   unsigned long long written = 0;
676   PCADDR pc = abuf->addr;
677   PCADDR npc = pc + 2;
678
679   {
680     BI opval = GTUSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
681     if (UNLIKELY(current_cpu->trace_result_p))
682       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
683     current_cpu->h_tbit_set (opval);
684   }
685
686   current_cpu->done_insn (npc, status);
687 #undef FLD
688 }
689
690 // ********** cmphs-compact: cmp/hs $rm, $rn
691
692 void
693 sh2a_nofpu_sem_cmphs_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
694         sh2a_nofpu::write_stacks &buf)
695 {
696 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
697   sem_status status = SEM_STATUS_NORMAL;
698   sh2a_nofpu_scache* abuf = sem;
699   unsigned long long written = 0;
700   PCADDR pc = abuf->addr;
701   PCADDR npc = pc + 2;
702
703   {
704     BI opval = GEUSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
705     if (UNLIKELY(current_cpu->trace_result_p))
706       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
707     current_cpu->h_tbit_set (opval);
708   }
709
710   current_cpu->done_insn (npc, status);
711 #undef FLD
712 }
713
714 // ********** cmppl-compact: cmp/pl $rn
715
716 void
717 sh2a_nofpu_sem_cmppl_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
718         sh2a_nofpu::write_stacks &buf)
719 {
720 #define FLD(f) abuf->fields.sfmt_divu_compact.f
721   sem_status status = SEM_STATUS_NORMAL;
722   sh2a_nofpu_scache* abuf = sem;
723   unsigned long long written = 0;
724   PCADDR pc = abuf->addr;
725   PCADDR npc = pc + 2;
726
727   {
728     BI opval = GTSI (current_cpu->h_grc_get (FLD (f_rn)), 0);
729     if (UNLIKELY(current_cpu->trace_result_p))
730       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
731     current_cpu->h_tbit_set (opval);
732   }
733
734   current_cpu->done_insn (npc, status);
735 #undef FLD
736 }
737
738 // ********** cmppz-compact: cmp/pz $rn
739
740 void
741 sh2a_nofpu_sem_cmppz_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
742         sh2a_nofpu::write_stacks &buf)
743 {
744 #define FLD(f) abuf->fields.sfmt_divu_compact.f
745   sem_status status = SEM_STATUS_NORMAL;
746   sh2a_nofpu_scache* abuf = sem;
747   unsigned long long written = 0;
748   PCADDR pc = abuf->addr;
749   PCADDR npc = pc + 2;
750
751   {
752     BI opval = GESI (current_cpu->h_grc_get (FLD (f_rn)), 0);
753     if (UNLIKELY(current_cpu->trace_result_p))
754       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
755     current_cpu->h_tbit_set (opval);
756   }
757
758   current_cpu->done_insn (npc, status);
759 #undef FLD
760 }
761
762 // ********** cmpstr-compact: cmp/str $rm, $rn
763
764 void
765 sh2a_nofpu_sem_cmpstr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
766         sh2a_nofpu::write_stacks &buf)
767 {
768 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
769   sem_status status = SEM_STATUS_NORMAL;
770   sh2a_nofpu_scache* abuf = sem;
771   unsigned long long written = 0;
772   PCADDR pc = abuf->addr;
773   PCADDR npc = pc + 2;
774
775 {
776   BI tmp_t;
777   SI tmp_temp;
778   tmp_temp = XORSI (current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_grc_get (FLD (f_rn)));
779   tmp_t = EQSI (ANDSI (tmp_temp, 0xff000000), 0);
780   tmp_t = ORBI (EQSI (ANDSI (tmp_temp, 16711680), 0), tmp_t);
781   tmp_t = ORBI (EQSI (ANDSI (tmp_temp, 65280), 0), tmp_t);
782   tmp_t = ORBI (EQSI (ANDSI (tmp_temp, 255), 0), tmp_t);
783   {
784     BI opval = ((GTUBI (tmp_t, 0)) ? (1) : (0));
785     if (UNLIKELY(current_cpu->trace_result_p))
786       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
787     current_cpu->h_tbit_set (opval);
788   }
789 }
790
791   current_cpu->done_insn (npc, status);
792 #undef FLD
793 }
794
795 // ********** div0s-compact: div0s $rm, $rn
796
797 void
798 sh2a_nofpu_sem_div0s_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
799         sh2a_nofpu::write_stacks &buf)
800 {
801 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
802   sem_status status = SEM_STATUS_NORMAL;
803   sh2a_nofpu_scache* abuf = sem;
804   unsigned long long written = 0;
805   PCADDR pc = abuf->addr;
806   PCADDR npc = pc + 2;
807
808 {
809   {
810     BI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
811     if (UNLIKELY(current_cpu->trace_result_p))
812       current_cpu->trace_stream << "qbit" << ":=0x" << hex << opval << dec << "  ";
813     current_cpu->h_qbit_set (opval);
814   }
815   {
816     BI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rm)), 31);
817     if (UNLIKELY(current_cpu->trace_result_p))
818       current_cpu->trace_stream << "mbit" << ":=0x" << hex << opval << dec << "  ";
819     current_cpu->h_mbit_set (opval);
820   }
821   {
822     BI opval = ((EQSI (SRLSI (current_cpu->h_grc_get (FLD (f_rm)), 31), SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31))) ? (0) : (1));
823     if (UNLIKELY(current_cpu->trace_result_p))
824       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
825     current_cpu->h_tbit_set (opval);
826   }
827 }
828
829   current_cpu->done_insn (npc, status);
830 #undef FLD
831 }
832
833 // ********** div0u-compact: div0u
834
835 void
836 sh2a_nofpu_sem_div0u_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
837         sh2a_nofpu::write_stacks &buf)
838 {
839 #define FLD(f) abuf->fields.fmt_empty.f
840   sem_status status = SEM_STATUS_NORMAL;
841   sh2a_nofpu_scache* abuf = sem;
842   unsigned long long written = 0;
843   PCADDR pc = abuf->addr;
844   PCADDR npc = pc + 2;
845
846 {
847   {
848     BI opval = 0;
849     if (UNLIKELY(current_cpu->trace_result_p))
850       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
851     current_cpu->h_tbit_set (opval);
852   }
853   {
854     BI opval = 0;
855     if (UNLIKELY(current_cpu->trace_result_p))
856       current_cpu->trace_stream << "qbit" << ":=0x" << hex << opval << dec << "  ";
857     current_cpu->h_qbit_set (opval);
858   }
859   {
860     BI opval = 0;
861     if (UNLIKELY(current_cpu->trace_result_p))
862       current_cpu->trace_stream << "mbit" << ":=0x" << hex << opval << dec << "  ";
863     current_cpu->h_mbit_set (opval);
864   }
865 }
866
867   current_cpu->done_insn (npc, status);
868 #undef FLD
869 }
870
871 // ********** div1-compact: div1 $rm, $rn
872
873 void
874 sh2a_nofpu_sem_div1_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
875         sh2a_nofpu::write_stacks &buf)
876 {
877 #define FLD(f) abuf->fields.sfmt_macl_compact.f
878   sem_status status = SEM_STATUS_NORMAL;
879   sh2a_nofpu_scache* abuf = sem;
880   unsigned long long written = 0;
881   PCADDR pc = abuf->addr;
882   PCADDR npc = pc + 2;
883
884 {
885   BI tmp_oldq;
886   SI tmp_tmp0;
887   UQI tmp_tmp1;
888   tmp_oldq = current_cpu->h_qbit_get ();
889   {
890     BI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
891     if (UNLIKELY(current_cpu->trace_result_p))
892       current_cpu->trace_stream << "qbit" << ":=0x" << hex << opval << dec << "  ";
893     current_cpu->h_qbit_set (opval);
894   }
895   {
896     SI opval = ORSI (SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), ZEXTBISI (current_cpu->h_tbit_get ()));
897     if (UNLIKELY(current_cpu->trace_result_p))
898       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
899     current_cpu->h_grc_set (FLD (f_rn), opval);
900   }
901 if (NOTBI (tmp_oldq)) {
902 if (NOTBI (current_cpu->h_mbit_get ())) {
903 {
904   tmp_tmp0 = current_cpu->h_grc_get (FLD (f_rn));
905   {
906     SI opval = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
907     if (UNLIKELY(current_cpu->trace_result_p))
908       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
909     current_cpu->h_grc_set (FLD (f_rn), opval);
910   }
911   tmp_tmp1 = GTUSI (current_cpu->h_grc_get (FLD (f_rn)), tmp_tmp0);
912 if (NOTBI (current_cpu->h_qbit_get ())) {
913   {
914     BI opval = ((tmp_tmp1) ? (1) : (0));
915     if (UNLIKELY(current_cpu->trace_result_p))
916       current_cpu->trace_stream << "qbit" << ":=0x" << hex << opval << dec << "  ";
917     current_cpu->h_qbit_set (opval);
918   }
919 } else {
920   {
921     BI opval = ((EQQI (tmp_tmp1, 0)) ? (1) : (0));
922     if (UNLIKELY(current_cpu->trace_result_p))
923       current_cpu->trace_stream << "qbit" << ":=0x" << hex << opval << dec << "  ";
924     current_cpu->h_qbit_set (opval);
925   }
926 }
927 }
928 } else {
929 {
930   tmp_tmp0 = current_cpu->h_grc_get (FLD (f_rn));
931   {
932     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
933     if (UNLIKELY(current_cpu->trace_result_p))
934       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
935     current_cpu->h_grc_set (FLD (f_rn), opval);
936   }
937   tmp_tmp1 = LTUSI (current_cpu->h_grc_get (FLD (f_rn)), tmp_tmp0);
938 if (NOTBI (current_cpu->h_qbit_get ())) {
939   {
940     BI opval = ((EQQI (tmp_tmp1, 0)) ? (1) : (0));
941     if (UNLIKELY(current_cpu->trace_result_p))
942       current_cpu->trace_stream << "qbit" << ":=0x" << hex << opval << dec << "  ";
943     current_cpu->h_qbit_set (opval);
944   }
945 } else {
946   {
947     BI opval = ((tmp_tmp1) ? (1) : (0));
948     if (UNLIKELY(current_cpu->trace_result_p))
949       current_cpu->trace_stream << "qbit" << ":=0x" << hex << opval << dec << "  ";
950     current_cpu->h_qbit_set (opval);
951   }
952 }
953 }
954 }
955 } else {
956 if (NOTBI (current_cpu->h_mbit_get ())) {
957 {
958   tmp_tmp0 = current_cpu->h_grc_get (FLD (f_rn));
959   {
960     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_grc_get (FLD (f_rn)));
961     if (UNLIKELY(current_cpu->trace_result_p))
962       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
963     current_cpu->h_grc_set (FLD (f_rn), opval);
964   }
965   tmp_tmp1 = LTUSI (current_cpu->h_grc_get (FLD (f_rn)), tmp_tmp0);
966 if (NOTBI (current_cpu->h_qbit_get ())) {
967   {
968     BI opval = ((tmp_tmp1) ? (1) : (0));
969     if (UNLIKELY(current_cpu->trace_result_p))
970       current_cpu->trace_stream << "qbit" << ":=0x" << hex << opval << dec << "  ";
971     current_cpu->h_qbit_set (opval);
972   }
973 } else {
974   {
975     BI opval = ((EQQI (tmp_tmp1, 0)) ? (1) : (0));
976     if (UNLIKELY(current_cpu->trace_result_p))
977       current_cpu->trace_stream << "qbit" << ":=0x" << hex << opval << dec << "  ";
978     current_cpu->h_qbit_set (opval);
979   }
980 }
981 }
982 } else {
983 {
984   tmp_tmp0 = current_cpu->h_grc_get (FLD (f_rn));
985   {
986     SI opval = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
987     if (UNLIKELY(current_cpu->trace_result_p))
988       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
989     current_cpu->h_grc_set (FLD (f_rn), opval);
990   }
991   tmp_tmp1 = GTUSI (current_cpu->h_grc_get (FLD (f_rn)), tmp_tmp0);
992 if (NOTBI (current_cpu->h_qbit_get ())) {
993   {
994     BI opval = ((EQQI (tmp_tmp1, 0)) ? (1) : (0));
995     if (UNLIKELY(current_cpu->trace_result_p))
996       current_cpu->trace_stream << "qbit" << ":=0x" << hex << opval << dec << "  ";
997     current_cpu->h_qbit_set (opval);
998   }
999 } else {
1000   {
1001     BI opval = ((tmp_tmp1) ? (1) : (0));
1002     if (UNLIKELY(current_cpu->trace_result_p))
1003       current_cpu->trace_stream << "qbit" << ":=0x" << hex << opval << dec << "  ";
1004     current_cpu->h_qbit_set (opval);
1005   }
1006 }
1007 }
1008 }
1009 }
1010   {
1011     BI opval = ((EQBI (current_cpu->h_qbit_get (), current_cpu->h_mbit_get ())) ? (1) : (0));
1012     if (UNLIKELY(current_cpu->trace_result_p))
1013       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
1014     current_cpu->h_tbit_set (opval);
1015   }
1016 }
1017
1018   current_cpu->done_insn (npc, status);
1019 #undef FLD
1020 }
1021
1022 // ********** divu-compact: divu r0, $rn
1023
1024 void
1025 sh2a_nofpu_sem_divu_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1026         sh2a_nofpu::write_stacks &buf)
1027 {
1028 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1029   sem_status status = SEM_STATUS_NORMAL;
1030   sh2a_nofpu_scache* abuf = sem;
1031   unsigned long long written = 0;
1032   PCADDR pc = abuf->addr;
1033   PCADDR npc = pc + 2;
1034
1035   {
1036     SI opval = UDIVSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (((UINT) 0)));
1037     if (UNLIKELY(current_cpu->trace_result_p))
1038       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1039     current_cpu->h_grc_set (FLD (f_rn), opval);
1040   }
1041
1042   current_cpu->done_insn (npc, status);
1043 #undef FLD
1044 }
1045
1046 // ********** mulr-compact: mulr r0, $rn
1047
1048 void
1049 sh2a_nofpu_sem_mulr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1050         sh2a_nofpu::write_stacks &buf)
1051 {
1052 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1053   sem_status status = SEM_STATUS_NORMAL;
1054   sh2a_nofpu_scache* abuf = sem;
1055   unsigned long long written = 0;
1056   PCADDR pc = abuf->addr;
1057   PCADDR npc = pc + 2;
1058
1059   {
1060     SI opval = MULSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (((UINT) 0)));
1061     if (UNLIKELY(current_cpu->trace_result_p))
1062       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1063     current_cpu->h_grc_set (FLD (f_rn), opval);
1064   }
1065
1066   current_cpu->done_insn (npc, status);
1067 #undef FLD
1068 }
1069
1070 // ********** dmulsl-compact: dmuls.l $rm, $rn
1071
1072 void
1073 sh2a_nofpu_sem_dmulsl_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1074         sh2a_nofpu::write_stacks &buf)
1075 {
1076 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
1077   sem_status status = SEM_STATUS_NORMAL;
1078   sh2a_nofpu_scache* abuf = sem;
1079   unsigned long long written = 0;
1080   PCADDR pc = abuf->addr;
1081   PCADDR npc = pc + 2;
1082
1083 {
1084   DI tmp_result;
1085   tmp_result = MULDI (EXTSIDI (current_cpu->h_grc_get (FLD (f_rm))), EXTSIDI (current_cpu->h_grc_get (FLD (f_rn))));
1086   {
1087     SI opval = SUBWORDDISI (tmp_result, 0);
1088     if (UNLIKELY(current_cpu->trace_result_p))
1089       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1090     current_cpu->h_mach_set (opval);
1091   }
1092   {
1093     SI opval = SUBWORDDISI (tmp_result, 1);
1094     if (UNLIKELY(current_cpu->trace_result_p))
1095       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1096     current_cpu->h_macl_set (opval);
1097   }
1098 }
1099
1100   current_cpu->done_insn (npc, status);
1101 #undef FLD
1102 }
1103
1104 // ********** dmulul-compact: dmulu.l $rm, $rn
1105
1106 void
1107 sh2a_nofpu_sem_dmulul_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1108         sh2a_nofpu::write_stacks &buf)
1109 {
1110 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
1111   sem_status status = SEM_STATUS_NORMAL;
1112   sh2a_nofpu_scache* abuf = sem;
1113   unsigned long long written = 0;
1114   PCADDR pc = abuf->addr;
1115   PCADDR npc = pc + 2;
1116
1117 {
1118   DI tmp_result;
1119   tmp_result = MULDI (ZEXTSIDI (current_cpu->h_grc_get (FLD (f_rm))), ZEXTSIDI (current_cpu->h_grc_get (FLD (f_rn))));
1120   {
1121     SI opval = SUBWORDDISI (tmp_result, 0);
1122     if (UNLIKELY(current_cpu->trace_result_p))
1123       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1124     current_cpu->h_mach_set (opval);
1125   }
1126   {
1127     SI opval = SUBWORDDISI (tmp_result, 1);
1128     if (UNLIKELY(current_cpu->trace_result_p))
1129       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1130     current_cpu->h_macl_set (opval);
1131   }
1132 }
1133
1134   current_cpu->done_insn (npc, status);
1135 #undef FLD
1136 }
1137
1138 // ********** dt-compact: dt $rn
1139
1140 void
1141 sh2a_nofpu_sem_dt_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1142         sh2a_nofpu::write_stacks &buf)
1143 {
1144 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1145   sem_status status = SEM_STATUS_NORMAL;
1146   sh2a_nofpu_scache* abuf = sem;
1147   unsigned long long written = 0;
1148   PCADDR pc = abuf->addr;
1149   PCADDR npc = pc + 2;
1150
1151 {
1152   {
1153     SI opval = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
1154     if (UNLIKELY(current_cpu->trace_result_p))
1155       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1156     current_cpu->h_grc_set (FLD (f_rn), opval);
1157   }
1158   {
1159     BI opval = EQSI (current_cpu->h_grc_get (FLD (f_rn)), 0);
1160     if (UNLIKELY(current_cpu->trace_result_p))
1161       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
1162     current_cpu->h_tbit_set (opval);
1163   }
1164 }
1165
1166   current_cpu->done_insn (npc, status);
1167 #undef FLD
1168 }
1169
1170 // ********** extsb-compact: exts.b $rm, $rn
1171
1172 void
1173 sh2a_nofpu_sem_extsb_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1174         sh2a_nofpu::write_stacks &buf)
1175 {
1176 #define FLD(f) abuf->fields.sfmt_movl12_compact.f
1177   sem_status status = SEM_STATUS_NORMAL;
1178   sh2a_nofpu_scache* abuf = sem;
1179   unsigned long long written = 0;
1180   PCADDR pc = abuf->addr;
1181   PCADDR npc = pc + 2;
1182
1183   {
1184     SI opval = EXTQISI (SUBWORDSIQI (current_cpu->h_grc_get (FLD (f_rm)), 3));
1185     if (UNLIKELY(current_cpu->trace_result_p))
1186       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1187     current_cpu->h_grc_set (FLD (f_rn), opval);
1188   }
1189
1190   current_cpu->done_insn (npc, status);
1191 #undef FLD
1192 }
1193
1194 // ********** extsw-compact: exts.w $rm, $rn
1195
1196 void
1197 sh2a_nofpu_sem_extsw_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1198         sh2a_nofpu::write_stacks &buf)
1199 {
1200 #define FLD(f) abuf->fields.sfmt_movl12_compact.f
1201   sem_status status = SEM_STATUS_NORMAL;
1202   sh2a_nofpu_scache* abuf = sem;
1203   unsigned long long written = 0;
1204   PCADDR pc = abuf->addr;
1205   PCADDR npc = pc + 2;
1206
1207   {
1208     SI opval = EXTHISI (SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1));
1209     if (UNLIKELY(current_cpu->trace_result_p))
1210       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1211     current_cpu->h_grc_set (FLD (f_rn), opval);
1212   }
1213
1214   current_cpu->done_insn (npc, status);
1215 #undef FLD
1216 }
1217
1218 // ********** extub-compact: extu.b $rm, $rn
1219
1220 void
1221 sh2a_nofpu_sem_extub_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1222         sh2a_nofpu::write_stacks &buf)
1223 {
1224 #define FLD(f) abuf->fields.sfmt_movl12_compact.f
1225   sem_status status = SEM_STATUS_NORMAL;
1226   sh2a_nofpu_scache* abuf = sem;
1227   unsigned long long written = 0;
1228   PCADDR pc = abuf->addr;
1229   PCADDR npc = pc + 2;
1230
1231   {
1232     SI opval = ZEXTQISI (SUBWORDSIQI (current_cpu->h_grc_get (FLD (f_rm)), 3));
1233     if (UNLIKELY(current_cpu->trace_result_p))
1234       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1235     current_cpu->h_grc_set (FLD (f_rn), opval);
1236   }
1237
1238   current_cpu->done_insn (npc, status);
1239 #undef FLD
1240 }
1241
1242 // ********** extuw-compact: extu.w $rm, $rn
1243
1244 void
1245 sh2a_nofpu_sem_extuw_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1246         sh2a_nofpu::write_stacks &buf)
1247 {
1248 #define FLD(f) abuf->fields.sfmt_movl12_compact.f
1249   sem_status status = SEM_STATUS_NORMAL;
1250   sh2a_nofpu_scache* abuf = sem;
1251   unsigned long long written = 0;
1252   PCADDR pc = abuf->addr;
1253   PCADDR npc = pc + 2;
1254
1255   {
1256     SI opval = ZEXTHISI (SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1));
1257     if (UNLIKELY(current_cpu->trace_result_p))
1258       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1259     current_cpu->h_grc_set (FLD (f_rn), opval);
1260   }
1261
1262   current_cpu->done_insn (npc, status);
1263 #undef FLD
1264 }
1265
1266 // ********** frchg-compact: frchg
1267
1268 void
1269 sh2a_nofpu_sem_frchg_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1270         sh2a_nofpu::write_stacks &buf)
1271 {
1272 #define FLD(f) abuf->fields.fmt_empty.f
1273   sem_status status = SEM_STATUS_NORMAL;
1274   sh2a_nofpu_scache* abuf = sem;
1275   unsigned long long written = 0;
1276   PCADDR pc = abuf->addr;
1277   PCADDR npc = pc + 2;
1278
1279   {
1280     BI opval = NOTBI (current_cpu->h_frbit_get ());
1281     if (UNLIKELY(current_cpu->trace_result_p))
1282       current_cpu->trace_stream << "frbit" << ":=0x" << hex << opval << dec << "  ";
1283     current_cpu->h_frbit_set (opval);
1284   }
1285
1286   current_cpu->done_insn (npc, status);
1287 #undef FLD
1288 }
1289
1290 // ********** fschg-compact: fschg
1291
1292 void
1293 sh2a_nofpu_sem_fschg_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1294         sh2a_nofpu::write_stacks &buf)
1295 {
1296 #define FLD(f) abuf->fields.fmt_empty.f
1297   sem_status status = SEM_STATUS_NORMAL;
1298   sh2a_nofpu_scache* abuf = sem;
1299   unsigned long long written = 0;
1300   PCADDR pc = abuf->addr;
1301   PCADDR npc = pc + 2;
1302
1303   {
1304     BI opval = NOTBI (current_cpu->h_szbit_get ());
1305     if (UNLIKELY(current_cpu->trace_result_p))
1306       current_cpu->trace_stream << "szbit" << ":=0x" << hex << opval << dec << "  ";
1307     current_cpu->h_szbit_set (opval);
1308   }
1309
1310   current_cpu->done_insn (npc, status);
1311 #undef FLD
1312 }
1313
1314 // ********** jmp-compact: jmp @$rn
1315
1316 void
1317 sh2a_nofpu_sem_jmp_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1318         sh2a_nofpu::write_stacks &buf)
1319 {
1320 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1321   sem_status status = SEM_STATUS_NORMAL;
1322   sh2a_nofpu_scache* abuf = sem;
1323   unsigned long long written = 0;
1324   PCADDR pc = abuf->addr;
1325   PCADDR npc = pc + 2;
1326
1327 {
1328   {
1329     UDI opval = ADDDI (pc, 2);
1330     if (UNLIKELY(current_cpu->trace_result_p))
1331       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
1332     current_cpu->branch (opval, npc, status);
1333   }
1334 current_cpu->save_delayed_pc (current_cpu->h_grc_get (FLD (f_rn)));
1335   {
1336     UDI opval = current_cpu->h_grc_get (FLD (f_rn));
1337     buf.h_pc_writes [(tick + 1) % sh2a_nofpu::pipe_sz].push (sh2a_nofpu::write<UDI>(pc, opval));
1338     if (UNLIKELY(current_cpu->trace_result_p))
1339       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
1340   }
1341 current_cpu->cg_profile (pc, current_cpu->h_grc_get (FLD (f_rn)));
1342 }
1343
1344   current_cpu->done_cti_insn (npc, status);
1345 #undef FLD
1346 }
1347
1348 // ********** jsr-compact: jsr @$rn
1349
1350 void
1351 sh2a_nofpu_sem_jsr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1352         sh2a_nofpu::write_stacks &buf)
1353 {
1354 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1355   sem_status status = SEM_STATUS_NORMAL;
1356   sh2a_nofpu_scache* abuf = sem;
1357   unsigned long long written = 0;
1358   PCADDR pc = abuf->addr;
1359   PCADDR npc = pc + 2;
1360
1361 {
1362   {
1363     SI opval = ADDDI (pc, 4);
1364     buf.h_pr_writes [(tick + 1) % sh2a_nofpu::pipe_sz].push (sh2a_nofpu::write<SI>(pc, opval));
1365     if (UNLIKELY(current_cpu->trace_result_p))
1366       current_cpu->trace_stream << "pr" << ":=0x" << hex << opval << dec << "  ";
1367   }
1368   {
1369     UDI opval = ADDDI (pc, 2);
1370     if (UNLIKELY(current_cpu->trace_result_p))
1371       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
1372     current_cpu->branch (opval, npc, status);
1373   }
1374 current_cpu->save_delayed_pc (current_cpu->h_grc_get (FLD (f_rn)));
1375   {
1376     UDI opval = current_cpu->h_grc_get (FLD (f_rn));
1377     buf.h_pc_writes [(tick + 1) % sh2a_nofpu::pipe_sz].push (sh2a_nofpu::write<UDI>(pc, opval));
1378     if (UNLIKELY(current_cpu->trace_result_p))
1379       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
1380   }
1381 current_cpu->cg_profile (pc, current_cpu->h_grc_get (FLD (f_rn)));
1382 }
1383
1384   current_cpu->done_cti_insn (npc, status);
1385 #undef FLD
1386 }
1387
1388 // ********** ldc-gbr-compact: ldc $rn, gbr
1389
1390 void
1391 sh2a_nofpu_sem_ldc_gbr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1392         sh2a_nofpu::write_stacks &buf)
1393 {
1394 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1395   sem_status status = SEM_STATUS_NORMAL;
1396   sh2a_nofpu_scache* abuf = sem;
1397   unsigned long long written = 0;
1398   PCADDR pc = abuf->addr;
1399   PCADDR npc = pc + 2;
1400
1401   {
1402     SI opval = current_cpu->h_grc_get (FLD (f_rn));
1403     if (UNLIKELY(current_cpu->trace_result_p))
1404       current_cpu->trace_stream << "gbr" << ":=0x" << hex << opval << dec << "  ";
1405     current_cpu->h_gbr_set (opval);
1406   }
1407
1408   current_cpu->done_insn (npc, status);
1409 #undef FLD
1410 }
1411
1412 // ********** ldc-vbr-compact: ldc $rn, vbr
1413
1414 void
1415 sh2a_nofpu_sem_ldc_vbr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1416         sh2a_nofpu::write_stacks &buf)
1417 {
1418 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1419   sem_status status = SEM_STATUS_NORMAL;
1420   sh2a_nofpu_scache* abuf = sem;
1421   unsigned long long written = 0;
1422   PCADDR pc = abuf->addr;
1423   PCADDR npc = pc + 2;
1424
1425   {
1426     SI opval = current_cpu->h_grc_get (FLD (f_rn));
1427     if (UNLIKELY(current_cpu->trace_result_p))
1428       current_cpu->trace_stream << "vbr" << ":=0x" << hex << opval << dec << "  ";
1429     current_cpu->h_vbr_set (opval);
1430   }
1431
1432   current_cpu->done_insn (npc, status);
1433 #undef FLD
1434 }
1435
1436 // ********** ldc-sr-compact: ldc $rn, sr
1437
1438 void
1439 sh2a_nofpu_sem_ldc_sr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1440         sh2a_nofpu::write_stacks &buf)
1441 {
1442 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1443   sem_status status = SEM_STATUS_NORMAL;
1444   sh2a_nofpu_scache* abuf = sem;
1445   unsigned long long written = 0;
1446   PCADDR pc = abuf->addr;
1447   PCADDR npc = pc + 2;
1448
1449   {
1450     SI opval = current_cpu->h_grc_get (FLD (f_rn));
1451     if (UNLIKELY(current_cpu->trace_result_p))
1452       current_cpu->trace_stream << "sr" << ":=0x" << hex << opval << dec << "  ";
1453     current_cpu->hardware.h_sr = opval;
1454   }
1455
1456   current_cpu->done_insn (npc, status);
1457 #undef FLD
1458 }
1459
1460 // ********** ldcl-gbr-compact: ldc.l @${rn}+, gbr
1461
1462 void
1463 sh2a_nofpu_sem_ldcl_gbr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1464         sh2a_nofpu::write_stacks &buf)
1465 {
1466 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1467   sem_status status = SEM_STATUS_NORMAL;
1468   sh2a_nofpu_scache* abuf = sem;
1469   unsigned long long written = 0;
1470   PCADDR pc = abuf->addr;
1471   PCADDR npc = pc + 2;
1472
1473 {
1474   {
1475     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1476     if (UNLIKELY(current_cpu->trace_result_p))
1477       current_cpu->trace_stream << "gbr" << ":=0x" << hex << opval << dec << "  ";
1478     current_cpu->h_gbr_set (opval);
1479   }
1480   {
1481     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1482     if (UNLIKELY(current_cpu->trace_result_p))
1483       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1484     current_cpu->h_grc_set (FLD (f_rn), opval);
1485   }
1486 }
1487
1488   current_cpu->done_insn (npc, status);
1489 #undef FLD
1490 }
1491
1492 // ********** ldcl-vbr-compact: ldc.l @${rn}+, vbr
1493
1494 void
1495 sh2a_nofpu_sem_ldcl_vbr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1496         sh2a_nofpu::write_stacks &buf)
1497 {
1498 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1499   sem_status status = SEM_STATUS_NORMAL;
1500   sh2a_nofpu_scache* abuf = sem;
1501   unsigned long long written = 0;
1502   PCADDR pc = abuf->addr;
1503   PCADDR npc = pc + 2;
1504
1505 {
1506   {
1507     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1508     if (UNLIKELY(current_cpu->trace_result_p))
1509       current_cpu->trace_stream << "vbr" << ":=0x" << hex << opval << dec << "  ";
1510     current_cpu->h_vbr_set (opval);
1511   }
1512   {
1513     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1514     if (UNLIKELY(current_cpu->trace_result_p))
1515       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1516     current_cpu->h_grc_set (FLD (f_rn), opval);
1517   }
1518 }
1519
1520   current_cpu->done_insn (npc, status);
1521 #undef FLD
1522 }
1523
1524 // ********** lds-mach-compact: lds $rn, mach
1525
1526 void
1527 sh2a_nofpu_sem_lds_mach_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1528         sh2a_nofpu::write_stacks &buf)
1529 {
1530 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1531   sem_status status = SEM_STATUS_NORMAL;
1532   sh2a_nofpu_scache* abuf = sem;
1533   unsigned long long written = 0;
1534   PCADDR pc = abuf->addr;
1535   PCADDR npc = pc + 2;
1536
1537   {
1538     SI opval = current_cpu->h_grc_get (FLD (f_rn));
1539     if (UNLIKELY(current_cpu->trace_result_p))
1540       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1541     current_cpu->h_mach_set (opval);
1542   }
1543
1544   current_cpu->done_insn (npc, status);
1545 #undef FLD
1546 }
1547
1548 // ********** ldsl-mach-compact: lds.l @${rn}+, mach
1549
1550 void
1551 sh2a_nofpu_sem_ldsl_mach_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1552         sh2a_nofpu::write_stacks &buf)
1553 {
1554 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1555   sem_status status = SEM_STATUS_NORMAL;
1556   sh2a_nofpu_scache* abuf = sem;
1557   unsigned long long written = 0;
1558   PCADDR pc = abuf->addr;
1559   PCADDR npc = pc + 2;
1560
1561 {
1562   {
1563     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1564     if (UNLIKELY(current_cpu->trace_result_p))
1565       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1566     current_cpu->h_mach_set (opval);
1567   }
1568   {
1569     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1570     if (UNLIKELY(current_cpu->trace_result_p))
1571       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1572     current_cpu->h_grc_set (FLD (f_rn), opval);
1573   }
1574 }
1575
1576   current_cpu->done_insn (npc, status);
1577 #undef FLD
1578 }
1579
1580 // ********** lds-macl-compact: lds $rn, macl
1581
1582 void
1583 sh2a_nofpu_sem_lds_macl_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1584         sh2a_nofpu::write_stacks &buf)
1585 {
1586 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1587   sem_status status = SEM_STATUS_NORMAL;
1588   sh2a_nofpu_scache* abuf = sem;
1589   unsigned long long written = 0;
1590   PCADDR pc = abuf->addr;
1591   PCADDR npc = pc + 2;
1592
1593   {
1594     SI opval = current_cpu->h_grc_get (FLD (f_rn));
1595     if (UNLIKELY(current_cpu->trace_result_p))
1596       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1597     current_cpu->h_macl_set (opval);
1598   }
1599
1600   current_cpu->done_insn (npc, status);
1601 #undef FLD
1602 }
1603
1604 // ********** ldsl-macl-compact: lds.l @${rn}+, macl
1605
1606 void
1607 sh2a_nofpu_sem_ldsl_macl_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1608         sh2a_nofpu::write_stacks &buf)
1609 {
1610 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1611   sem_status status = SEM_STATUS_NORMAL;
1612   sh2a_nofpu_scache* abuf = sem;
1613   unsigned long long written = 0;
1614   PCADDR pc = abuf->addr;
1615   PCADDR npc = pc + 2;
1616
1617 {
1618   {
1619     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1620     if (UNLIKELY(current_cpu->trace_result_p))
1621       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1622     current_cpu->h_macl_set (opval);
1623   }
1624   {
1625     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1626     if (UNLIKELY(current_cpu->trace_result_p))
1627       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1628     current_cpu->h_grc_set (FLD (f_rn), opval);
1629   }
1630 }
1631
1632   current_cpu->done_insn (npc, status);
1633 #undef FLD
1634 }
1635
1636 // ********** lds-pr-compact: lds $rn, pr
1637
1638 void
1639 sh2a_nofpu_sem_lds_pr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1640         sh2a_nofpu::write_stacks &buf)
1641 {
1642 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1643   sem_status status = SEM_STATUS_NORMAL;
1644   sh2a_nofpu_scache* abuf = sem;
1645   unsigned long long written = 0;
1646   PCADDR pc = abuf->addr;
1647   PCADDR npc = pc + 2;
1648
1649   {
1650     SI opval = current_cpu->h_grc_get (FLD (f_rn));
1651     if (UNLIKELY(current_cpu->trace_result_p))
1652       current_cpu->trace_stream << "pr" << ":=0x" << hex << opval << dec << "  ";
1653     current_cpu->h_pr_set (opval);
1654   }
1655
1656   current_cpu->done_insn (npc, status);
1657 #undef FLD
1658 }
1659
1660 // ********** ldsl-pr-compact: lds.l @${rn}+, pr
1661
1662 void
1663 sh2a_nofpu_sem_ldsl_pr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1664         sh2a_nofpu::write_stacks &buf)
1665 {
1666 #define FLD(f) abuf->fields.sfmt_divu_compact.f
1667   sem_status status = SEM_STATUS_NORMAL;
1668   sh2a_nofpu_scache* abuf = sem;
1669   unsigned long long written = 0;
1670   PCADDR pc = abuf->addr;
1671   PCADDR npc = pc + 2;
1672
1673 {
1674   {
1675     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1676     if (UNLIKELY(current_cpu->trace_result_p))
1677       current_cpu->trace_stream << "pr" << ":=0x" << hex << opval << dec << "  ";
1678     current_cpu->h_pr_set (opval);
1679   }
1680   {
1681     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1682     if (UNLIKELY(current_cpu->trace_result_p))
1683       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1684     current_cpu->h_grc_set (FLD (f_rn), opval);
1685   }
1686 }
1687
1688   current_cpu->done_insn (npc, status);
1689 #undef FLD
1690 }
1691
1692 // ********** macl-compact: mac.l @${rm}+, @${rn}+
1693
1694 void
1695 sh2a_nofpu_sem_macl_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1696         sh2a_nofpu::write_stacks &buf)
1697 {
1698 #define FLD(f) abuf->fields.sfmt_macl_compact.f
1699   sem_status status = SEM_STATUS_NORMAL;
1700   sh2a_nofpu_scache* abuf = sem;
1701   unsigned long long written = 0;
1702   PCADDR pc = abuf->addr;
1703   PCADDR npc = pc + 2;
1704
1705 {
1706   DI tmp_tmpry;
1707   DI tmp_mac;
1708   DI tmp_result;
1709   SI tmp_x;
1710   SI tmp_y;
1711   tmp_x = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1712   {
1713     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1714     if (UNLIKELY(current_cpu->trace_result_p))
1715       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1716     current_cpu->h_grc_set (FLD (f_rn), opval);
1717   }
1718 if (EQSI (FLD (f_rn), FLD (f_rm))) {
1719 {
1720   {
1721     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1722     if (UNLIKELY(current_cpu->trace_result_p))
1723       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1724     current_cpu->h_grc_set (FLD (f_rn), opval);
1725   }
1726   {
1727     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 4);
1728     written |= (1ULL << 11);
1729     if (UNLIKELY(current_cpu->trace_result_p))
1730       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
1731     current_cpu->h_grc_set (FLD (f_rm), opval);
1732   }
1733 }
1734 }
1735   tmp_y = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rm)));
1736   {
1737     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 4);
1738     written |= (1ULL << 11);
1739     if (UNLIKELY(current_cpu->trace_result_p))
1740       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
1741     current_cpu->h_grc_set (FLD (f_rm), opval);
1742   }
1743   tmp_tmpry = MULDI (ZEXTSIDI (tmp_x), ZEXTSIDI (tmp_y));
1744   tmp_mac = ORDI (SLLDI (ZEXTSIDI (current_cpu->h_mach_get ()), 32), ZEXTSIDI (current_cpu->h_macl_get ()));
1745   tmp_result = ADDDI (tmp_mac, tmp_tmpry);
1746 {
1747 if (current_cpu->h_sbit_get ()) {
1748 {
1749   SI tmp_min;
1750   SI tmp_max;
1751   tmp_max = SRLDI (INVDI (0), 16);
1752   tmp_min = SRLDI (INVDI (0), 15);
1753 if (GTDI (tmp_result, tmp_max)) {
1754   tmp_result = tmp_max;
1755 } else {
1756 if (LTDI (tmp_result, tmp_min)) {
1757   tmp_result = tmp_min;
1758 }
1759 }
1760 }
1761 }
1762   {
1763     SI opval = SUBWORDDISI (tmp_result, 0);
1764     if (UNLIKELY(current_cpu->trace_result_p))
1765       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1766     current_cpu->h_mach_set (opval);
1767   }
1768   {
1769     SI opval = SUBWORDDISI (tmp_result, 1);
1770     if (UNLIKELY(current_cpu->trace_result_p))
1771       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1772     current_cpu->h_macl_set (opval);
1773   }
1774 }
1775 }
1776
1777   abuf->written = written;
1778   current_cpu->done_insn (npc, status);
1779 #undef FLD
1780 }
1781
1782 // ********** macw-compact: mac.w @${rm}+, @${rn}+
1783
1784 void
1785 sh2a_nofpu_sem_macw_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1786         sh2a_nofpu::write_stacks &buf)
1787 {
1788 #define FLD(f) abuf->fields.sfmt_macl_compact.f
1789   sem_status status = SEM_STATUS_NORMAL;
1790   sh2a_nofpu_scache* abuf = sem;
1791   unsigned long long written = 0;
1792   PCADDR pc = abuf->addr;
1793   PCADDR npc = pc + 2;
1794
1795 {
1796   SI tmp_tmpry;
1797   DI tmp_mac;
1798   DI tmp_result;
1799   HI tmp_x;
1800   HI tmp_y;
1801   tmp_x = current_cpu->GETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1802   {
1803     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
1804     if (UNLIKELY(current_cpu->trace_result_p))
1805       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1806     current_cpu->h_grc_set (FLD (f_rn), opval);
1807   }
1808 if (EQSI (FLD (f_rn), FLD (f_rm))) {
1809 {
1810   {
1811     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
1812     if (UNLIKELY(current_cpu->trace_result_p))
1813       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1814     current_cpu->h_grc_set (FLD (f_rn), opval);
1815   }
1816   {
1817     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 2);
1818     written |= (1ULL << 11);
1819     if (UNLIKELY(current_cpu->trace_result_p))
1820       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
1821     current_cpu->h_grc_set (FLD (f_rm), opval);
1822   }
1823 }
1824 }
1825   tmp_y = current_cpu->GETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rm)));
1826   {
1827     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 2);
1828     written |= (1ULL << 11);
1829     if (UNLIKELY(current_cpu->trace_result_p))
1830       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
1831     current_cpu->h_grc_set (FLD (f_rm), opval);
1832   }
1833   tmp_tmpry = MULSI (ZEXTHISI (tmp_x), ZEXTHISI (tmp_y));
1834 if (current_cpu->h_sbit_get ()) {
1835 {
1836 if (ADDOFSI (tmp_tmpry, current_cpu->h_macl_get (), 0)) {
1837   {
1838     SI opval = 1;
1839     written |= (1ULL << 9);
1840     if (UNLIKELY(current_cpu->trace_result_p))
1841       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1842     current_cpu->h_mach_set (opval);
1843   }
1844 }
1845   {
1846     SI opval = ADDSI (tmp_tmpry, current_cpu->h_macl_get ());
1847     written |= (1ULL << 10);
1848     if (UNLIKELY(current_cpu->trace_result_p))
1849       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1850     current_cpu->h_macl_set (opval);
1851   }
1852 }
1853 } else {
1854 {
1855   tmp_mac = ORDI (SLLDI (ZEXTSIDI (current_cpu->h_mach_get ()), 32), ZEXTSIDI (current_cpu->h_macl_get ()));
1856   tmp_result = ADDDI (tmp_mac, EXTSIDI (tmp_tmpry));
1857   {
1858     SI opval = SUBWORDDISI (tmp_result, 0);
1859     written |= (1ULL << 9);
1860     if (UNLIKELY(current_cpu->trace_result_p))
1861       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1862     current_cpu->h_mach_set (opval);
1863   }
1864   {
1865     SI opval = SUBWORDDISI (tmp_result, 1);
1866     written |= (1ULL << 10);
1867     if (UNLIKELY(current_cpu->trace_result_p))
1868       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1869     current_cpu->h_macl_set (opval);
1870   }
1871 }
1872 }
1873 }
1874
1875   abuf->written = written;
1876   current_cpu->done_insn (npc, status);
1877 #undef FLD
1878 }
1879
1880 // ********** mov-compact: mov $rm64, $rn64
1881
1882 void
1883 sh2a_nofpu_sem_mov_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1884         sh2a_nofpu::write_stacks &buf)
1885 {
1886 #define FLD(f) abuf->fields.sfmt_and_compact.f
1887   sem_status status = SEM_STATUS_NORMAL;
1888   sh2a_nofpu_scache* abuf = sem;
1889   unsigned long long written = 0;
1890   PCADDR pc = abuf->addr;
1891   PCADDR npc = pc + 2;
1892
1893   {
1894     DI opval = current_cpu->h_gr_get (FLD (f_rm));
1895     if (UNLIKELY(current_cpu->trace_result_p))
1896       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1897     current_cpu->h_gr_set (FLD (f_rn), opval);
1898   }
1899
1900   current_cpu->done_insn (npc, status);
1901 #undef FLD
1902 }
1903
1904 // ********** movi-compact: mov #$imm8, $rn
1905
1906 void
1907 sh2a_nofpu_sem_movi_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1908         sh2a_nofpu::write_stacks &buf)
1909 {
1910 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1911   sem_status status = SEM_STATUS_NORMAL;
1912   sh2a_nofpu_scache* abuf = sem;
1913   unsigned long long written = 0;
1914   PCADDR pc = abuf->addr;
1915   PCADDR npc = pc + 2;
1916
1917   {
1918     SI opval = EXTQIDI (ANDQI (FLD (f_imm8), 255));
1919     if (UNLIKELY(current_cpu->trace_result_p))
1920       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1921     current_cpu->h_grc_set (FLD (f_rn), opval);
1922   }
1923
1924   current_cpu->done_insn (npc, status);
1925 #undef FLD
1926 }
1927
1928 // ********** movi20-compact: movi20 #$imm20, $rn
1929
1930 void
1931 sh2a_nofpu_sem_movi20_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1932         sh2a_nofpu::write_stacks &buf)
1933 {
1934 #define FLD(f) abuf->fields.sfmt_movi20_compact.f
1935   sem_status status = SEM_STATUS_NORMAL;
1936   sh2a_nofpu_scache* abuf = sem;
1937   unsigned long long written = 0;
1938   PCADDR pc = abuf->addr;
1939   PCADDR npc = pc + 4;
1940
1941   {
1942     SI opval = FLD (f_imm20);
1943     if (UNLIKELY(current_cpu->trace_result_p))
1944       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1945     current_cpu->h_grc_set (FLD (f_rn), opval);
1946   }
1947
1948   current_cpu->done_insn (npc, status);
1949 #undef FLD
1950 }
1951
1952 // ********** movb1-compact: mov.b $rm, @$rn
1953
1954 void
1955 sh2a_nofpu_sem_movb1_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1956         sh2a_nofpu::write_stacks &buf)
1957 {
1958 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
1959   sem_status status = SEM_STATUS_NORMAL;
1960   sh2a_nofpu_scache* abuf = sem;
1961   unsigned long long written = 0;
1962   PCADDR pc = abuf->addr;
1963   PCADDR npc = pc + 2;
1964
1965   {
1966     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (FLD (f_rm)), 3);
1967     if (UNLIKELY(current_cpu->trace_result_p))
1968       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
1969     current_cpu->SETMEMUQI (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
1970   }
1971
1972   current_cpu->done_insn (npc, status);
1973 #undef FLD
1974 }
1975
1976 // ********** movb2-compact: mov.b $rm, @-$rn
1977
1978 void
1979 sh2a_nofpu_sem_movb2_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
1980         sh2a_nofpu::write_stacks &buf)
1981 {
1982 #define FLD(f) abuf->fields.sfmt_macl_compact.f
1983   sem_status status = SEM_STATUS_NORMAL;
1984   sh2a_nofpu_scache* abuf = sem;
1985   unsigned long long written = 0;
1986   PCADDR pc = abuf->addr;
1987   PCADDR npc = pc + 2;
1988
1989 {
1990   DI tmp_addr;
1991   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
1992   {
1993     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (FLD (f_rm)), 3);
1994     if (UNLIKELY(current_cpu->trace_result_p))
1995       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
1996     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
1997   }
1998   {
1999     SI opval = tmp_addr;
2000     if (UNLIKELY(current_cpu->trace_result_p))
2001       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2002     current_cpu->h_grc_set (FLD (f_rn), opval);
2003   }
2004 }
2005
2006   current_cpu->done_insn (npc, status);
2007 #undef FLD
2008 }
2009
2010 // ********** movb3-compact: mov.b $rm, @(r0,$rn)
2011
2012 void
2013 sh2a_nofpu_sem_movb3_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2014         sh2a_nofpu::write_stacks &buf)
2015 {
2016 #define FLD(f) abuf->fields.sfmt_movb3_compact.f
2017   sem_status status = SEM_STATUS_NORMAL;
2018   sh2a_nofpu_scache* abuf = sem;
2019   unsigned long long written = 0;
2020   PCADDR pc = abuf->addr;
2021   PCADDR npc = pc + 2;
2022
2023   {
2024     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (FLD (f_rm)), 3);
2025     if (UNLIKELY(current_cpu->trace_result_p))
2026       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))) << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
2027     current_cpu->SETMEMUQI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))), opval);
2028   }
2029
2030   current_cpu->done_insn (npc, status);
2031 #undef FLD
2032 }
2033
2034 // ********** movb4-compact: mov.b r0, @($imm8, gbr)
2035
2036 void
2037 sh2a_nofpu_sem_movb4_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2038         sh2a_nofpu::write_stacks &buf)
2039 {
2040 #define FLD(f) abuf->fields.sfmt_andi_compact.f
2041   sem_status status = SEM_STATUS_NORMAL;
2042   sh2a_nofpu_scache* abuf = sem;
2043   unsigned long long written = 0;
2044   PCADDR pc = abuf->addr;
2045   PCADDR npc = pc + 2;
2046
2047 {
2048   DI tmp_addr;
2049   tmp_addr = ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8));
2050   {
2051     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (((UINT) 0)), 3);
2052     if (UNLIKELY(current_cpu->trace_result_p))
2053       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
2054     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
2055   }
2056 }
2057
2058   current_cpu->done_insn (npc, status);
2059 #undef FLD
2060 }
2061
2062 // ********** movb5-compact: mov.b r0, @($imm4, $rm)
2063
2064 void
2065 sh2a_nofpu_sem_movb5_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2066         sh2a_nofpu::write_stacks &buf)
2067 {
2068 #define FLD(f) abuf->fields.sfmt_movb5_compact.f
2069   sem_status status = SEM_STATUS_NORMAL;
2070   sh2a_nofpu_scache* abuf = sem;
2071   unsigned long long written = 0;
2072   PCADDR pc = abuf->addr;
2073   PCADDR npc = pc + 2;
2074
2075 {
2076   DI tmp_addr;
2077   tmp_addr = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4));
2078   {
2079     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (((UINT) 0)), 3);
2080     if (UNLIKELY(current_cpu->trace_result_p))
2081       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
2082     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
2083   }
2084 }
2085
2086   current_cpu->done_insn (npc, status);
2087 #undef FLD
2088 }
2089
2090 // ********** movb6-compact: mov.b @$rm, $rn
2091
2092 void
2093 sh2a_nofpu_sem_movb6_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2094         sh2a_nofpu::write_stacks &buf)
2095 {
2096 #define FLD(f) abuf->fields.sfmt_movl12_compact.f
2097   sem_status status = SEM_STATUS_NORMAL;
2098   sh2a_nofpu_scache* abuf = sem;
2099   unsigned long long written = 0;
2100   PCADDR pc = abuf->addr;
2101   PCADDR npc = pc + 2;
2102
2103   {
2104     SI opval = EXTQISI (current_cpu->GETMEMQI (pc, current_cpu->h_grc_get (FLD (f_rm))));
2105     if (UNLIKELY(current_cpu->trace_result_p))
2106       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2107     current_cpu->h_grc_set (FLD (f_rn), opval);
2108   }
2109
2110   current_cpu->done_insn (npc, status);
2111 #undef FLD
2112 }
2113
2114 // ********** movb7-compact: mov.b @${rm}+, $rn
2115
2116 void
2117 sh2a_nofpu_sem_movb7_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2118         sh2a_nofpu::write_stacks &buf)
2119 {
2120 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2121   sem_status status = SEM_STATUS_NORMAL;
2122   sh2a_nofpu_scache* abuf = sem;
2123   unsigned long long written = 0;
2124   PCADDR pc = abuf->addr;
2125   PCADDR npc = pc + 2;
2126
2127 {
2128   QI tmp_data;
2129   tmp_data = current_cpu->GETMEMQI (pc, current_cpu->h_grc_get (FLD (f_rm)));
2130 if (EQSI (FLD (f_rm), FLD (f_rn))) {
2131   {
2132     SI opval = EXTQISI (tmp_data);
2133     written |= (1ULL << 4);
2134     if (UNLIKELY(current_cpu->trace_result_p))
2135       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2136     current_cpu->h_grc_set (FLD (f_rm), opval);
2137   }
2138 } else {
2139   {
2140     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 1);
2141     written |= (1ULL << 4);
2142     if (UNLIKELY(current_cpu->trace_result_p))
2143       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2144     current_cpu->h_grc_set (FLD (f_rm), opval);
2145   }
2146 }
2147   {
2148     SI opval = EXTQISI (tmp_data);
2149     if (UNLIKELY(current_cpu->trace_result_p))
2150       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2151     current_cpu->h_grc_set (FLD (f_rn), opval);
2152   }
2153 }
2154
2155   abuf->written = written;
2156   current_cpu->done_insn (npc, status);
2157 #undef FLD
2158 }
2159
2160 // ********** movb8-compact: mov.b @(r0, $rm), $rn
2161
2162 void
2163 sh2a_nofpu_sem_movb8_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2164         sh2a_nofpu::write_stacks &buf)
2165 {
2166 #define FLD(f) abuf->fields.sfmt_movb8_compact.f
2167   sem_status status = SEM_STATUS_NORMAL;
2168   sh2a_nofpu_scache* abuf = sem;
2169   unsigned long long written = 0;
2170   PCADDR pc = abuf->addr;
2171   PCADDR npc = pc + 2;
2172
2173   {
2174     SI opval = EXTQISI (current_cpu->GETMEMQI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rm)))));
2175     if (UNLIKELY(current_cpu->trace_result_p))
2176       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2177     current_cpu->h_grc_set (FLD (f_rn), opval);
2178   }
2179
2180   current_cpu->done_insn (npc, status);
2181 #undef FLD
2182 }
2183
2184 // ********** movb9-compact: mov.b @($imm8, gbr), r0
2185
2186 void
2187 sh2a_nofpu_sem_movb9_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2188         sh2a_nofpu::write_stacks &buf)
2189 {
2190 #define FLD(f) abuf->fields.sfmt_andi_compact.f
2191   sem_status status = SEM_STATUS_NORMAL;
2192   sh2a_nofpu_scache* abuf = sem;
2193   unsigned long long written = 0;
2194   PCADDR pc = abuf->addr;
2195   PCADDR npc = pc + 2;
2196
2197   {
2198     SI opval = EXTQISI (current_cpu->GETMEMQI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8))));
2199     if (UNLIKELY(current_cpu->trace_result_p))
2200       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2201     current_cpu->h_grc_set (((UINT) 0), opval);
2202   }
2203
2204   current_cpu->done_insn (npc, status);
2205 #undef FLD
2206 }
2207
2208 // ********** movb10-compact: mov.b @($imm4, $rm), r0
2209
2210 void
2211 sh2a_nofpu_sem_movb10_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2212         sh2a_nofpu::write_stacks &buf)
2213 {
2214 #define FLD(f) abuf->fields.sfmt_movb10_compact.f
2215   sem_status status = SEM_STATUS_NORMAL;
2216   sh2a_nofpu_scache* abuf = sem;
2217   unsigned long long written = 0;
2218   PCADDR pc = abuf->addr;
2219   PCADDR npc = pc + 2;
2220
2221   {
2222     SI opval = EXTQISI (current_cpu->GETMEMQI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4))));
2223     if (UNLIKELY(current_cpu->trace_result_p))
2224       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2225     current_cpu->h_grc_set (((UINT) 0), opval);
2226   }
2227
2228   current_cpu->done_insn (npc, status);
2229 #undef FLD
2230 }
2231
2232 // ********** movl1-compact: mov.l $rm, @$rn
2233
2234 void
2235 sh2a_nofpu_sem_movl1_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2236         sh2a_nofpu::write_stacks &buf)
2237 {
2238 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
2239   sem_status status = SEM_STATUS_NORMAL;
2240   sh2a_nofpu_scache* abuf = sem;
2241   unsigned long long written = 0;
2242   PCADDR pc = abuf->addr;
2243   PCADDR npc = pc + 2;
2244
2245   {
2246     SI opval = current_cpu->h_grc_get (FLD (f_rm));
2247     if (UNLIKELY(current_cpu->trace_result_p))
2248       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2249     current_cpu->SETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
2250   }
2251
2252   current_cpu->done_insn (npc, status);
2253 #undef FLD
2254 }
2255
2256 // ********** movl2-compact: mov.l $rm, @-$rn
2257
2258 void
2259 sh2a_nofpu_sem_movl2_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2260         sh2a_nofpu::write_stacks &buf)
2261 {
2262 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2263   sem_status status = SEM_STATUS_NORMAL;
2264   sh2a_nofpu_scache* abuf = sem;
2265   unsigned long long written = 0;
2266   PCADDR pc = abuf->addr;
2267   PCADDR npc = pc + 2;
2268
2269 {
2270   SI tmp_addr;
2271   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
2272   {
2273     SI opval = current_cpu->h_grc_get (FLD (f_rm));
2274     if (UNLIKELY(current_cpu->trace_result_p))
2275       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2276     current_cpu->SETMEMSI (pc, tmp_addr, opval);
2277   }
2278   {
2279     SI opval = tmp_addr;
2280     if (UNLIKELY(current_cpu->trace_result_p))
2281       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2282     current_cpu->h_grc_set (FLD (f_rn), opval);
2283   }
2284 }
2285
2286   current_cpu->done_insn (npc, status);
2287 #undef FLD
2288 }
2289
2290 // ********** movl3-compact: mov.l $rm, @(r0, $rn)
2291
2292 void
2293 sh2a_nofpu_sem_movl3_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2294         sh2a_nofpu::write_stacks &buf)
2295 {
2296 #define FLD(f) abuf->fields.sfmt_movb3_compact.f
2297   sem_status status = SEM_STATUS_NORMAL;
2298   sh2a_nofpu_scache* abuf = sem;
2299   unsigned long long written = 0;
2300   PCADDR pc = abuf->addr;
2301   PCADDR npc = pc + 2;
2302
2303   {
2304     SI opval = current_cpu->h_grc_get (FLD (f_rm));
2305     if (UNLIKELY(current_cpu->trace_result_p))
2306       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2307     current_cpu->SETMEMSI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))), opval);
2308   }
2309
2310   current_cpu->done_insn (npc, status);
2311 #undef FLD
2312 }
2313
2314 // ********** movl4-compact: mov.l r0, @($imm8x4, gbr)
2315
2316 void
2317 sh2a_nofpu_sem_movl4_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2318         sh2a_nofpu::write_stacks &buf)
2319 {
2320 #define FLD(f) abuf->fields.sfmt_movl4_compact.f
2321   sem_status status = SEM_STATUS_NORMAL;
2322   sh2a_nofpu_scache* abuf = sem;
2323   unsigned long long written = 0;
2324   PCADDR pc = abuf->addr;
2325   PCADDR npc = pc + 2;
2326
2327   {
2328     SI opval = current_cpu->h_grc_get (((UINT) 0));
2329     if (UNLIKELY(current_cpu->trace_result_p))
2330       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x4)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2331     current_cpu->SETMEMSI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x4)), opval);
2332   }
2333
2334   current_cpu->done_insn (npc, status);
2335 #undef FLD
2336 }
2337
2338 // ********** movl5-compact: mov.l $rm, @($imm4x4, $rn)
2339
2340 void
2341 sh2a_nofpu_sem_movl5_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2342         sh2a_nofpu::write_stacks &buf)
2343 {
2344 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
2345   sem_status status = SEM_STATUS_NORMAL;
2346   sh2a_nofpu_scache* abuf = sem;
2347   unsigned long long written = 0;
2348   PCADDR pc = abuf->addr;
2349   PCADDR npc = pc + 2;
2350
2351   {
2352     SI opval = current_cpu->h_grc_get (FLD (f_rm));
2353     if (UNLIKELY(current_cpu->trace_result_p))
2354       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_grc_get (FLD (f_rn)), FLD (f_imm4x4)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2355     current_cpu->SETMEMSI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rn)), FLD (f_imm4x4)), opval);
2356   }
2357
2358   current_cpu->done_insn (npc, status);
2359 #undef FLD
2360 }
2361
2362 // ********** movl6-compact: mov.l @$rm, $rn
2363
2364 void
2365 sh2a_nofpu_sem_movl6_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2366         sh2a_nofpu::write_stacks &buf)
2367 {
2368 #define FLD(f) abuf->fields.sfmt_movl12_compact.f
2369   sem_status status = SEM_STATUS_NORMAL;
2370   sh2a_nofpu_scache* abuf = sem;
2371   unsigned long long written = 0;
2372   PCADDR pc = abuf->addr;
2373   PCADDR npc = pc + 2;
2374
2375   {
2376     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rm)));
2377     if (UNLIKELY(current_cpu->trace_result_p))
2378       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2379     current_cpu->h_grc_set (FLD (f_rn), opval);
2380   }
2381
2382   current_cpu->done_insn (npc, status);
2383 #undef FLD
2384 }
2385
2386 // ********** movl7-compact: mov.l @${rm}+, $rn
2387
2388 void
2389 sh2a_nofpu_sem_movl7_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2390         sh2a_nofpu::write_stacks &buf)
2391 {
2392 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2393   sem_status status = SEM_STATUS_NORMAL;
2394   sh2a_nofpu_scache* abuf = sem;
2395   unsigned long long written = 0;
2396   PCADDR pc = abuf->addr;
2397   PCADDR npc = pc + 2;
2398
2399 {
2400   {
2401     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rm)));
2402     if (UNLIKELY(current_cpu->trace_result_p))
2403       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2404     current_cpu->h_grc_set (FLD (f_rn), opval);
2405   }
2406 if (EQSI (FLD (f_rm), FLD (f_rn))) {
2407   {
2408     SI opval = current_cpu->h_grc_get (FLD (f_rn));
2409     written |= (1ULL << 5);
2410     if (UNLIKELY(current_cpu->trace_result_p))
2411       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2412     current_cpu->h_grc_set (FLD (f_rm), opval);
2413   }
2414 } else {
2415   {
2416     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 4);
2417     written |= (1ULL << 5);
2418     if (UNLIKELY(current_cpu->trace_result_p))
2419       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2420     current_cpu->h_grc_set (FLD (f_rm), opval);
2421   }
2422 }
2423 }
2424
2425   abuf->written = written;
2426   current_cpu->done_insn (npc, status);
2427 #undef FLD
2428 }
2429
2430 // ********** movl8-compact: mov.l @(r0, $rm), $rn
2431
2432 void
2433 sh2a_nofpu_sem_movl8_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2434         sh2a_nofpu::write_stacks &buf)
2435 {
2436 #define FLD(f) abuf->fields.sfmt_movb8_compact.f
2437   sem_status status = SEM_STATUS_NORMAL;
2438   sh2a_nofpu_scache* abuf = sem;
2439   unsigned long long written = 0;
2440   PCADDR pc = abuf->addr;
2441   PCADDR npc = pc + 2;
2442
2443   {
2444     SI opval = current_cpu->GETMEMSI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rm))));
2445     if (UNLIKELY(current_cpu->trace_result_p))
2446       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2447     current_cpu->h_grc_set (FLD (f_rn), opval);
2448   }
2449
2450   current_cpu->done_insn (npc, status);
2451 #undef FLD
2452 }
2453
2454 // ********** movl9-compact: mov.l @($imm8x4, gbr), r0
2455
2456 void
2457 sh2a_nofpu_sem_movl9_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2458         sh2a_nofpu::write_stacks &buf)
2459 {
2460 #define FLD(f) abuf->fields.sfmt_movl9_compact.f
2461   sem_status status = SEM_STATUS_NORMAL;
2462   sh2a_nofpu_scache* abuf = sem;
2463   unsigned long long written = 0;
2464   PCADDR pc = abuf->addr;
2465   PCADDR npc = pc + 2;
2466
2467   {
2468     SI opval = current_cpu->GETMEMSI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x4)));
2469     if (UNLIKELY(current_cpu->trace_result_p))
2470       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2471     current_cpu->h_grc_set (((UINT) 0), opval);
2472   }
2473
2474   current_cpu->done_insn (npc, status);
2475 #undef FLD
2476 }
2477
2478 // ********** movl10-compact: mov.l @($imm8x4, pc), $rn
2479
2480 void
2481 sh2a_nofpu_sem_movl10_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2482         sh2a_nofpu::write_stacks &buf)
2483 {
2484 #define FLD(f) abuf->fields.sfmt_movl10_compact.f
2485   sem_status status = SEM_STATUS_NORMAL;
2486   sh2a_nofpu_scache* abuf = sem;
2487   unsigned long long written = 0;
2488   PCADDR pc = abuf->addr;
2489   PCADDR npc = pc + 2;
2490
2491   {
2492     SI opval = current_cpu->GETMEMSI (pc, ADDSI (FLD (f_imm8x4), ANDDI (ADDDI (pc, 4), INVSI (3))));
2493     if (UNLIKELY(current_cpu->trace_result_p))
2494       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2495     current_cpu->h_grc_set (FLD (f_rn), opval);
2496   }
2497
2498   current_cpu->done_insn (npc, status);
2499 #undef FLD
2500 }
2501
2502 // ********** movl11-compact: mov.l @($imm4x4, $rm), $rn
2503
2504 void
2505 sh2a_nofpu_sem_movl11_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2506         sh2a_nofpu::write_stacks &buf)
2507 {
2508 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
2509   sem_status status = SEM_STATUS_NORMAL;
2510   sh2a_nofpu_scache* abuf = sem;
2511   unsigned long long written = 0;
2512   PCADDR pc = abuf->addr;
2513   PCADDR npc = pc + 2;
2514
2515   {
2516     SI opval = current_cpu->GETMEMSI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4x4)));
2517     if (UNLIKELY(current_cpu->trace_result_p))
2518       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2519     current_cpu->h_grc_set (FLD (f_rn), opval);
2520   }
2521
2522   current_cpu->done_insn (npc, status);
2523 #undef FLD
2524 }
2525
2526 // ********** movl12-compact: mov.l @($imm12x4, $rm), $rn
2527
2528 void
2529 sh2a_nofpu_sem_movl12_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2530         sh2a_nofpu::write_stacks &buf)
2531 {
2532 #define FLD(f) abuf->fields.sfmt_movl12_compact.f
2533   sem_status status = SEM_STATUS_NORMAL;
2534   sh2a_nofpu_scache* abuf = sem;
2535   unsigned long long written = 0;
2536   PCADDR pc = abuf->addr;
2537   PCADDR npc = pc + 4;
2538
2539   {
2540     SI opval = current_cpu->GETMEMSI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm12x4)));
2541     if (UNLIKELY(current_cpu->trace_result_p))
2542       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2543     current_cpu->h_grc_set (FLD (f_rn), opval);
2544   }
2545
2546   current_cpu->done_insn (npc, status);
2547 #undef FLD
2548 }
2549
2550 // ********** movl13-compact: mov.l $rm, @($imm12x4, $rn)
2551
2552 void
2553 sh2a_nofpu_sem_movl13_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2554         sh2a_nofpu::write_stacks &buf)
2555 {
2556 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
2557   sem_status status = SEM_STATUS_NORMAL;
2558   sh2a_nofpu_scache* abuf = sem;
2559   unsigned long long written = 0;
2560   PCADDR pc = abuf->addr;
2561   PCADDR npc = pc + 4;
2562
2563   {
2564     SI opval = current_cpu->h_grc_get (FLD (f_rm));
2565     if (UNLIKELY(current_cpu->trace_result_p))
2566       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_grc_get (FLD (f_rn)), FLD (f_imm12x4)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2567     current_cpu->SETMEMSI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rn)), FLD (f_imm12x4)), opval);
2568   }
2569
2570   current_cpu->done_insn (npc, status);
2571 #undef FLD
2572 }
2573
2574 // ********** movw1-compact: mov.w $rm, @$rn
2575
2576 void
2577 sh2a_nofpu_sem_movw1_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2578         sh2a_nofpu::write_stacks &buf)
2579 {
2580 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
2581   sem_status status = SEM_STATUS_NORMAL;
2582   sh2a_nofpu_scache* abuf = sem;
2583   unsigned long long written = 0;
2584   PCADDR pc = abuf->addr;
2585   PCADDR npc = pc + 2;
2586
2587   {
2588     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1);
2589     if (UNLIKELY(current_cpu->trace_result_p))
2590       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2591     current_cpu->SETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
2592   }
2593
2594   current_cpu->done_insn (npc, status);
2595 #undef FLD
2596 }
2597
2598 // ********** movw2-compact: mov.w $rm, @-$rn
2599
2600 void
2601 sh2a_nofpu_sem_movw2_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2602         sh2a_nofpu::write_stacks &buf)
2603 {
2604 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2605   sem_status status = SEM_STATUS_NORMAL;
2606   sh2a_nofpu_scache* abuf = sem;
2607   unsigned long long written = 0;
2608   PCADDR pc = abuf->addr;
2609   PCADDR npc = pc + 2;
2610
2611 {
2612   DI tmp_addr;
2613   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
2614   {
2615     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1);
2616     if (UNLIKELY(current_cpu->trace_result_p))
2617       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2618     current_cpu->SETMEMHI (pc, tmp_addr, opval);
2619   }
2620   {
2621     SI opval = tmp_addr;
2622     if (UNLIKELY(current_cpu->trace_result_p))
2623       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2624     current_cpu->h_grc_set (FLD (f_rn), opval);
2625   }
2626 }
2627
2628   current_cpu->done_insn (npc, status);
2629 #undef FLD
2630 }
2631
2632 // ********** movw3-compact: mov.w $rm, @(r0, $rn)
2633
2634 void
2635 sh2a_nofpu_sem_movw3_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2636         sh2a_nofpu::write_stacks &buf)
2637 {
2638 #define FLD(f) abuf->fields.sfmt_movb3_compact.f
2639   sem_status status = SEM_STATUS_NORMAL;
2640   sh2a_nofpu_scache* abuf = sem;
2641   unsigned long long written = 0;
2642   PCADDR pc = abuf->addr;
2643   PCADDR npc = pc + 2;
2644
2645   {
2646     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1);
2647     if (UNLIKELY(current_cpu->trace_result_p))
2648       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2649     current_cpu->SETMEMHI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))), opval);
2650   }
2651
2652   current_cpu->done_insn (npc, status);
2653 #undef FLD
2654 }
2655
2656 // ********** movw4-compact: mov.w r0, @($imm8x2, gbr)
2657
2658 void
2659 sh2a_nofpu_sem_movw4_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2660         sh2a_nofpu::write_stacks &buf)
2661 {
2662 #define FLD(f) abuf->fields.sfmt_movw4_compact.f
2663   sem_status status = SEM_STATUS_NORMAL;
2664   sh2a_nofpu_scache* abuf = sem;
2665   unsigned long long written = 0;
2666   PCADDR pc = abuf->addr;
2667   PCADDR npc = pc + 2;
2668
2669   {
2670     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (((UINT) 0)), 1);
2671     if (UNLIKELY(current_cpu->trace_result_p))
2672       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x2)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2673     current_cpu->SETMEMHI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x2)), opval);
2674   }
2675
2676   current_cpu->done_insn (npc, status);
2677 #undef FLD
2678 }
2679
2680 // ********** movw5-compact: mov.w r0, @($imm4x2, $rm)
2681
2682 void
2683 sh2a_nofpu_sem_movw5_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2684         sh2a_nofpu::write_stacks &buf)
2685 {
2686 #define FLD(f) abuf->fields.sfmt_movw5_compact.f
2687   sem_status status = SEM_STATUS_NORMAL;
2688   sh2a_nofpu_scache* abuf = sem;
2689   unsigned long long written = 0;
2690   PCADDR pc = abuf->addr;
2691   PCADDR npc = pc + 2;
2692
2693   {
2694     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (((UINT) 0)), 1);
2695     if (UNLIKELY(current_cpu->trace_result_p))
2696       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4x2)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2697     current_cpu->SETMEMHI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4x2)), opval);
2698   }
2699
2700   current_cpu->done_insn (npc, status);
2701 #undef FLD
2702 }
2703
2704 // ********** movw6-compact: mov.w @$rm, $rn
2705
2706 void
2707 sh2a_nofpu_sem_movw6_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2708         sh2a_nofpu::write_stacks &buf)
2709 {
2710 #define FLD(f) abuf->fields.sfmt_movl12_compact.f
2711   sem_status status = SEM_STATUS_NORMAL;
2712   sh2a_nofpu_scache* abuf = sem;
2713   unsigned long long written = 0;
2714   PCADDR pc = abuf->addr;
2715   PCADDR npc = pc + 2;
2716
2717   {
2718     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rm))));
2719     if (UNLIKELY(current_cpu->trace_result_p))
2720       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2721     current_cpu->h_grc_set (FLD (f_rn), opval);
2722   }
2723
2724   current_cpu->done_insn (npc, status);
2725 #undef FLD
2726 }
2727
2728 // ********** movw7-compact: mov.w @${rm}+, $rn
2729
2730 void
2731 sh2a_nofpu_sem_movw7_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2732         sh2a_nofpu::write_stacks &buf)
2733 {
2734 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2735   sem_status status = SEM_STATUS_NORMAL;
2736   sh2a_nofpu_scache* abuf = sem;
2737   unsigned long long written = 0;
2738   PCADDR pc = abuf->addr;
2739   PCADDR npc = pc + 2;
2740
2741 {
2742   HI tmp_data;
2743   tmp_data = current_cpu->GETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rm)));
2744 if (EQSI (FLD (f_rm), FLD (f_rn))) {
2745   {
2746     SI opval = EXTHISI (tmp_data);
2747     written |= (1ULL << 4);
2748     if (UNLIKELY(current_cpu->trace_result_p))
2749       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2750     current_cpu->h_grc_set (FLD (f_rm), opval);
2751   }
2752 } else {
2753   {
2754     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 2);
2755     written |= (1ULL << 4);
2756     if (UNLIKELY(current_cpu->trace_result_p))
2757       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2758     current_cpu->h_grc_set (FLD (f_rm), opval);
2759   }
2760 }
2761   {
2762     SI opval = EXTHISI (tmp_data);
2763     if (UNLIKELY(current_cpu->trace_result_p))
2764       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2765     current_cpu->h_grc_set (FLD (f_rn), opval);
2766   }
2767 }
2768
2769   abuf->written = written;
2770   current_cpu->done_insn (npc, status);
2771 #undef FLD
2772 }
2773
2774 // ********** movw8-compact: mov.w @(r0, $rm), $rn
2775
2776 void
2777 sh2a_nofpu_sem_movw8_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2778         sh2a_nofpu::write_stacks &buf)
2779 {
2780 #define FLD(f) abuf->fields.sfmt_movb8_compact.f
2781   sem_status status = SEM_STATUS_NORMAL;
2782   sh2a_nofpu_scache* abuf = sem;
2783   unsigned long long written = 0;
2784   PCADDR pc = abuf->addr;
2785   PCADDR npc = pc + 2;
2786
2787   {
2788     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rm)))));
2789     if (UNLIKELY(current_cpu->trace_result_p))
2790       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2791     current_cpu->h_grc_set (FLD (f_rn), opval);
2792   }
2793
2794   current_cpu->done_insn (npc, status);
2795 #undef FLD
2796 }
2797
2798 // ********** movw9-compact: mov.w @($imm8x2, gbr), r0
2799
2800 void
2801 sh2a_nofpu_sem_movw9_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2802         sh2a_nofpu::write_stacks &buf)
2803 {
2804 #define FLD(f) abuf->fields.sfmt_movw9_compact.f
2805   sem_status status = SEM_STATUS_NORMAL;
2806   sh2a_nofpu_scache* abuf = sem;
2807   unsigned long long written = 0;
2808   PCADDR pc = abuf->addr;
2809   PCADDR npc = pc + 2;
2810
2811   {
2812     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x2))));
2813     if (UNLIKELY(current_cpu->trace_result_p))
2814       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2815     current_cpu->h_grc_set (((UINT) 0), opval);
2816   }
2817
2818   current_cpu->done_insn (npc, status);
2819 #undef FLD
2820 }
2821
2822 // ********** movw10-compact: mov.w @($imm8x2, pc), $rn
2823
2824 void
2825 sh2a_nofpu_sem_movw10_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2826         sh2a_nofpu::write_stacks &buf)
2827 {
2828 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
2829   sem_status status = SEM_STATUS_NORMAL;
2830   sh2a_nofpu_scache* abuf = sem;
2831   unsigned long long written = 0;
2832   PCADDR pc = abuf->addr;
2833   PCADDR npc = pc + 2;
2834
2835   {
2836     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, ADDDI (ADDDI (pc, 4), FLD (f_imm8x2))));
2837     if (UNLIKELY(current_cpu->trace_result_p))
2838       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2839     current_cpu->h_grc_set (FLD (f_rn), opval);
2840   }
2841
2842   current_cpu->done_insn (npc, status);
2843 #undef FLD
2844 }
2845
2846 // ********** movw11-compact: mov.w @($imm4x2, $rm), r0
2847
2848 void
2849 sh2a_nofpu_sem_movw11_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2850         sh2a_nofpu::write_stacks &buf)
2851 {
2852 #define FLD(f) abuf->fields.sfmt_movw11_compact.f
2853   sem_status status = SEM_STATUS_NORMAL;
2854   sh2a_nofpu_scache* abuf = sem;
2855   unsigned long long written = 0;
2856   PCADDR pc = abuf->addr;
2857   PCADDR npc = pc + 2;
2858
2859   {
2860     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4x2))));
2861     if (UNLIKELY(current_cpu->trace_result_p))
2862       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2863     current_cpu->h_grc_set (((UINT) 0), opval);
2864   }
2865
2866   current_cpu->done_insn (npc, status);
2867 #undef FLD
2868 }
2869
2870 // ********** mova-compact: mova @($imm8x4, pc), r0
2871
2872 void
2873 sh2a_nofpu_sem_mova_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2874         sh2a_nofpu::write_stacks &buf)
2875 {
2876 #define FLD(f) abuf->fields.sfmt_movl9_compact.f
2877   sem_status status = SEM_STATUS_NORMAL;
2878   sh2a_nofpu_scache* abuf = sem;
2879   unsigned long long written = 0;
2880   PCADDR pc = abuf->addr;
2881   PCADDR npc = pc + 2;
2882
2883   {
2884     SI opval = ADDDI (ANDDI (ADDDI (pc, 4), INVSI (3)), FLD (f_imm8x4));
2885     if (UNLIKELY(current_cpu->trace_result_p))
2886       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2887     current_cpu->h_grc_set (((UINT) 0), opval);
2888   }
2889
2890   current_cpu->done_insn (npc, status);
2891 #undef FLD
2892 }
2893
2894 // ********** movt-compact: movt $rn
2895
2896 void
2897 sh2a_nofpu_sem_movt_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2898         sh2a_nofpu::write_stacks &buf)
2899 {
2900 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
2901   sem_status status = SEM_STATUS_NORMAL;
2902   sh2a_nofpu_scache* abuf = sem;
2903   unsigned long long written = 0;
2904   PCADDR pc = abuf->addr;
2905   PCADDR npc = pc + 2;
2906
2907   {
2908     SI opval = ZEXTBISI (current_cpu->h_tbit_get ());
2909     if (UNLIKELY(current_cpu->trace_result_p))
2910       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2911     current_cpu->h_grc_set (FLD (f_rn), opval);
2912   }
2913
2914   current_cpu->done_insn (npc, status);
2915 #undef FLD
2916 }
2917
2918 // ********** mull-compact: mul.l $rm, $rn
2919
2920 void
2921 sh2a_nofpu_sem_mull_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2922         sh2a_nofpu::write_stacks &buf)
2923 {
2924 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
2925   sem_status status = SEM_STATUS_NORMAL;
2926   sh2a_nofpu_scache* abuf = sem;
2927   unsigned long long written = 0;
2928   PCADDR pc = abuf->addr;
2929   PCADDR npc = pc + 2;
2930
2931   {
2932     SI opval = MULSI (current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_grc_get (FLD (f_rn)));
2933     if (UNLIKELY(current_cpu->trace_result_p))
2934       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
2935     current_cpu->h_macl_set (opval);
2936   }
2937
2938   current_cpu->done_insn (npc, status);
2939 #undef FLD
2940 }
2941
2942 // ********** mulsw-compact: muls.w $rm, $rn
2943
2944 void
2945 sh2a_nofpu_sem_mulsw_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2946         sh2a_nofpu::write_stacks &buf)
2947 {
2948 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
2949   sem_status status = SEM_STATUS_NORMAL;
2950   sh2a_nofpu_scache* abuf = sem;
2951   unsigned long long written = 0;
2952   PCADDR pc = abuf->addr;
2953   PCADDR npc = pc + 2;
2954
2955   {
2956     SI opval = MULSI (EXTHISI (SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1)), EXTHISI (SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rn)), 1)));
2957     if (UNLIKELY(current_cpu->trace_result_p))
2958       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
2959     current_cpu->h_macl_set (opval);
2960   }
2961
2962   current_cpu->done_insn (npc, status);
2963 #undef FLD
2964 }
2965
2966 // ********** muluw-compact: mulu.w $rm, $rn
2967
2968 void
2969 sh2a_nofpu_sem_muluw_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2970         sh2a_nofpu::write_stacks &buf)
2971 {
2972 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
2973   sem_status status = SEM_STATUS_NORMAL;
2974   sh2a_nofpu_scache* abuf = sem;
2975   unsigned long long written = 0;
2976   PCADDR pc = abuf->addr;
2977   PCADDR npc = pc + 2;
2978
2979   {
2980     SI opval = MULSI (ZEXTHISI (SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1)), ZEXTHISI (SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rn)), 1)));
2981     if (UNLIKELY(current_cpu->trace_result_p))
2982       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
2983     current_cpu->h_macl_set (opval);
2984   }
2985
2986   current_cpu->done_insn (npc, status);
2987 #undef FLD
2988 }
2989
2990 // ********** neg-compact: neg $rm, $rn
2991
2992 void
2993 sh2a_nofpu_sem_neg_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
2994         sh2a_nofpu::write_stacks &buf)
2995 {
2996 #define FLD(f) abuf->fields.sfmt_movl12_compact.f
2997   sem_status status = SEM_STATUS_NORMAL;
2998   sh2a_nofpu_scache* abuf = sem;
2999   unsigned long long written = 0;
3000   PCADDR pc = abuf->addr;
3001   PCADDR npc = pc + 2;
3002
3003   {
3004     SI opval = NEGSI (current_cpu->h_grc_get (FLD (f_rm)));
3005     if (UNLIKELY(current_cpu->trace_result_p))
3006       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3007     current_cpu->h_grc_set (FLD (f_rn), opval);
3008   }
3009
3010   current_cpu->done_insn (npc, status);
3011 #undef FLD
3012 }
3013
3014 // ********** negc-compact: negc $rm, $rn
3015
3016 void
3017 sh2a_nofpu_sem_negc_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3018         sh2a_nofpu::write_stacks &buf)
3019 {
3020 #define FLD(f) abuf->fields.sfmt_movl12_compact.f
3021   sem_status status = SEM_STATUS_NORMAL;
3022   sh2a_nofpu_scache* abuf = sem;
3023   unsigned long long written = 0;
3024   PCADDR pc = abuf->addr;
3025   PCADDR npc = pc + 2;
3026
3027 {
3028   BI tmp_flag;
3029   tmp_flag = SUBCFSI (0, current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
3030   {
3031     SI opval = SUBCSI (0, current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
3032     if (UNLIKELY(current_cpu->trace_result_p))
3033       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3034     current_cpu->h_grc_set (FLD (f_rn), opval);
3035   }
3036   {
3037     BI opval = tmp_flag;
3038     if (UNLIKELY(current_cpu->trace_result_p))
3039       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3040     current_cpu->h_tbit_set (opval);
3041   }
3042 }
3043
3044   current_cpu->done_insn (npc, status);
3045 #undef FLD
3046 }
3047
3048 // ********** nop-compact: nop
3049
3050 void
3051 sh2a_nofpu_sem_nop_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3052         sh2a_nofpu::write_stacks &buf)
3053 {
3054 #define FLD(f) abuf->fields.fmt_empty.f
3055   sem_status status = SEM_STATUS_NORMAL;
3056   sh2a_nofpu_scache* abuf = sem;
3057   unsigned long long written = 0;
3058   PCADDR pc = abuf->addr;
3059   PCADDR npc = pc + 2;
3060
3061 ((void) 0); /*nop*/
3062
3063   current_cpu->done_insn (npc, status);
3064 #undef FLD
3065 }
3066
3067 // ********** not-compact: not $rm64, $rn64
3068
3069 void
3070 sh2a_nofpu_sem_not_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3071         sh2a_nofpu::write_stacks &buf)
3072 {
3073 #define FLD(f) abuf->fields.sfmt_and_compact.f
3074   sem_status status = SEM_STATUS_NORMAL;
3075   sh2a_nofpu_scache* abuf = sem;
3076   unsigned long long written = 0;
3077   PCADDR pc = abuf->addr;
3078   PCADDR npc = pc + 2;
3079
3080   {
3081     DI opval = INVDI (current_cpu->h_gr_get (FLD (f_rm)));
3082     if (UNLIKELY(current_cpu->trace_result_p))
3083       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3084     current_cpu->h_gr_set (FLD (f_rn), opval);
3085   }
3086
3087   current_cpu->done_insn (npc, status);
3088 #undef FLD
3089 }
3090
3091 // ********** or-compact: or $rm64, $rn64
3092
3093 void
3094 sh2a_nofpu_sem_or_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3095         sh2a_nofpu::write_stacks &buf)
3096 {
3097 #define FLD(f) abuf->fields.sfmt_and_compact.f
3098   sem_status status = SEM_STATUS_NORMAL;
3099   sh2a_nofpu_scache* abuf = sem;
3100   unsigned long long written = 0;
3101   PCADDR pc = abuf->addr;
3102   PCADDR npc = pc + 2;
3103
3104   {
3105     DI opval = ORDI (current_cpu->h_gr_get (FLD (f_rm)), current_cpu->h_gr_get (FLD (f_rn)));
3106     if (UNLIKELY(current_cpu->trace_result_p))
3107       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3108     current_cpu->h_gr_set (FLD (f_rn), opval);
3109   }
3110
3111   current_cpu->done_insn (npc, status);
3112 #undef FLD
3113 }
3114
3115 // ********** ori-compact: or #$uimm8, r0
3116
3117 void
3118 sh2a_nofpu_sem_ori_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3119         sh2a_nofpu::write_stacks &buf)
3120 {
3121 #define FLD(f) abuf->fields.sfmt_andi_compact.f
3122   sem_status status = SEM_STATUS_NORMAL;
3123   sh2a_nofpu_scache* abuf = sem;
3124   unsigned long long written = 0;
3125   PCADDR pc = abuf->addr;
3126   PCADDR npc = pc + 2;
3127
3128   {
3129     SI opval = ORSI (current_cpu->h_grc_get (((UINT) 0)), ZEXTSIDI (FLD (f_imm8)));
3130     if (UNLIKELY(current_cpu->trace_result_p))
3131       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
3132     current_cpu->h_grc_set (((UINT) 0), opval);
3133   }
3134
3135   current_cpu->done_insn (npc, status);
3136 #undef FLD
3137 }
3138
3139 // ********** orb-compact: or.b #$imm8, @(r0, gbr)
3140
3141 void
3142 sh2a_nofpu_sem_orb_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3143         sh2a_nofpu::write_stacks &buf)
3144 {
3145 #define FLD(f) abuf->fields.sfmt_andi_compact.f
3146   sem_status status = SEM_STATUS_NORMAL;
3147   sh2a_nofpu_scache* abuf = sem;
3148   unsigned long long written = 0;
3149   PCADDR pc = abuf->addr;
3150   PCADDR npc = pc + 2;
3151
3152 {
3153   DI tmp_addr;
3154   UQI tmp_data;
3155   tmp_addr = ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_gbr_get ());
3156   tmp_data = ORQI (current_cpu->GETMEMUQI (pc, tmp_addr), FLD (f_imm8));
3157   {
3158     UQI opval = tmp_data;
3159     if (UNLIKELY(current_cpu->trace_result_p))
3160       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
3161     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
3162   }
3163 }
3164
3165   current_cpu->done_insn (npc, status);
3166 #undef FLD
3167 }
3168
3169 // ********** rotcl-compact: rotcl $rn
3170
3171 void
3172 sh2a_nofpu_sem_rotcl_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3173         sh2a_nofpu::write_stacks &buf)
3174 {
3175 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3176   sem_status status = SEM_STATUS_NORMAL;
3177   sh2a_nofpu_scache* abuf = sem;
3178   unsigned long long written = 0;
3179   PCADDR pc = abuf->addr;
3180   PCADDR npc = pc + 2;
3181
3182 {
3183   BI tmp_temp;
3184   tmp_temp = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
3185   {
3186     SI opval = ORSI (SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), current_cpu->h_tbit_get ());
3187     if (UNLIKELY(current_cpu->trace_result_p))
3188       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3189     current_cpu->h_grc_set (FLD (f_rn), opval);
3190   }
3191   {
3192     BI opval = ((tmp_temp) ? (1) : (0));
3193     if (UNLIKELY(current_cpu->trace_result_p))
3194       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3195     current_cpu->h_tbit_set (opval);
3196   }
3197 }
3198
3199   current_cpu->done_insn (npc, status);
3200 #undef FLD
3201 }
3202
3203 // ********** rotcr-compact: rotcr $rn
3204
3205 void
3206 sh2a_nofpu_sem_rotcr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3207         sh2a_nofpu::write_stacks &buf)
3208 {
3209 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3210   sem_status status = SEM_STATUS_NORMAL;
3211   sh2a_nofpu_scache* abuf = sem;
3212   unsigned long long written = 0;
3213   PCADDR pc = abuf->addr;
3214   PCADDR npc = pc + 2;
3215
3216 {
3217   BI tmp_lsbit;
3218   SI tmp_temp;
3219   tmp_lsbit = ((EQSI (ANDSI (current_cpu->h_grc_get (FLD (f_rn)), 1), 0)) ? (0) : (1));
3220   tmp_temp = current_cpu->h_tbit_get ();
3221   {
3222     SI opval = ORSI (SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), SLLSI (tmp_temp, 31));
3223     if (UNLIKELY(current_cpu->trace_result_p))
3224       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3225     current_cpu->h_grc_set (FLD (f_rn), opval);
3226   }
3227   {
3228     BI opval = ((tmp_lsbit) ? (1) : (0));
3229     if (UNLIKELY(current_cpu->trace_result_p))
3230       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3231     current_cpu->h_tbit_set (opval);
3232   }
3233 }
3234
3235   current_cpu->done_insn (npc, status);
3236 #undef FLD
3237 }
3238
3239 // ********** rotl-compact: rotl $rn
3240
3241 void
3242 sh2a_nofpu_sem_rotl_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3243         sh2a_nofpu::write_stacks &buf)
3244 {
3245 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3246   sem_status status = SEM_STATUS_NORMAL;
3247   sh2a_nofpu_scache* abuf = sem;
3248   unsigned long long written = 0;
3249   PCADDR pc = abuf->addr;
3250   PCADDR npc = pc + 2;
3251
3252 {
3253   BI tmp_temp;
3254   tmp_temp = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
3255   {
3256     SI opval = ORSI (SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), tmp_temp);
3257     if (UNLIKELY(current_cpu->trace_result_p))
3258       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3259     current_cpu->h_grc_set (FLD (f_rn), opval);
3260   }
3261   {
3262     BI opval = ((tmp_temp) ? (1) : (0));
3263     if (UNLIKELY(current_cpu->trace_result_p))
3264       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3265     current_cpu->h_tbit_set (opval);
3266   }
3267 }
3268
3269   current_cpu->done_insn (npc, status);
3270 #undef FLD
3271 }
3272
3273 // ********** rotr-compact: rotr $rn
3274
3275 void
3276 sh2a_nofpu_sem_rotr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3277         sh2a_nofpu::write_stacks &buf)
3278 {
3279 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3280   sem_status status = SEM_STATUS_NORMAL;
3281   sh2a_nofpu_scache* abuf = sem;
3282   unsigned long long written = 0;
3283   PCADDR pc = abuf->addr;
3284   PCADDR npc = pc + 2;
3285
3286 {
3287   BI tmp_lsbit;
3288   SI tmp_temp;
3289   tmp_lsbit = ((EQSI (ANDSI (current_cpu->h_grc_get (FLD (f_rn)), 1), 0)) ? (0) : (1));
3290   tmp_temp = tmp_lsbit;
3291   {
3292     SI opval = ORSI (SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), SLLSI (tmp_temp, 31));
3293     if (UNLIKELY(current_cpu->trace_result_p))
3294       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3295     current_cpu->h_grc_set (FLD (f_rn), opval);
3296   }
3297   {
3298     BI opval = ((tmp_lsbit) ? (1) : (0));
3299     if (UNLIKELY(current_cpu->trace_result_p))
3300       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3301     current_cpu->h_tbit_set (opval);
3302   }
3303 }
3304
3305   current_cpu->done_insn (npc, status);
3306 #undef FLD
3307 }
3308
3309 // ********** rts-compact: rts
3310
3311 void
3312 sh2a_nofpu_sem_rts_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3313         sh2a_nofpu::write_stacks &buf)
3314 {
3315 #define FLD(f) abuf->fields.fmt_empty.f
3316   sem_status status = SEM_STATUS_NORMAL;
3317   sh2a_nofpu_scache* abuf = sem;
3318   unsigned long long written = 0;
3319   PCADDR pc = abuf->addr;
3320   PCADDR npc = pc + 2;
3321
3322 {
3323   {
3324     UDI opval = ADDDI (pc, 2);
3325     if (UNLIKELY(current_cpu->trace_result_p))
3326       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
3327     current_cpu->branch (opval, npc, status);
3328   }
3329 current_cpu->save_delayed_pc (current_cpu->h_pr_get ());
3330   {
3331     UDI opval = current_cpu->h_pr_get ();
3332     buf.h_pc_writes [(tick + 1) % sh2a_nofpu::pipe_sz].push (sh2a_nofpu::write<UDI>(pc, opval));
3333     if (UNLIKELY(current_cpu->trace_result_p))
3334       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
3335   }
3336 current_cpu->notify_ret (current_cpu->h_pr_get ());
3337 }
3338
3339   current_cpu->done_cti_insn (npc, status);
3340 #undef FLD
3341 }
3342
3343 // ********** sett-compact: sett
3344
3345 void
3346 sh2a_nofpu_sem_sett_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3347         sh2a_nofpu::write_stacks &buf)
3348 {
3349 #define FLD(f) abuf->fields.fmt_empty.f
3350   sem_status status = SEM_STATUS_NORMAL;
3351   sh2a_nofpu_scache* abuf = sem;
3352   unsigned long long written = 0;
3353   PCADDR pc = abuf->addr;
3354   PCADDR npc = pc + 2;
3355
3356   {
3357     BI opval = 1;
3358     if (UNLIKELY(current_cpu->trace_result_p))
3359       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3360     current_cpu->h_tbit_set (opval);
3361   }
3362
3363   current_cpu->done_insn (npc, status);
3364 #undef FLD
3365 }
3366
3367 // ********** shad-compact: shad $rm, $rn
3368
3369 void
3370 sh2a_nofpu_sem_shad_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3371         sh2a_nofpu::write_stacks &buf)
3372 {
3373 #define FLD(f) abuf->fields.sfmt_macl_compact.f
3374   sem_status status = SEM_STATUS_NORMAL;
3375   sh2a_nofpu_scache* abuf = sem;
3376   unsigned long long written = 0;
3377   PCADDR pc = abuf->addr;
3378   PCADDR npc = pc + 2;
3379
3380 {
3381   SI tmp_shamt;
3382   tmp_shamt = ANDSI (current_cpu->h_grc_get (FLD (f_rm)), 31);
3383 if (GESI (current_cpu->h_grc_get (FLD (f_rm)), 0)) {
3384   {
3385     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), tmp_shamt);
3386     written |= (1ULL << 2);
3387     if (UNLIKELY(current_cpu->trace_result_p))
3388       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3389     current_cpu->h_grc_set (FLD (f_rn), opval);
3390   }
3391 } else {
3392 if (NESI (tmp_shamt, 0)) {
3393   {
3394     SI opval = SRASI (current_cpu->h_grc_get (FLD (f_rn)), SUBSI (32, tmp_shamt));
3395     written |= (1ULL << 2);
3396     if (UNLIKELY(current_cpu->trace_result_p))
3397       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3398     current_cpu->h_grc_set (FLD (f_rn), opval);
3399   }
3400 } else {
3401 if (LTSI (current_cpu->h_grc_get (FLD (f_rn)), 0)) {
3402   {
3403     SI opval = NEGSI (1);
3404     written |= (1ULL << 2);
3405     if (UNLIKELY(current_cpu->trace_result_p))
3406       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3407     current_cpu->h_grc_set (FLD (f_rn), opval);
3408   }
3409 } else {
3410   {
3411     SI opval = 0;
3412     written |= (1ULL << 2);
3413     if (UNLIKELY(current_cpu->trace_result_p))
3414       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3415     current_cpu->h_grc_set (FLD (f_rn), opval);
3416   }
3417 }
3418 }
3419 }
3420 }
3421
3422   abuf->written = written;
3423   current_cpu->done_insn (npc, status);
3424 #undef FLD
3425 }
3426
3427 // ********** shal-compact: shal $rn
3428
3429 void
3430 sh2a_nofpu_sem_shal_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3431         sh2a_nofpu::write_stacks &buf)
3432 {
3433 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3434   sem_status status = SEM_STATUS_NORMAL;
3435   sh2a_nofpu_scache* abuf = sem;
3436   unsigned long long written = 0;
3437   PCADDR pc = abuf->addr;
3438   PCADDR npc = pc + 2;
3439
3440 {
3441   BI tmp_t;
3442   tmp_t = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
3443   {
3444     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
3445     if (UNLIKELY(current_cpu->trace_result_p))
3446       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3447     current_cpu->h_grc_set (FLD (f_rn), opval);
3448   }
3449   {
3450     BI opval = ((tmp_t) ? (1) : (0));
3451     if (UNLIKELY(current_cpu->trace_result_p))
3452       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3453     current_cpu->h_tbit_set (opval);
3454   }
3455 }
3456
3457   current_cpu->done_insn (npc, status);
3458 #undef FLD
3459 }
3460
3461 // ********** shar-compact: shar $rn
3462
3463 void
3464 sh2a_nofpu_sem_shar_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3465         sh2a_nofpu::write_stacks &buf)
3466 {
3467 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3468   sem_status status = SEM_STATUS_NORMAL;
3469   sh2a_nofpu_scache* abuf = sem;
3470   unsigned long long written = 0;
3471   PCADDR pc = abuf->addr;
3472   PCADDR npc = pc + 2;
3473
3474 {
3475   BI tmp_t;
3476   tmp_t = ANDSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
3477   {
3478     SI opval = SRASI (current_cpu->h_grc_get (FLD (f_rn)), 1);
3479     if (UNLIKELY(current_cpu->trace_result_p))
3480       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3481     current_cpu->h_grc_set (FLD (f_rn), opval);
3482   }
3483   {
3484     BI opval = ((tmp_t) ? (1) : (0));
3485     if (UNLIKELY(current_cpu->trace_result_p))
3486       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3487     current_cpu->h_tbit_set (opval);
3488   }
3489 }
3490
3491   current_cpu->done_insn (npc, status);
3492 #undef FLD
3493 }
3494
3495 // ********** shll-compact: shll $rn
3496
3497 void
3498 sh2a_nofpu_sem_shll_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3499         sh2a_nofpu::write_stacks &buf)
3500 {
3501 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3502   sem_status status = SEM_STATUS_NORMAL;
3503   sh2a_nofpu_scache* abuf = sem;
3504   unsigned long long written = 0;
3505   PCADDR pc = abuf->addr;
3506   PCADDR npc = pc + 2;
3507
3508 {
3509   BI tmp_t;
3510   tmp_t = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
3511   {
3512     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
3513     if (UNLIKELY(current_cpu->trace_result_p))
3514       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3515     current_cpu->h_grc_set (FLD (f_rn), opval);
3516   }
3517   {
3518     BI opval = ((tmp_t) ? (1) : (0));
3519     if (UNLIKELY(current_cpu->trace_result_p))
3520       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3521     current_cpu->h_tbit_set (opval);
3522   }
3523 }
3524
3525   current_cpu->done_insn (npc, status);
3526 #undef FLD
3527 }
3528
3529 // ********** shll2-compact: shll2 $rn
3530
3531 void
3532 sh2a_nofpu_sem_shll2_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3533         sh2a_nofpu::write_stacks &buf)
3534 {
3535 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3536   sem_status status = SEM_STATUS_NORMAL;
3537   sh2a_nofpu_scache* abuf = sem;
3538   unsigned long long written = 0;
3539   PCADDR pc = abuf->addr;
3540   PCADDR npc = pc + 2;
3541
3542   {
3543     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
3544     if (UNLIKELY(current_cpu->trace_result_p))
3545       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3546     current_cpu->h_grc_set (FLD (f_rn), opval);
3547   }
3548
3549   current_cpu->done_insn (npc, status);
3550 #undef FLD
3551 }
3552
3553 // ********** shll8-compact: shll8 $rn
3554
3555 void
3556 sh2a_nofpu_sem_shll8_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3557         sh2a_nofpu::write_stacks &buf)
3558 {
3559 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3560   sem_status status = SEM_STATUS_NORMAL;
3561   sh2a_nofpu_scache* abuf = sem;
3562   unsigned long long written = 0;
3563   PCADDR pc = abuf->addr;
3564   PCADDR npc = pc + 2;
3565
3566   {
3567     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 8);
3568     if (UNLIKELY(current_cpu->trace_result_p))
3569       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3570     current_cpu->h_grc_set (FLD (f_rn), opval);
3571   }
3572
3573   current_cpu->done_insn (npc, status);
3574 #undef FLD
3575 }
3576
3577 // ********** shll16-compact: shll16 $rn
3578
3579 void
3580 sh2a_nofpu_sem_shll16_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3581         sh2a_nofpu::write_stacks &buf)
3582 {
3583 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3584   sem_status status = SEM_STATUS_NORMAL;
3585   sh2a_nofpu_scache* abuf = sem;
3586   unsigned long long written = 0;
3587   PCADDR pc = abuf->addr;
3588   PCADDR npc = pc + 2;
3589
3590   {
3591     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 16);
3592     if (UNLIKELY(current_cpu->trace_result_p))
3593       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3594     current_cpu->h_grc_set (FLD (f_rn), opval);
3595   }
3596
3597   current_cpu->done_insn (npc, status);
3598 #undef FLD
3599 }
3600
3601 // ********** shlr-compact: shlr $rn
3602
3603 void
3604 sh2a_nofpu_sem_shlr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3605         sh2a_nofpu::write_stacks &buf)
3606 {
3607 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3608   sem_status status = SEM_STATUS_NORMAL;
3609   sh2a_nofpu_scache* abuf = sem;
3610   unsigned long long written = 0;
3611   PCADDR pc = abuf->addr;
3612   PCADDR npc = pc + 2;
3613
3614 {
3615   BI tmp_t;
3616   tmp_t = ANDSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
3617   {
3618     SI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
3619     if (UNLIKELY(current_cpu->trace_result_p))
3620       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3621     current_cpu->h_grc_set (FLD (f_rn), opval);
3622   }
3623   {
3624     BI opval = ((tmp_t) ? (1) : (0));
3625     if (UNLIKELY(current_cpu->trace_result_p))
3626       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3627     current_cpu->h_tbit_set (opval);
3628   }
3629 }
3630
3631   current_cpu->done_insn (npc, status);
3632 #undef FLD
3633 }
3634
3635 // ********** shlr2-compact: shlr2 $rn
3636
3637 void
3638 sh2a_nofpu_sem_shlr2_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3639         sh2a_nofpu::write_stacks &buf)
3640 {
3641 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3642   sem_status status = SEM_STATUS_NORMAL;
3643   sh2a_nofpu_scache* abuf = sem;
3644   unsigned long long written = 0;
3645   PCADDR pc = abuf->addr;
3646   PCADDR npc = pc + 2;
3647
3648   {
3649     SI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
3650     if (UNLIKELY(current_cpu->trace_result_p))
3651       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3652     current_cpu->h_grc_set (FLD (f_rn), opval);
3653   }
3654
3655   current_cpu->done_insn (npc, status);
3656 #undef FLD
3657 }
3658
3659 // ********** shlr8-compact: shlr8 $rn
3660
3661 void
3662 sh2a_nofpu_sem_shlr8_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3663         sh2a_nofpu::write_stacks &buf)
3664 {
3665 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3666   sem_status status = SEM_STATUS_NORMAL;
3667   sh2a_nofpu_scache* abuf = sem;
3668   unsigned long long written = 0;
3669   PCADDR pc = abuf->addr;
3670   PCADDR npc = pc + 2;
3671
3672   {
3673     SI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 8);
3674     if (UNLIKELY(current_cpu->trace_result_p))
3675       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3676     current_cpu->h_grc_set (FLD (f_rn), opval);
3677   }
3678
3679   current_cpu->done_insn (npc, status);
3680 #undef FLD
3681 }
3682
3683 // ********** shlr16-compact: shlr16 $rn
3684
3685 void
3686 sh2a_nofpu_sem_shlr16_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3687         sh2a_nofpu::write_stacks &buf)
3688 {
3689 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3690   sem_status status = SEM_STATUS_NORMAL;
3691   sh2a_nofpu_scache* abuf = sem;
3692   unsigned long long written = 0;
3693   PCADDR pc = abuf->addr;
3694   PCADDR npc = pc + 2;
3695
3696   {
3697     SI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 16);
3698     if (UNLIKELY(current_cpu->trace_result_p))
3699       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3700     current_cpu->h_grc_set (FLD (f_rn), opval);
3701   }
3702
3703   current_cpu->done_insn (npc, status);
3704 #undef FLD
3705 }
3706
3707 // ********** stc-gbr-compact: stc gbr, $rn
3708
3709 void
3710 sh2a_nofpu_sem_stc_gbr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3711         sh2a_nofpu::write_stacks &buf)
3712 {
3713 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
3714   sem_status status = SEM_STATUS_NORMAL;
3715   sh2a_nofpu_scache* abuf = sem;
3716   unsigned long long written = 0;
3717   PCADDR pc = abuf->addr;
3718   PCADDR npc = pc + 2;
3719
3720   {
3721     SI opval = current_cpu->h_gbr_get ();
3722     if (UNLIKELY(current_cpu->trace_result_p))
3723       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3724     current_cpu->h_grc_set (FLD (f_rn), opval);
3725   }
3726
3727   current_cpu->done_insn (npc, status);
3728 #undef FLD
3729 }
3730
3731 // ********** stc-vbr-compact: stc vbr, $rn
3732
3733 void
3734 sh2a_nofpu_sem_stc_vbr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3735         sh2a_nofpu::write_stacks &buf)
3736 {
3737 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
3738   sem_status status = SEM_STATUS_NORMAL;
3739   sh2a_nofpu_scache* abuf = sem;
3740   unsigned long long written = 0;
3741   PCADDR pc = abuf->addr;
3742   PCADDR npc = pc + 2;
3743
3744   {
3745     SI opval = current_cpu->h_vbr_get ();
3746     if (UNLIKELY(current_cpu->trace_result_p))
3747       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3748     current_cpu->h_grc_set (FLD (f_rn), opval);
3749   }
3750
3751   current_cpu->done_insn (npc, status);
3752 #undef FLD
3753 }
3754
3755 // ********** stcl-gbr-compact: stc.l gbr, @-$rn
3756
3757 void
3758 sh2a_nofpu_sem_stcl_gbr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3759         sh2a_nofpu::write_stacks &buf)
3760 {
3761 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3762   sem_status status = SEM_STATUS_NORMAL;
3763   sh2a_nofpu_scache* abuf = sem;
3764   unsigned long long written = 0;
3765   PCADDR pc = abuf->addr;
3766   PCADDR npc = pc + 2;
3767
3768 {
3769   DI tmp_addr;
3770   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
3771   {
3772     SI opval = current_cpu->h_gbr_get ();
3773     if (UNLIKELY(current_cpu->trace_result_p))
3774       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3775     current_cpu->SETMEMSI (pc, tmp_addr, opval);
3776   }
3777   {
3778     SI opval = tmp_addr;
3779     if (UNLIKELY(current_cpu->trace_result_p))
3780       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3781     current_cpu->h_grc_set (FLD (f_rn), opval);
3782   }
3783 }
3784
3785   current_cpu->done_insn (npc, status);
3786 #undef FLD
3787 }
3788
3789 // ********** stcl-vbr-compact: stc.l vbr, @-$rn
3790
3791 void
3792 sh2a_nofpu_sem_stcl_vbr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3793         sh2a_nofpu::write_stacks &buf)
3794 {
3795 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3796   sem_status status = SEM_STATUS_NORMAL;
3797   sh2a_nofpu_scache* abuf = sem;
3798   unsigned long long written = 0;
3799   PCADDR pc = abuf->addr;
3800   PCADDR npc = pc + 2;
3801
3802 {
3803   DI tmp_addr;
3804   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
3805   {
3806     SI opval = current_cpu->h_vbr_get ();
3807     if (UNLIKELY(current_cpu->trace_result_p))
3808       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3809     current_cpu->SETMEMSI (pc, tmp_addr, opval);
3810   }
3811   {
3812     SI opval = tmp_addr;
3813     if (UNLIKELY(current_cpu->trace_result_p))
3814       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3815     current_cpu->h_grc_set (FLD (f_rn), opval);
3816   }
3817 }
3818
3819   current_cpu->done_insn (npc, status);
3820 #undef FLD
3821 }
3822
3823 // ********** sts-mach-compact: sts mach, $rn
3824
3825 void
3826 sh2a_nofpu_sem_sts_mach_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3827         sh2a_nofpu::write_stacks &buf)
3828 {
3829 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
3830   sem_status status = SEM_STATUS_NORMAL;
3831   sh2a_nofpu_scache* abuf = sem;
3832   unsigned long long written = 0;
3833   PCADDR pc = abuf->addr;
3834   PCADDR npc = pc + 2;
3835
3836   {
3837     SI opval = current_cpu->h_mach_get ();
3838     if (UNLIKELY(current_cpu->trace_result_p))
3839       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3840     current_cpu->h_grc_set (FLD (f_rn), opval);
3841   }
3842
3843   current_cpu->done_insn (npc, status);
3844 #undef FLD
3845 }
3846
3847 // ********** stsl-mach-compact: sts.l mach, @-$rn
3848
3849 void
3850 sh2a_nofpu_sem_stsl_mach_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3851         sh2a_nofpu::write_stacks &buf)
3852 {
3853 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3854   sem_status status = SEM_STATUS_NORMAL;
3855   sh2a_nofpu_scache* abuf = sem;
3856   unsigned long long written = 0;
3857   PCADDR pc = abuf->addr;
3858   PCADDR npc = pc + 2;
3859
3860 {
3861   DI tmp_addr;
3862   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
3863   {
3864     SI opval = current_cpu->h_mach_get ();
3865     if (UNLIKELY(current_cpu->trace_result_p))
3866       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3867     current_cpu->SETMEMSI (pc, tmp_addr, opval);
3868   }
3869   {
3870     SI opval = tmp_addr;
3871     if (UNLIKELY(current_cpu->trace_result_p))
3872       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3873     current_cpu->h_grc_set (FLD (f_rn), opval);
3874   }
3875 }
3876
3877   current_cpu->done_insn (npc, status);
3878 #undef FLD
3879 }
3880
3881 // ********** sts-macl-compact: sts macl, $rn
3882
3883 void
3884 sh2a_nofpu_sem_sts_macl_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3885         sh2a_nofpu::write_stacks &buf)
3886 {
3887 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
3888   sem_status status = SEM_STATUS_NORMAL;
3889   sh2a_nofpu_scache* abuf = sem;
3890   unsigned long long written = 0;
3891   PCADDR pc = abuf->addr;
3892   PCADDR npc = pc + 2;
3893
3894   {
3895     SI opval = current_cpu->h_macl_get ();
3896     if (UNLIKELY(current_cpu->trace_result_p))
3897       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3898     current_cpu->h_grc_set (FLD (f_rn), opval);
3899   }
3900
3901   current_cpu->done_insn (npc, status);
3902 #undef FLD
3903 }
3904
3905 // ********** stsl-macl-compact: sts.l macl, @-$rn
3906
3907 void
3908 sh2a_nofpu_sem_stsl_macl_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3909         sh2a_nofpu::write_stacks &buf)
3910 {
3911 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3912   sem_status status = SEM_STATUS_NORMAL;
3913   sh2a_nofpu_scache* abuf = sem;
3914   unsigned long long written = 0;
3915   PCADDR pc = abuf->addr;
3916   PCADDR npc = pc + 2;
3917
3918 {
3919   DI tmp_addr;
3920   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
3921   {
3922     SI opval = current_cpu->h_macl_get ();
3923     if (UNLIKELY(current_cpu->trace_result_p))
3924       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3925     current_cpu->SETMEMSI (pc, tmp_addr, opval);
3926   }
3927   {
3928     SI opval = tmp_addr;
3929     if (UNLIKELY(current_cpu->trace_result_p))
3930       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3931     current_cpu->h_grc_set (FLD (f_rn), opval);
3932   }
3933 }
3934
3935   current_cpu->done_insn (npc, status);
3936 #undef FLD
3937 }
3938
3939 // ********** sts-pr-compact: sts pr, $rn
3940
3941 void
3942 sh2a_nofpu_sem_sts_pr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3943         sh2a_nofpu::write_stacks &buf)
3944 {
3945 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
3946   sem_status status = SEM_STATUS_NORMAL;
3947   sh2a_nofpu_scache* abuf = sem;
3948   unsigned long long written = 0;
3949   PCADDR pc = abuf->addr;
3950   PCADDR npc = pc + 2;
3951
3952   {
3953     SI opval = current_cpu->h_pr_get ();
3954     if (UNLIKELY(current_cpu->trace_result_p))
3955       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3956     current_cpu->h_grc_set (FLD (f_rn), opval);
3957   }
3958
3959   current_cpu->done_insn (npc, status);
3960 #undef FLD
3961 }
3962
3963 // ********** stsl-pr-compact: sts.l pr, @-$rn
3964
3965 void
3966 sh2a_nofpu_sem_stsl_pr_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
3967         sh2a_nofpu::write_stacks &buf)
3968 {
3969 #define FLD(f) abuf->fields.sfmt_divu_compact.f
3970   sem_status status = SEM_STATUS_NORMAL;
3971   sh2a_nofpu_scache* abuf = sem;
3972   unsigned long long written = 0;
3973   PCADDR pc = abuf->addr;
3974   PCADDR npc = pc + 2;
3975
3976 {
3977   DI tmp_addr;
3978   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
3979   {
3980     SI opval = current_cpu->h_pr_get ();
3981     if (UNLIKELY(current_cpu->trace_result_p))
3982       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3983     current_cpu->SETMEMSI (pc, tmp_addr, opval);
3984   }
3985   {
3986     SI opval = tmp_addr;
3987     if (UNLIKELY(current_cpu->trace_result_p))
3988       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3989     current_cpu->h_grc_set (FLD (f_rn), opval);
3990   }
3991 }
3992
3993   current_cpu->done_insn (npc, status);
3994 #undef FLD
3995 }
3996
3997 // ********** sub-compact: sub $rm, $rn
3998
3999 void
4000 sh2a_nofpu_sem_sub_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4001         sh2a_nofpu::write_stacks &buf)
4002 {
4003 #define FLD(f) abuf->fields.sfmt_macl_compact.f
4004   sem_status status = SEM_STATUS_NORMAL;
4005   sh2a_nofpu_scache* abuf = sem;
4006   unsigned long long written = 0;
4007   PCADDR pc = abuf->addr;
4008   PCADDR npc = pc + 2;
4009
4010   {
4011     SI opval = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
4012     if (UNLIKELY(current_cpu->trace_result_p))
4013       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4014     current_cpu->h_grc_set (FLD (f_rn), opval);
4015   }
4016
4017   current_cpu->done_insn (npc, status);
4018 #undef FLD
4019 }
4020
4021 // ********** subc-compact: subc $rm, $rn
4022
4023 void
4024 sh2a_nofpu_sem_subc_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4025         sh2a_nofpu::write_stacks &buf)
4026 {
4027 #define FLD(f) abuf->fields.sfmt_macl_compact.f
4028   sem_status status = SEM_STATUS_NORMAL;
4029   sh2a_nofpu_scache* abuf = sem;
4030   unsigned long long written = 0;
4031   PCADDR pc = abuf->addr;
4032   PCADDR npc = pc + 2;
4033
4034 {
4035   BI tmp_flag;
4036   tmp_flag = SUBCFSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
4037   {
4038     SI opval = SUBCSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
4039     if (UNLIKELY(current_cpu->trace_result_p))
4040       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4041     current_cpu->h_grc_set (FLD (f_rn), opval);
4042   }
4043   {
4044     BI opval = tmp_flag;
4045     if (UNLIKELY(current_cpu->trace_result_p))
4046       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4047     current_cpu->h_tbit_set (opval);
4048   }
4049 }
4050
4051   current_cpu->done_insn (npc, status);
4052 #undef FLD
4053 }
4054
4055 // ********** subv-compact: subv $rm, $rn
4056
4057 void
4058 sh2a_nofpu_sem_subv_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4059         sh2a_nofpu::write_stacks &buf)
4060 {
4061 #define FLD(f) abuf->fields.sfmt_macl_compact.f
4062   sem_status status = SEM_STATUS_NORMAL;
4063   sh2a_nofpu_scache* abuf = sem;
4064   unsigned long long written = 0;
4065   PCADDR pc = abuf->addr;
4066   PCADDR npc = pc + 2;
4067
4068 {
4069   BI tmp_t;
4070   tmp_t = SUBOFSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)), 0);
4071   {
4072     SI opval = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
4073     if (UNLIKELY(current_cpu->trace_result_p))
4074       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4075     current_cpu->h_grc_set (FLD (f_rn), opval);
4076   }
4077   {
4078     BI opval = ((tmp_t) ? (1) : (0));
4079     if (UNLIKELY(current_cpu->trace_result_p))
4080       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4081     current_cpu->h_tbit_set (opval);
4082   }
4083 }
4084
4085   current_cpu->done_insn (npc, status);
4086 #undef FLD
4087 }
4088
4089 // ********** swapb-compact: swap.b $rm, $rn
4090
4091 void
4092 sh2a_nofpu_sem_swapb_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4093         sh2a_nofpu::write_stacks &buf)
4094 {
4095 #define FLD(f) abuf->fields.sfmt_movl12_compact.f
4096   sem_status status = SEM_STATUS_NORMAL;
4097   sh2a_nofpu_scache* abuf = sem;
4098   unsigned long long written = 0;
4099   PCADDR pc = abuf->addr;
4100   PCADDR npc = pc + 2;
4101
4102 {
4103   UHI tmp_top_half;
4104   UQI tmp_byte1;
4105   UQI tmp_byte0;
4106   tmp_top_half = SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 0);
4107   tmp_byte1 = SUBWORDSIQI (current_cpu->h_grc_get (FLD (f_rm)), 2);
4108   tmp_byte0 = SUBWORDSIQI (current_cpu->h_grc_get (FLD (f_rm)), 3);
4109   {
4110     SI opval = ORSI (SLLSI (tmp_top_half, 16), ORSI (SLLSI (tmp_byte0, 8), tmp_byte1));
4111     if (UNLIKELY(current_cpu->trace_result_p))
4112       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4113     current_cpu->h_grc_set (FLD (f_rn), opval);
4114   }
4115 }
4116
4117   current_cpu->done_insn (npc, status);
4118 #undef FLD
4119 }
4120
4121 // ********** swapw-compact: swap.w $rm, $rn
4122
4123 void
4124 sh2a_nofpu_sem_swapw_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4125         sh2a_nofpu::write_stacks &buf)
4126 {
4127 #define FLD(f) abuf->fields.sfmt_movl12_compact.f
4128   sem_status status = SEM_STATUS_NORMAL;
4129   sh2a_nofpu_scache* abuf = sem;
4130   unsigned long long written = 0;
4131   PCADDR pc = abuf->addr;
4132   PCADDR npc = pc + 2;
4133
4134   {
4135     SI opval = ORSI (SRLSI (current_cpu->h_grc_get (FLD (f_rm)), 16), SLLSI (current_cpu->h_grc_get (FLD (f_rm)), 16));
4136     if (UNLIKELY(current_cpu->trace_result_p))
4137       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4138     current_cpu->h_grc_set (FLD (f_rn), opval);
4139   }
4140
4141   current_cpu->done_insn (npc, status);
4142 #undef FLD
4143 }
4144
4145 // ********** tasb-compact: tas.b @$rn
4146
4147 void
4148 sh2a_nofpu_sem_tasb_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4149         sh2a_nofpu::write_stacks &buf)
4150 {
4151 #define FLD(f) abuf->fields.sfmt_divu_compact.f
4152   sem_status status = SEM_STATUS_NORMAL;
4153   sh2a_nofpu_scache* abuf = sem;
4154   unsigned long long written = 0;
4155   PCADDR pc = abuf->addr;
4156   PCADDR npc = pc + 2;
4157
4158 {
4159   UQI tmp_byte;
4160   tmp_byte = current_cpu->GETMEMUQI (pc, current_cpu->h_grc_get (FLD (f_rn)));
4161   {
4162     BI opval = ((EQQI (tmp_byte, 0)) ? (1) : (0));
4163     if (UNLIKELY(current_cpu->trace_result_p))
4164       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4165     current_cpu->h_tbit_set (opval);
4166   }
4167   tmp_byte = ORQI (tmp_byte, 128);
4168   {
4169     UQI opval = tmp_byte;
4170     if (UNLIKELY(current_cpu->trace_result_p))
4171       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
4172     current_cpu->SETMEMUQI (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
4173   }
4174 }
4175
4176   current_cpu->done_insn (npc, status);
4177 #undef FLD
4178 }
4179
4180 // ********** trapa-compact: trapa #$uimm8
4181
4182 void
4183 sh2a_nofpu_sem_trapa_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4184         sh2a_nofpu::write_stacks &buf)
4185 {
4186 #define FLD(f) abuf->fields.sfmt_andi_compact.f
4187   sem_status status = SEM_STATUS_NORMAL;
4188   sh2a_nofpu_scache* abuf = sem;
4189   unsigned long long written = 0;
4190   PCADDR pc = abuf->addr;
4191   PCADDR npc = pc + 2;
4192
4193 current_cpu->sh64_compact_trapa (FLD (f_imm8), pc);
4194
4195   current_cpu->done_insn (npc, status);
4196 #undef FLD
4197 }
4198
4199 // ********** tst-compact: tst $rm, $rn
4200
4201 void
4202 sh2a_nofpu_sem_tst_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4203         sh2a_nofpu::write_stacks &buf)
4204 {
4205 #define FLD(f) abuf->fields.sfmt_movl13_compact.f
4206   sem_status status = SEM_STATUS_NORMAL;
4207   sh2a_nofpu_scache* abuf = sem;
4208   unsigned long long written = 0;
4209   PCADDR pc = abuf->addr;
4210   PCADDR npc = pc + 2;
4211
4212   {
4213     BI opval = ((EQSI (ANDSI (current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_grc_get (FLD (f_rn))), 0)) ? (1) : (0));
4214     if (UNLIKELY(current_cpu->trace_result_p))
4215       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4216     current_cpu->h_tbit_set (opval);
4217   }
4218
4219   current_cpu->done_insn (npc, status);
4220 #undef FLD
4221 }
4222
4223 // ********** tsti-compact: tst #$uimm8, r0
4224
4225 void
4226 sh2a_nofpu_sem_tsti_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4227         sh2a_nofpu::write_stacks &buf)
4228 {
4229 #define FLD(f) abuf->fields.sfmt_andi_compact.f
4230   sem_status status = SEM_STATUS_NORMAL;
4231   sh2a_nofpu_scache* abuf = sem;
4232   unsigned long long written = 0;
4233   PCADDR pc = abuf->addr;
4234   PCADDR npc = pc + 2;
4235
4236   {
4237     BI opval = ((EQSI (ANDSI (current_cpu->h_grc_get (((UINT) 0)), ZEXTSISI (FLD (f_imm8))), 0)) ? (1) : (0));
4238     if (UNLIKELY(current_cpu->trace_result_p))
4239       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4240     current_cpu->h_tbit_set (opval);
4241   }
4242
4243   current_cpu->done_insn (npc, status);
4244 #undef FLD
4245 }
4246
4247 // ********** tstb-compact: tst.b #$imm8, @(r0, gbr)
4248
4249 void
4250 sh2a_nofpu_sem_tstb_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4251         sh2a_nofpu::write_stacks &buf)
4252 {
4253 #define FLD(f) abuf->fields.sfmt_andi_compact.f
4254   sem_status status = SEM_STATUS_NORMAL;
4255   sh2a_nofpu_scache* abuf = sem;
4256   unsigned long long written = 0;
4257   PCADDR pc = abuf->addr;
4258   PCADDR npc = pc + 2;
4259
4260 {
4261   DI tmp_addr;
4262   tmp_addr = ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_gbr_get ());
4263   {
4264     BI opval = ((EQQI (ANDQI (current_cpu->GETMEMUQI (pc, tmp_addr), FLD (f_imm8)), 0)) ? (1) : (0));
4265     if (UNLIKELY(current_cpu->trace_result_p))
4266       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4267     current_cpu->h_tbit_set (opval);
4268   }
4269 }
4270
4271   current_cpu->done_insn (npc, status);
4272 #undef FLD
4273 }
4274
4275 // ********** xor-compact: xor $rm64, $rn64
4276
4277 void
4278 sh2a_nofpu_sem_xor_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4279         sh2a_nofpu::write_stacks &buf)
4280 {
4281 #define FLD(f) abuf->fields.sfmt_and_compact.f
4282   sem_status status = SEM_STATUS_NORMAL;
4283   sh2a_nofpu_scache* abuf = sem;
4284   unsigned long long written = 0;
4285   PCADDR pc = abuf->addr;
4286   PCADDR npc = pc + 2;
4287
4288   {
4289     DI opval = XORDI (current_cpu->h_gr_get (FLD (f_rn)), current_cpu->h_gr_get (FLD (f_rm)));
4290     if (UNLIKELY(current_cpu->trace_result_p))
4291       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4292     current_cpu->h_gr_set (FLD (f_rn), opval);
4293   }
4294
4295   current_cpu->done_insn (npc, status);
4296 #undef FLD
4297 }
4298
4299 // ********** xori-compact: xor #$uimm8, r0
4300
4301 void
4302 sh2a_nofpu_sem_xori_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4303         sh2a_nofpu::write_stacks &buf)
4304 {
4305 #define FLD(f) abuf->fields.sfmt_andi_compact.f
4306   sem_status status = SEM_STATUS_NORMAL;
4307   sh2a_nofpu_scache* abuf = sem;
4308   unsigned long long written = 0;
4309   PCADDR pc = abuf->addr;
4310   PCADDR npc = pc + 2;
4311
4312   {
4313     SI opval = XORSI (current_cpu->h_grc_get (((UINT) 0)), ZEXTSIDI (FLD (f_imm8)));
4314     if (UNLIKELY(current_cpu->trace_result_p))
4315       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
4316     current_cpu->h_grc_set (((UINT) 0), opval);
4317   }
4318
4319   current_cpu->done_insn (npc, status);
4320 #undef FLD
4321 }
4322
4323 // ********** xorb-compact: xor.b #$imm8, @(r0, gbr)
4324
4325 void
4326 sh2a_nofpu_sem_xorb_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4327         sh2a_nofpu::write_stacks &buf)
4328 {
4329 #define FLD(f) abuf->fields.sfmt_andi_compact.f
4330   sem_status status = SEM_STATUS_NORMAL;
4331   sh2a_nofpu_scache* abuf = sem;
4332   unsigned long long written = 0;
4333   PCADDR pc = abuf->addr;
4334   PCADDR npc = pc + 2;
4335
4336 {
4337   DI tmp_addr;
4338   UQI tmp_data;
4339   tmp_addr = ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_gbr_get ());
4340   tmp_data = XORQI (current_cpu->GETMEMUQI (pc, tmp_addr), FLD (f_imm8));
4341   {
4342     UQI opval = tmp_data;
4343     if (UNLIKELY(current_cpu->trace_result_p))
4344       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
4345     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
4346   }
4347 }
4348
4349   current_cpu->done_insn (npc, status);
4350 #undef FLD
4351 }
4352
4353 // ********** xtrct-compact: xtrct $rm, $rn
4354
4355 void
4356 sh2a_nofpu_sem_xtrct_compact (sh2a_nofpu_cpu* current_cpu, sh2a_nofpu_scache* sem, const int tick, 
4357         sh2a_nofpu::write_stacks &buf)
4358 {
4359 #define FLD(f) abuf->fields.sfmt_macl_compact.f
4360   sem_status status = SEM_STATUS_NORMAL;
4361   sh2a_nofpu_scache* abuf = sem;
4362   unsigned long long written = 0;
4363   PCADDR pc = abuf->addr;
4364   PCADDR npc = pc + 2;
4365
4366   {
4367     SI opval = ORSI (SLLSI (current_cpu->h_grc_get (FLD (f_rm)), 16), SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 16));
4368     if (UNLIKELY(current_cpu->trace_result_p))
4369       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4370     current_cpu->h_grc_set (FLD (f_rn), opval);
4371   }
4372
4373   current_cpu->done_insn (npc, status);
4374 #undef FLD
4375 }
4376