OSDN Git Service

Regenerate cgen files, update copyright year.
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / cgen-cpu / sh / sh2-sem.cxx
1 /* Simulator instruction semantics for sh2.
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 "sh2.h"
17
18 using namespace sh2; // FIXME: namespace organization still wip
19 using namespace sh2; // FIXME: namespace organization still wip
20 #define GET_ATTR(name) GET_ATTR_##name ()
21
22
23 // ********** x-invalid: --invalid--
24
25 void
26 sh2_sem_x_invalid (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
27         sh2::write_stacks &buf)
28 {
29 #define FLD(f) abuf->fields.fmt_empty.f
30   sem_status status = SEM_STATUS_NORMAL;
31   sh2_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 sh2_sem_add_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
50         sh2::write_stacks &buf)
51 {
52 #define FLD(f) abuf->fields.sfmt_macl_compact.f
53   sem_status status = SEM_STATUS_NORMAL;
54   sh2_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 sh2_sem_addi_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
74         sh2::write_stacks &buf)
75 {
76 #define FLD(f) abuf->fields.sfmt_addi_compact.f
77   sem_status status = SEM_STATUS_NORMAL;
78   sh2_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 sh2_sem_addc_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
98         sh2::write_stacks &buf)
99 {
100 #define FLD(f) abuf->fields.sfmt_macl_compact.f
101   sem_status status = SEM_STATUS_NORMAL;
102   sh2_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 sh2_sem_addv_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
132         sh2::write_stacks &buf)
133 {
134 #define FLD(f) abuf->fields.sfmt_macl_compact.f
135   sem_status status = SEM_STATUS_NORMAL;
136   sh2_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 sh2_sem_and_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
166         sh2::write_stacks &buf)
167 {
168 #define FLD(f) abuf->fields.sfmt_and_compact.f
169   sem_status status = SEM_STATUS_NORMAL;
170   sh2_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 sh2_sem_andi_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
190         sh2::write_stacks &buf)
191 {
192 #define FLD(f) abuf->fields.sfmt_andi_compact.f
193   sem_status status = SEM_STATUS_NORMAL;
194   sh2_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 sh2_sem_andb_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
214         sh2::write_stacks &buf)
215 {
216 #define FLD(f) abuf->fields.sfmt_andi_compact.f
217   sem_status status = SEM_STATUS_NORMAL;
218   sh2_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 sh2_sem_bf_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
244         sh2::write_stacks &buf)
245 {
246 #define FLD(f) abuf->fields.sfmt_bf_compact.f
247   sem_status status = SEM_STATUS_NORMAL;
248   sh2_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 sh2_sem_bfs_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
272         sh2::write_stacks &buf)
273 {
274 #define FLD(f) abuf->fields.sfmt_bf_compact.f
275   sem_status status = SEM_STATUS_NORMAL;
276   sh2_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) % sh2::pipe_sz].push (sh2::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 sh2_sem_bra_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
309         sh2::write_stacks &buf)
310 {
311 #define FLD(f) abuf->fields.sfmt_bra_compact.f
312   sem_status status = SEM_STATUS_NORMAL;
313   sh2_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) % sh2::pipe_sz].push (sh2::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 sh2_sem_braf_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
342         sh2::write_stacks &buf)
343 {
344 #define FLD(f) abuf->fields.sfmt_addi_compact.f
345   sem_status status = SEM_STATUS_NORMAL;
346   sh2_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) % sh2::pipe_sz].push (sh2::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 sh2_sem_bsr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
375         sh2::write_stacks &buf)
376 {
377 #define FLD(f) abuf->fields.sfmt_bra_compact.f
378   sem_status status = SEM_STATUS_NORMAL;
379   sh2_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) % sh2::pipe_sz].push (sh2::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) % sh2::pipe_sz].push (sh2::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 sh2_sem_bsrf_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
414         sh2::write_stacks &buf)
415 {
416 #define FLD(f) abuf->fields.sfmt_addi_compact.f
417   sem_status status = SEM_STATUS_NORMAL;
418   sh2_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) % sh2::pipe_sz].push (sh2::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) % sh2::pipe_sz].push (sh2::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 sh2_sem_bt_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
453         sh2::write_stacks &buf)
454 {
455 #define FLD(f) abuf->fields.sfmt_bf_compact.f
456   sem_status status = SEM_STATUS_NORMAL;
457   sh2_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 sh2_sem_bts_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
481         sh2::write_stacks &buf)
482 {
483 #define FLD(f) abuf->fields.sfmt_bf_compact.f
484   sem_status status = SEM_STATUS_NORMAL;
485   sh2_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) % sh2::pipe_sz].push (sh2::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 sh2_sem_clrmac_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
518         sh2::write_stacks &buf)
519 {
520 #define FLD(f) abuf->fields.fmt_empty.f
521   sem_status status = SEM_STATUS_NORMAL;
522   sh2_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 sh2_sem_clrt_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
550         sh2::write_stacks &buf)
551 {
552 #define FLD(f) abuf->fields.fmt_empty.f
553   sem_status status = SEM_STATUS_NORMAL;
554   sh2_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 sh2_sem_cmpeq_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
574         sh2::write_stacks &buf)
575 {
576 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
577   sem_status status = SEM_STATUS_NORMAL;
578   sh2_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 sh2_sem_cmpeqi_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
598         sh2::write_stacks &buf)
599 {
600 #define FLD(f) abuf->fields.sfmt_andi_compact.f
601   sem_status status = SEM_STATUS_NORMAL;
602   sh2_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 sh2_sem_cmpge_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
622         sh2::write_stacks &buf)
623 {
624 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
625   sem_status status = SEM_STATUS_NORMAL;
626   sh2_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 sh2_sem_cmpgt_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
646         sh2::write_stacks &buf)
647 {
648 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
649   sem_status status = SEM_STATUS_NORMAL;
650   sh2_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 sh2_sem_cmphi_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
670         sh2::write_stacks &buf)
671 {
672 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
673   sem_status status = SEM_STATUS_NORMAL;
674   sh2_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 sh2_sem_cmphs_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
694         sh2::write_stacks &buf)
695 {
696 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
697   sem_status status = SEM_STATUS_NORMAL;
698   sh2_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 sh2_sem_cmppl_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
718         sh2::write_stacks &buf)
719 {
720 #define FLD(f) abuf->fields.sfmt_addi_compact.f
721   sem_status status = SEM_STATUS_NORMAL;
722   sh2_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 sh2_sem_cmppz_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
742         sh2::write_stacks &buf)
743 {
744 #define FLD(f) abuf->fields.sfmt_addi_compact.f
745   sem_status status = SEM_STATUS_NORMAL;
746   sh2_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 sh2_sem_cmpstr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
766         sh2::write_stacks &buf)
767 {
768 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
769   sem_status status = SEM_STATUS_NORMAL;
770   sh2_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 sh2_sem_div0s_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
799         sh2::write_stacks &buf)
800 {
801 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
802   sem_status status = SEM_STATUS_NORMAL;
803   sh2_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 sh2_sem_div0u_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
837         sh2::write_stacks &buf)
838 {
839 #define FLD(f) abuf->fields.fmt_empty.f
840   sem_status status = SEM_STATUS_NORMAL;
841   sh2_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 sh2_sem_div1_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
875         sh2::write_stacks &buf)
876 {
877 #define FLD(f) abuf->fields.sfmt_macl_compact.f
878   sem_status status = SEM_STATUS_NORMAL;
879   sh2_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 // ********** dmulsl-compact: dmuls.l $rm, $rn
1023
1024 void
1025 sh2_sem_dmulsl_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1026         sh2::write_stacks &buf)
1027 {
1028 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
1029   sem_status status = SEM_STATUS_NORMAL;
1030   sh2_scache* abuf = sem;
1031   unsigned long long written = 0;
1032   PCADDR pc = abuf->addr;
1033   PCADDR npc = pc + 2;
1034
1035 {
1036   DI tmp_result;
1037   tmp_result = MULDI (EXTSIDI (current_cpu->h_grc_get (FLD (f_rm))), EXTSIDI (current_cpu->h_grc_get (FLD (f_rn))));
1038   {
1039     SI opval = SUBWORDDISI (tmp_result, 0);
1040     if (UNLIKELY(current_cpu->trace_result_p))
1041       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1042     current_cpu->h_mach_set (opval);
1043   }
1044   {
1045     SI opval = SUBWORDDISI (tmp_result, 1);
1046     if (UNLIKELY(current_cpu->trace_result_p))
1047       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1048     current_cpu->h_macl_set (opval);
1049   }
1050 }
1051
1052   current_cpu->done_insn (npc, status);
1053 #undef FLD
1054 }
1055
1056 // ********** dmulul-compact: dmulu.l $rm, $rn
1057
1058 void
1059 sh2_sem_dmulul_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1060         sh2::write_stacks &buf)
1061 {
1062 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
1063   sem_status status = SEM_STATUS_NORMAL;
1064   sh2_scache* abuf = sem;
1065   unsigned long long written = 0;
1066   PCADDR pc = abuf->addr;
1067   PCADDR npc = pc + 2;
1068
1069 {
1070   DI tmp_result;
1071   tmp_result = MULDI (ZEXTSIDI (current_cpu->h_grc_get (FLD (f_rm))), ZEXTSIDI (current_cpu->h_grc_get (FLD (f_rn))));
1072   {
1073     SI opval = SUBWORDDISI (tmp_result, 0);
1074     if (UNLIKELY(current_cpu->trace_result_p))
1075       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1076     current_cpu->h_mach_set (opval);
1077   }
1078   {
1079     SI opval = SUBWORDDISI (tmp_result, 1);
1080     if (UNLIKELY(current_cpu->trace_result_p))
1081       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1082     current_cpu->h_macl_set (opval);
1083   }
1084 }
1085
1086   current_cpu->done_insn (npc, status);
1087 #undef FLD
1088 }
1089
1090 // ********** dt-compact: dt $rn
1091
1092 void
1093 sh2_sem_dt_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1094         sh2::write_stacks &buf)
1095 {
1096 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1097   sem_status status = SEM_STATUS_NORMAL;
1098   sh2_scache* abuf = sem;
1099   unsigned long long written = 0;
1100   PCADDR pc = abuf->addr;
1101   PCADDR npc = pc + 2;
1102
1103 {
1104   {
1105     SI opval = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
1106     if (UNLIKELY(current_cpu->trace_result_p))
1107       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1108     current_cpu->h_grc_set (FLD (f_rn), opval);
1109   }
1110   {
1111     BI opval = EQSI (current_cpu->h_grc_get (FLD (f_rn)), 0);
1112     if (UNLIKELY(current_cpu->trace_result_p))
1113       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
1114     current_cpu->h_tbit_set (opval);
1115   }
1116 }
1117
1118   current_cpu->done_insn (npc, status);
1119 #undef FLD
1120 }
1121
1122 // ********** extsb-compact: exts.b $rm, $rn
1123
1124 void
1125 sh2_sem_extsb_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1126         sh2::write_stacks &buf)
1127 {
1128 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
1129   sem_status status = SEM_STATUS_NORMAL;
1130   sh2_scache* abuf = sem;
1131   unsigned long long written = 0;
1132   PCADDR pc = abuf->addr;
1133   PCADDR npc = pc + 2;
1134
1135   {
1136     SI opval = EXTQISI (SUBWORDSIQI (current_cpu->h_grc_get (FLD (f_rm)), 3));
1137     if (UNLIKELY(current_cpu->trace_result_p))
1138       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1139     current_cpu->h_grc_set (FLD (f_rn), opval);
1140   }
1141
1142   current_cpu->done_insn (npc, status);
1143 #undef FLD
1144 }
1145
1146 // ********** extsw-compact: exts.w $rm, $rn
1147
1148 void
1149 sh2_sem_extsw_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1150         sh2::write_stacks &buf)
1151 {
1152 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
1153   sem_status status = SEM_STATUS_NORMAL;
1154   sh2_scache* abuf = sem;
1155   unsigned long long written = 0;
1156   PCADDR pc = abuf->addr;
1157   PCADDR npc = pc + 2;
1158
1159   {
1160     SI opval = EXTHISI (SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1));
1161     if (UNLIKELY(current_cpu->trace_result_p))
1162       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1163     current_cpu->h_grc_set (FLD (f_rn), opval);
1164   }
1165
1166   current_cpu->done_insn (npc, status);
1167 #undef FLD
1168 }
1169
1170 // ********** extub-compact: extu.b $rm, $rn
1171
1172 void
1173 sh2_sem_extub_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1174         sh2::write_stacks &buf)
1175 {
1176 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
1177   sem_status status = SEM_STATUS_NORMAL;
1178   sh2_scache* abuf = sem;
1179   unsigned long long written = 0;
1180   PCADDR pc = abuf->addr;
1181   PCADDR npc = pc + 2;
1182
1183   {
1184     SI opval = ZEXTQISI (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 // ********** extuw-compact: extu.w $rm, $rn
1195
1196 void
1197 sh2_sem_extuw_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1198         sh2::write_stacks &buf)
1199 {
1200 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
1201   sem_status status = SEM_STATUS_NORMAL;
1202   sh2_scache* abuf = sem;
1203   unsigned long long written = 0;
1204   PCADDR pc = abuf->addr;
1205   PCADDR npc = pc + 2;
1206
1207   {
1208     SI opval = ZEXTHISI (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 // ********** frchg-compact: frchg
1219
1220 void
1221 sh2_sem_frchg_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1222         sh2::write_stacks &buf)
1223 {
1224 #define FLD(f) abuf->fields.fmt_empty.f
1225   sem_status status = SEM_STATUS_NORMAL;
1226   sh2_scache* abuf = sem;
1227   unsigned long long written = 0;
1228   PCADDR pc = abuf->addr;
1229   PCADDR npc = pc + 2;
1230
1231   {
1232     BI opval = NOTBI (current_cpu->h_frbit_get ());
1233     if (UNLIKELY(current_cpu->trace_result_p))
1234       current_cpu->trace_stream << "frbit" << ":=0x" << hex << opval << dec << "  ";
1235     current_cpu->h_frbit_set (opval);
1236   }
1237
1238   current_cpu->done_insn (npc, status);
1239 #undef FLD
1240 }
1241
1242 // ********** fschg-compact: fschg
1243
1244 void
1245 sh2_sem_fschg_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1246         sh2::write_stacks &buf)
1247 {
1248 #define FLD(f) abuf->fields.fmt_empty.f
1249   sem_status status = SEM_STATUS_NORMAL;
1250   sh2_scache* abuf = sem;
1251   unsigned long long written = 0;
1252   PCADDR pc = abuf->addr;
1253   PCADDR npc = pc + 2;
1254
1255   {
1256     BI opval = NOTBI (current_cpu->h_szbit_get ());
1257     if (UNLIKELY(current_cpu->trace_result_p))
1258       current_cpu->trace_stream << "szbit" << ":=0x" << hex << opval << dec << "  ";
1259     current_cpu->h_szbit_set (opval);
1260   }
1261
1262   current_cpu->done_insn (npc, status);
1263 #undef FLD
1264 }
1265
1266 // ********** jmp-compact: jmp @$rn
1267
1268 void
1269 sh2_sem_jmp_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1270         sh2::write_stacks &buf)
1271 {
1272 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1273   sem_status status = SEM_STATUS_NORMAL;
1274   sh2_scache* abuf = sem;
1275   unsigned long long written = 0;
1276   PCADDR pc = abuf->addr;
1277   PCADDR npc = pc + 2;
1278
1279 {
1280   {
1281     UDI opval = ADDDI (pc, 2);
1282     if (UNLIKELY(current_cpu->trace_result_p))
1283       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
1284     current_cpu->branch (opval, npc, status);
1285   }
1286 current_cpu->save_delayed_pc (current_cpu->h_grc_get (FLD (f_rn)));
1287   {
1288     UDI opval = current_cpu->h_grc_get (FLD (f_rn));
1289     buf.h_pc_writes [(tick + 1) % sh2::pipe_sz].push (sh2::write<UDI>(pc, opval));
1290     if (UNLIKELY(current_cpu->trace_result_p))
1291       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
1292   }
1293 current_cpu->cg_profile (pc, current_cpu->h_grc_get (FLD (f_rn)));
1294 }
1295
1296   current_cpu->done_cti_insn (npc, status);
1297 #undef FLD
1298 }
1299
1300 // ********** jsr-compact: jsr @$rn
1301
1302 void
1303 sh2_sem_jsr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1304         sh2::write_stacks &buf)
1305 {
1306 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1307   sem_status status = SEM_STATUS_NORMAL;
1308   sh2_scache* abuf = sem;
1309   unsigned long long written = 0;
1310   PCADDR pc = abuf->addr;
1311   PCADDR npc = pc + 2;
1312
1313 {
1314   {
1315     SI opval = ADDDI (pc, 4);
1316     buf.h_pr_writes [(tick + 1) % sh2::pipe_sz].push (sh2::write<SI>(pc, opval));
1317     if (UNLIKELY(current_cpu->trace_result_p))
1318       current_cpu->trace_stream << "pr" << ":=0x" << hex << opval << dec << "  ";
1319   }
1320   {
1321     UDI opval = ADDDI (pc, 2);
1322     if (UNLIKELY(current_cpu->trace_result_p))
1323       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
1324     current_cpu->branch (opval, npc, status);
1325   }
1326 current_cpu->save_delayed_pc (current_cpu->h_grc_get (FLD (f_rn)));
1327   {
1328     UDI opval = current_cpu->h_grc_get (FLD (f_rn));
1329     buf.h_pc_writes [(tick + 1) % sh2::pipe_sz].push (sh2::write<UDI>(pc, opval));
1330     if (UNLIKELY(current_cpu->trace_result_p))
1331       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
1332   }
1333 current_cpu->cg_profile (pc, current_cpu->h_grc_get (FLD (f_rn)));
1334 }
1335
1336   current_cpu->done_cti_insn (npc, status);
1337 #undef FLD
1338 }
1339
1340 // ********** ldc-gbr-compact: ldc $rn, gbr
1341
1342 void
1343 sh2_sem_ldc_gbr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1344         sh2::write_stacks &buf)
1345 {
1346 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1347   sem_status status = SEM_STATUS_NORMAL;
1348   sh2_scache* abuf = sem;
1349   unsigned long long written = 0;
1350   PCADDR pc = abuf->addr;
1351   PCADDR npc = pc + 2;
1352
1353   {
1354     SI opval = current_cpu->h_grc_get (FLD (f_rn));
1355     if (UNLIKELY(current_cpu->trace_result_p))
1356       current_cpu->trace_stream << "gbr" << ":=0x" << hex << opval << dec << "  ";
1357     current_cpu->h_gbr_set (opval);
1358   }
1359
1360   current_cpu->done_insn (npc, status);
1361 #undef FLD
1362 }
1363
1364 // ********** ldc-vbr-compact: ldc $rn, vbr
1365
1366 void
1367 sh2_sem_ldc_vbr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1368         sh2::write_stacks &buf)
1369 {
1370 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1371   sem_status status = SEM_STATUS_NORMAL;
1372   sh2_scache* abuf = sem;
1373   unsigned long long written = 0;
1374   PCADDR pc = abuf->addr;
1375   PCADDR npc = pc + 2;
1376
1377   {
1378     SI opval = current_cpu->h_grc_get (FLD (f_rn));
1379     if (UNLIKELY(current_cpu->trace_result_p))
1380       current_cpu->trace_stream << "vbr" << ":=0x" << hex << opval << dec << "  ";
1381     current_cpu->h_vbr_set (opval);
1382   }
1383
1384   current_cpu->done_insn (npc, status);
1385 #undef FLD
1386 }
1387
1388 // ********** ldc-sr-compact: ldc $rn, sr
1389
1390 void
1391 sh2_sem_ldc_sr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1392         sh2::write_stacks &buf)
1393 {
1394 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1395   sem_status status = SEM_STATUS_NORMAL;
1396   sh2_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 << "sr" << ":=0x" << hex << opval << dec << "  ";
1405     current_cpu->hardware.h_sr = opval;
1406   }
1407
1408   current_cpu->done_insn (npc, status);
1409 #undef FLD
1410 }
1411
1412 // ********** ldcl-gbr-compact: ldc.l @${rn}+, gbr
1413
1414 void
1415 sh2_sem_ldcl_gbr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1416         sh2::write_stacks &buf)
1417 {
1418 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1419   sem_status status = SEM_STATUS_NORMAL;
1420   sh2_scache* abuf = sem;
1421   unsigned long long written = 0;
1422   PCADDR pc = abuf->addr;
1423   PCADDR npc = pc + 2;
1424
1425 {
1426   {
1427     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1428     if (UNLIKELY(current_cpu->trace_result_p))
1429       current_cpu->trace_stream << "gbr" << ":=0x" << hex << opval << dec << "  ";
1430     current_cpu->h_gbr_set (opval);
1431   }
1432   {
1433     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1434     if (UNLIKELY(current_cpu->trace_result_p))
1435       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1436     current_cpu->h_grc_set (FLD (f_rn), opval);
1437   }
1438 }
1439
1440   current_cpu->done_insn (npc, status);
1441 #undef FLD
1442 }
1443
1444 // ********** ldcl-vbr-compact: ldc.l @${rn}+, vbr
1445
1446 void
1447 sh2_sem_ldcl_vbr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1448         sh2::write_stacks &buf)
1449 {
1450 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1451   sem_status status = SEM_STATUS_NORMAL;
1452   sh2_scache* abuf = sem;
1453   unsigned long long written = 0;
1454   PCADDR pc = abuf->addr;
1455   PCADDR npc = pc + 2;
1456
1457 {
1458   {
1459     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1460     if (UNLIKELY(current_cpu->trace_result_p))
1461       current_cpu->trace_stream << "vbr" << ":=0x" << hex << opval << dec << "  ";
1462     current_cpu->h_vbr_set (opval);
1463   }
1464   {
1465     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1466     if (UNLIKELY(current_cpu->trace_result_p))
1467       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1468     current_cpu->h_grc_set (FLD (f_rn), opval);
1469   }
1470 }
1471
1472   current_cpu->done_insn (npc, status);
1473 #undef FLD
1474 }
1475
1476 // ********** lds-mach-compact: lds $rn, mach
1477
1478 void
1479 sh2_sem_lds_mach_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1480         sh2::write_stacks &buf)
1481 {
1482 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1483   sem_status status = SEM_STATUS_NORMAL;
1484   sh2_scache* abuf = sem;
1485   unsigned long long written = 0;
1486   PCADDR pc = abuf->addr;
1487   PCADDR npc = pc + 2;
1488
1489   {
1490     SI opval = current_cpu->h_grc_get (FLD (f_rn));
1491     if (UNLIKELY(current_cpu->trace_result_p))
1492       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1493     current_cpu->h_mach_set (opval);
1494   }
1495
1496   current_cpu->done_insn (npc, status);
1497 #undef FLD
1498 }
1499
1500 // ********** ldsl-mach-compact: lds.l @${rn}+, mach
1501
1502 void
1503 sh2_sem_ldsl_mach_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1504         sh2::write_stacks &buf)
1505 {
1506 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1507   sem_status status = SEM_STATUS_NORMAL;
1508   sh2_scache* abuf = sem;
1509   unsigned long long written = 0;
1510   PCADDR pc = abuf->addr;
1511   PCADDR npc = pc + 2;
1512
1513 {
1514   {
1515     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1516     if (UNLIKELY(current_cpu->trace_result_p))
1517       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1518     current_cpu->h_mach_set (opval);
1519   }
1520   {
1521     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1522     if (UNLIKELY(current_cpu->trace_result_p))
1523       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1524     current_cpu->h_grc_set (FLD (f_rn), opval);
1525   }
1526 }
1527
1528   current_cpu->done_insn (npc, status);
1529 #undef FLD
1530 }
1531
1532 // ********** lds-macl-compact: lds $rn, macl
1533
1534 void
1535 sh2_sem_lds_macl_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1536         sh2::write_stacks &buf)
1537 {
1538 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1539   sem_status status = SEM_STATUS_NORMAL;
1540   sh2_scache* abuf = sem;
1541   unsigned long long written = 0;
1542   PCADDR pc = abuf->addr;
1543   PCADDR npc = pc + 2;
1544
1545   {
1546     SI opval = current_cpu->h_grc_get (FLD (f_rn));
1547     if (UNLIKELY(current_cpu->trace_result_p))
1548       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1549     current_cpu->h_macl_set (opval);
1550   }
1551
1552   current_cpu->done_insn (npc, status);
1553 #undef FLD
1554 }
1555
1556 // ********** ldsl-macl-compact: lds.l @${rn}+, macl
1557
1558 void
1559 sh2_sem_ldsl_macl_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1560         sh2::write_stacks &buf)
1561 {
1562 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1563   sem_status status = SEM_STATUS_NORMAL;
1564   sh2_scache* abuf = sem;
1565   unsigned long long written = 0;
1566   PCADDR pc = abuf->addr;
1567   PCADDR npc = pc + 2;
1568
1569 {
1570   {
1571     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1572     if (UNLIKELY(current_cpu->trace_result_p))
1573       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1574     current_cpu->h_macl_set (opval);
1575   }
1576   {
1577     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1578     if (UNLIKELY(current_cpu->trace_result_p))
1579       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1580     current_cpu->h_grc_set (FLD (f_rn), opval);
1581   }
1582 }
1583
1584   current_cpu->done_insn (npc, status);
1585 #undef FLD
1586 }
1587
1588 // ********** lds-pr-compact: lds $rn, pr
1589
1590 void
1591 sh2_sem_lds_pr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1592         sh2::write_stacks &buf)
1593 {
1594 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1595   sem_status status = SEM_STATUS_NORMAL;
1596   sh2_scache* abuf = sem;
1597   unsigned long long written = 0;
1598   PCADDR pc = abuf->addr;
1599   PCADDR npc = pc + 2;
1600
1601   {
1602     SI opval = current_cpu->h_grc_get (FLD (f_rn));
1603     if (UNLIKELY(current_cpu->trace_result_p))
1604       current_cpu->trace_stream << "pr" << ":=0x" << hex << opval << dec << "  ";
1605     current_cpu->h_pr_set (opval);
1606   }
1607
1608   current_cpu->done_insn (npc, status);
1609 #undef FLD
1610 }
1611
1612 // ********** ldsl-pr-compact: lds.l @${rn}+, pr
1613
1614 void
1615 sh2_sem_ldsl_pr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1616         sh2::write_stacks &buf)
1617 {
1618 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1619   sem_status status = SEM_STATUS_NORMAL;
1620   sh2_scache* abuf = sem;
1621   unsigned long long written = 0;
1622   PCADDR pc = abuf->addr;
1623   PCADDR npc = pc + 2;
1624
1625 {
1626   {
1627     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1628     if (UNLIKELY(current_cpu->trace_result_p))
1629       current_cpu->trace_stream << "pr" << ":=0x" << hex << opval << dec << "  ";
1630     current_cpu->h_pr_set (opval);
1631   }
1632   {
1633     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1634     if (UNLIKELY(current_cpu->trace_result_p))
1635       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1636     current_cpu->h_grc_set (FLD (f_rn), opval);
1637   }
1638 }
1639
1640   current_cpu->done_insn (npc, status);
1641 #undef FLD
1642 }
1643
1644 // ********** macl-compact: mac.l @${rm}+, @${rn}+
1645
1646 void
1647 sh2_sem_macl_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1648         sh2::write_stacks &buf)
1649 {
1650 #define FLD(f) abuf->fields.sfmt_macl_compact.f
1651   sem_status status = SEM_STATUS_NORMAL;
1652   sh2_scache* abuf = sem;
1653   unsigned long long written = 0;
1654   PCADDR pc = abuf->addr;
1655   PCADDR npc = pc + 2;
1656
1657 {
1658   DI tmp_tmpry;
1659   DI tmp_mac;
1660   DI tmp_result;
1661   SI tmp_x;
1662   SI tmp_y;
1663   tmp_x = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1664   {
1665     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1666     if (UNLIKELY(current_cpu->trace_result_p))
1667       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1668     current_cpu->h_grc_set (FLD (f_rn), opval);
1669   }
1670 if (EQSI (FLD (f_rn), FLD (f_rm))) {
1671 {
1672   {
1673     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1674     if (UNLIKELY(current_cpu->trace_result_p))
1675       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1676     current_cpu->h_grc_set (FLD (f_rn), opval);
1677   }
1678   {
1679     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 4);
1680     written |= (1ULL << 11);
1681     if (UNLIKELY(current_cpu->trace_result_p))
1682       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
1683     current_cpu->h_grc_set (FLD (f_rm), opval);
1684   }
1685 }
1686 }
1687   tmp_y = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rm)));
1688   {
1689     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 4);
1690     written |= (1ULL << 11);
1691     if (UNLIKELY(current_cpu->trace_result_p))
1692       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
1693     current_cpu->h_grc_set (FLD (f_rm), opval);
1694   }
1695   tmp_tmpry = MULDI (ZEXTSIDI (tmp_x), ZEXTSIDI (tmp_y));
1696   tmp_mac = ORDI (SLLDI (ZEXTSIDI (current_cpu->h_mach_get ()), 32), ZEXTSIDI (current_cpu->h_macl_get ()));
1697   tmp_result = ADDDI (tmp_mac, tmp_tmpry);
1698 {
1699 if (current_cpu->h_sbit_get ()) {
1700 {
1701   SI tmp_min;
1702   SI tmp_max;
1703   tmp_max = SRLDI (INVDI (0), 16);
1704   tmp_min = SRLDI (INVDI (0), 15);
1705 if (GTDI (tmp_result, tmp_max)) {
1706   tmp_result = tmp_max;
1707 } else {
1708 if (LTDI (tmp_result, tmp_min)) {
1709   tmp_result = tmp_min;
1710 }
1711 }
1712 }
1713 }
1714   {
1715     SI opval = SUBWORDDISI (tmp_result, 0);
1716     if (UNLIKELY(current_cpu->trace_result_p))
1717       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1718     current_cpu->h_mach_set (opval);
1719   }
1720   {
1721     SI opval = SUBWORDDISI (tmp_result, 1);
1722     if (UNLIKELY(current_cpu->trace_result_p))
1723       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1724     current_cpu->h_macl_set (opval);
1725   }
1726 }
1727 }
1728
1729   abuf->written = written;
1730   current_cpu->done_insn (npc, status);
1731 #undef FLD
1732 }
1733
1734 // ********** macw-compact: mac.w @${rm}+, @${rn}+
1735
1736 void
1737 sh2_sem_macw_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1738         sh2::write_stacks &buf)
1739 {
1740 #define FLD(f) abuf->fields.sfmt_macl_compact.f
1741   sem_status status = SEM_STATUS_NORMAL;
1742   sh2_scache* abuf = sem;
1743   unsigned long long written = 0;
1744   PCADDR pc = abuf->addr;
1745   PCADDR npc = pc + 2;
1746
1747 {
1748   SI tmp_tmpry;
1749   DI tmp_mac;
1750   DI tmp_result;
1751   HI tmp_x;
1752   HI tmp_y;
1753   tmp_x = current_cpu->GETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rn)));
1754   {
1755     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
1756     if (UNLIKELY(current_cpu->trace_result_p))
1757       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1758     current_cpu->h_grc_set (FLD (f_rn), opval);
1759   }
1760 if (EQSI (FLD (f_rn), FLD (f_rm))) {
1761 {
1762   {
1763     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
1764     if (UNLIKELY(current_cpu->trace_result_p))
1765       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1766     current_cpu->h_grc_set (FLD (f_rn), opval);
1767   }
1768   {
1769     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 2);
1770     written |= (1ULL << 11);
1771     if (UNLIKELY(current_cpu->trace_result_p))
1772       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
1773     current_cpu->h_grc_set (FLD (f_rm), opval);
1774   }
1775 }
1776 }
1777   tmp_y = current_cpu->GETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rm)));
1778   {
1779     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 2);
1780     written |= (1ULL << 11);
1781     if (UNLIKELY(current_cpu->trace_result_p))
1782       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
1783     current_cpu->h_grc_set (FLD (f_rm), opval);
1784   }
1785   tmp_tmpry = MULSI (ZEXTHISI (tmp_x), ZEXTHISI (tmp_y));
1786 if (current_cpu->h_sbit_get ()) {
1787 {
1788 if (ADDOFSI (tmp_tmpry, current_cpu->h_macl_get (), 0)) {
1789   {
1790     SI opval = 1;
1791     written |= (1ULL << 9);
1792     if (UNLIKELY(current_cpu->trace_result_p))
1793       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1794     current_cpu->h_mach_set (opval);
1795   }
1796 }
1797   {
1798     SI opval = ADDSI (tmp_tmpry, current_cpu->h_macl_get ());
1799     written |= (1ULL << 10);
1800     if (UNLIKELY(current_cpu->trace_result_p))
1801       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1802     current_cpu->h_macl_set (opval);
1803   }
1804 }
1805 } else {
1806 {
1807   tmp_mac = ORDI (SLLDI (ZEXTSIDI (current_cpu->h_mach_get ()), 32), ZEXTSIDI (current_cpu->h_macl_get ()));
1808   tmp_result = ADDDI (tmp_mac, EXTSIDI (tmp_tmpry));
1809   {
1810     SI opval = SUBWORDDISI (tmp_result, 0);
1811     written |= (1ULL << 9);
1812     if (UNLIKELY(current_cpu->trace_result_p))
1813       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
1814     current_cpu->h_mach_set (opval);
1815   }
1816   {
1817     SI opval = SUBWORDDISI (tmp_result, 1);
1818     written |= (1ULL << 10);
1819     if (UNLIKELY(current_cpu->trace_result_p))
1820       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
1821     current_cpu->h_macl_set (opval);
1822   }
1823 }
1824 }
1825 }
1826
1827   abuf->written = written;
1828   current_cpu->done_insn (npc, status);
1829 #undef FLD
1830 }
1831
1832 // ********** mov-compact: mov $rm64, $rn64
1833
1834 void
1835 sh2_sem_mov_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1836         sh2::write_stacks &buf)
1837 {
1838 #define FLD(f) abuf->fields.sfmt_and_compact.f
1839   sem_status status = SEM_STATUS_NORMAL;
1840   sh2_scache* abuf = sem;
1841   unsigned long long written = 0;
1842   PCADDR pc = abuf->addr;
1843   PCADDR npc = pc + 2;
1844
1845   {
1846     DI opval = current_cpu->h_gr_get (FLD (f_rm));
1847     if (UNLIKELY(current_cpu->trace_result_p))
1848       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1849     current_cpu->h_gr_set (FLD (f_rn), opval);
1850   }
1851
1852   current_cpu->done_insn (npc, status);
1853 #undef FLD
1854 }
1855
1856 // ********** movi-compact: mov #$imm8, $rn
1857
1858 void
1859 sh2_sem_movi_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1860         sh2::write_stacks &buf)
1861 {
1862 #define FLD(f) abuf->fields.sfmt_addi_compact.f
1863   sem_status status = SEM_STATUS_NORMAL;
1864   sh2_scache* abuf = sem;
1865   unsigned long long written = 0;
1866   PCADDR pc = abuf->addr;
1867   PCADDR npc = pc + 2;
1868
1869   {
1870     SI opval = EXTQIDI (ANDQI (FLD (f_imm8), 255));
1871     if (UNLIKELY(current_cpu->trace_result_p))
1872       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1873     current_cpu->h_grc_set (FLD (f_rn), opval);
1874   }
1875
1876   current_cpu->done_insn (npc, status);
1877 #undef FLD
1878 }
1879
1880 // ********** movb1-compact: mov.b $rm, @$rn
1881
1882 void
1883 sh2_sem_movb1_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1884         sh2::write_stacks &buf)
1885 {
1886 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
1887   sem_status status = SEM_STATUS_NORMAL;
1888   sh2_scache* abuf = sem;
1889   unsigned long long written = 0;
1890   PCADDR pc = abuf->addr;
1891   PCADDR npc = pc + 2;
1892
1893   {
1894     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (FLD (f_rm)), 3);
1895     if (UNLIKELY(current_cpu->trace_result_p))
1896       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
1897     current_cpu->SETMEMUQI (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
1898   }
1899
1900   current_cpu->done_insn (npc, status);
1901 #undef FLD
1902 }
1903
1904 // ********** movb2-compact: mov.b $rm, @-$rn
1905
1906 void
1907 sh2_sem_movb2_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1908         sh2::write_stacks &buf)
1909 {
1910 #define FLD(f) abuf->fields.sfmt_macl_compact.f
1911   sem_status status = SEM_STATUS_NORMAL;
1912   sh2_scache* abuf = sem;
1913   unsigned long long written = 0;
1914   PCADDR pc = abuf->addr;
1915   PCADDR npc = pc + 2;
1916
1917 {
1918   DI tmp_addr;
1919   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
1920   {
1921     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (FLD (f_rm)), 3);
1922     if (UNLIKELY(current_cpu->trace_result_p))
1923       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
1924     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
1925   }
1926   {
1927     SI opval = tmp_addr;
1928     if (UNLIKELY(current_cpu->trace_result_p))
1929       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1930     current_cpu->h_grc_set (FLD (f_rn), opval);
1931   }
1932 }
1933
1934   current_cpu->done_insn (npc, status);
1935 #undef FLD
1936 }
1937
1938 // ********** movb3-compact: mov.b $rm, @(r0,$rn)
1939
1940 void
1941 sh2_sem_movb3_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1942         sh2::write_stacks &buf)
1943 {
1944 #define FLD(f) abuf->fields.sfmt_movb3_compact.f
1945   sem_status status = SEM_STATUS_NORMAL;
1946   sh2_scache* abuf = sem;
1947   unsigned long long written = 0;
1948   PCADDR pc = abuf->addr;
1949   PCADDR npc = pc + 2;
1950
1951   {
1952     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (FLD (f_rm)), 3);
1953     if (UNLIKELY(current_cpu->trace_result_p))
1954       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 << "  ";
1955     current_cpu->SETMEMUQI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))), opval);
1956   }
1957
1958   current_cpu->done_insn (npc, status);
1959 #undef FLD
1960 }
1961
1962 // ********** movb4-compact: mov.b r0, @($imm8, gbr)
1963
1964 void
1965 sh2_sem_movb4_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1966         sh2::write_stacks &buf)
1967 {
1968 #define FLD(f) abuf->fields.sfmt_andi_compact.f
1969   sem_status status = SEM_STATUS_NORMAL;
1970   sh2_scache* abuf = sem;
1971   unsigned long long written = 0;
1972   PCADDR pc = abuf->addr;
1973   PCADDR npc = pc + 2;
1974
1975 {
1976   DI tmp_addr;
1977   tmp_addr = ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8));
1978   {
1979     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (((UINT) 0)), 3);
1980     if (UNLIKELY(current_cpu->trace_result_p))
1981       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
1982     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
1983   }
1984 }
1985
1986   current_cpu->done_insn (npc, status);
1987 #undef FLD
1988 }
1989
1990 // ********** movb5-compact: mov.b r0, @($imm4, $rm)
1991
1992 void
1993 sh2_sem_movb5_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
1994         sh2::write_stacks &buf)
1995 {
1996 #define FLD(f) abuf->fields.sfmt_movb5_compact.f
1997   sem_status status = SEM_STATUS_NORMAL;
1998   sh2_scache* abuf = sem;
1999   unsigned long long written = 0;
2000   PCADDR pc = abuf->addr;
2001   PCADDR npc = pc + 2;
2002
2003 {
2004   DI tmp_addr;
2005   tmp_addr = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4));
2006   {
2007     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (((UINT) 0)), 3);
2008     if (UNLIKELY(current_cpu->trace_result_p))
2009       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
2010     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
2011   }
2012 }
2013
2014   current_cpu->done_insn (npc, status);
2015 #undef FLD
2016 }
2017
2018 // ********** movb6-compact: mov.b @$rm, $rn
2019
2020 void
2021 sh2_sem_movb6_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2022         sh2::write_stacks &buf)
2023 {
2024 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
2025   sem_status status = SEM_STATUS_NORMAL;
2026   sh2_scache* abuf = sem;
2027   unsigned long long written = 0;
2028   PCADDR pc = abuf->addr;
2029   PCADDR npc = pc + 2;
2030
2031   {
2032     SI opval = EXTQISI (current_cpu->GETMEMQI (pc, current_cpu->h_grc_get (FLD (f_rm))));
2033     if (UNLIKELY(current_cpu->trace_result_p))
2034       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2035     current_cpu->h_grc_set (FLD (f_rn), opval);
2036   }
2037
2038   current_cpu->done_insn (npc, status);
2039 #undef FLD
2040 }
2041
2042 // ********** movb7-compact: mov.b @${rm}+, $rn
2043
2044 void
2045 sh2_sem_movb7_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2046         sh2::write_stacks &buf)
2047 {
2048 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2049   sem_status status = SEM_STATUS_NORMAL;
2050   sh2_scache* abuf = sem;
2051   unsigned long long written = 0;
2052   PCADDR pc = abuf->addr;
2053   PCADDR npc = pc + 2;
2054
2055 {
2056   QI tmp_data;
2057   tmp_data = current_cpu->GETMEMQI (pc, current_cpu->h_grc_get (FLD (f_rm)));
2058 if (EQSI (FLD (f_rm), FLD (f_rn))) {
2059   {
2060     SI opval = EXTQISI (tmp_data);
2061     written |= (1ULL << 4);
2062     if (UNLIKELY(current_cpu->trace_result_p))
2063       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2064     current_cpu->h_grc_set (FLD (f_rm), opval);
2065   }
2066 } else {
2067   {
2068     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 1);
2069     written |= (1ULL << 4);
2070     if (UNLIKELY(current_cpu->trace_result_p))
2071       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2072     current_cpu->h_grc_set (FLD (f_rm), opval);
2073   }
2074 }
2075   {
2076     SI opval = EXTQISI (tmp_data);
2077     if (UNLIKELY(current_cpu->trace_result_p))
2078       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2079     current_cpu->h_grc_set (FLD (f_rn), opval);
2080   }
2081 }
2082
2083   abuf->written = written;
2084   current_cpu->done_insn (npc, status);
2085 #undef FLD
2086 }
2087
2088 // ********** movb8-compact: mov.b @(r0, $rm), $rn
2089
2090 void
2091 sh2_sem_movb8_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2092         sh2::write_stacks &buf)
2093 {
2094 #define FLD(f) abuf->fields.sfmt_movb8_compact.f
2095   sem_status status = SEM_STATUS_NORMAL;
2096   sh2_scache* abuf = sem;
2097   unsigned long long written = 0;
2098   PCADDR pc = abuf->addr;
2099   PCADDR npc = pc + 2;
2100
2101   {
2102     SI opval = EXTQISI (current_cpu->GETMEMQI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rm)))));
2103     if (UNLIKELY(current_cpu->trace_result_p))
2104       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2105     current_cpu->h_grc_set (FLD (f_rn), opval);
2106   }
2107
2108   current_cpu->done_insn (npc, status);
2109 #undef FLD
2110 }
2111
2112 // ********** movb9-compact: mov.b @($imm8, gbr), r0
2113
2114 void
2115 sh2_sem_movb9_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2116         sh2::write_stacks &buf)
2117 {
2118 #define FLD(f) abuf->fields.sfmt_andi_compact.f
2119   sem_status status = SEM_STATUS_NORMAL;
2120   sh2_scache* abuf = sem;
2121   unsigned long long written = 0;
2122   PCADDR pc = abuf->addr;
2123   PCADDR npc = pc + 2;
2124
2125   {
2126     SI opval = EXTQISI (current_cpu->GETMEMQI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8))));
2127     if (UNLIKELY(current_cpu->trace_result_p))
2128       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2129     current_cpu->h_grc_set (((UINT) 0), opval);
2130   }
2131
2132   current_cpu->done_insn (npc, status);
2133 #undef FLD
2134 }
2135
2136 // ********** movb10-compact: mov.b @($imm4, $rm), r0
2137
2138 void
2139 sh2_sem_movb10_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2140         sh2::write_stacks &buf)
2141 {
2142 #define FLD(f) abuf->fields.sfmt_movb10_compact.f
2143   sem_status status = SEM_STATUS_NORMAL;
2144   sh2_scache* abuf = sem;
2145   unsigned long long written = 0;
2146   PCADDR pc = abuf->addr;
2147   PCADDR npc = pc + 2;
2148
2149   {
2150     SI opval = EXTQISI (current_cpu->GETMEMQI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4))));
2151     if (UNLIKELY(current_cpu->trace_result_p))
2152       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2153     current_cpu->h_grc_set (((UINT) 0), opval);
2154   }
2155
2156   current_cpu->done_insn (npc, status);
2157 #undef FLD
2158 }
2159
2160 // ********** movl1-compact: mov.l $rm, @$rn
2161
2162 void
2163 sh2_sem_movl1_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2164         sh2::write_stacks &buf)
2165 {
2166 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
2167   sem_status status = SEM_STATUS_NORMAL;
2168   sh2_scache* abuf = sem;
2169   unsigned long long written = 0;
2170   PCADDR pc = abuf->addr;
2171   PCADDR npc = pc + 2;
2172
2173   {
2174     SI opval = current_cpu->h_grc_get (FLD (f_rm));
2175     if (UNLIKELY(current_cpu->trace_result_p))
2176       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2177     current_cpu->SETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
2178   }
2179
2180   current_cpu->done_insn (npc, status);
2181 #undef FLD
2182 }
2183
2184 // ********** movl2-compact: mov.l $rm, @-$rn
2185
2186 void
2187 sh2_sem_movl2_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2188         sh2::write_stacks &buf)
2189 {
2190 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2191   sem_status status = SEM_STATUS_NORMAL;
2192   sh2_scache* abuf = sem;
2193   unsigned long long written = 0;
2194   PCADDR pc = abuf->addr;
2195   PCADDR npc = pc + 2;
2196
2197 {
2198   SI tmp_addr;
2199   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
2200   {
2201     SI opval = current_cpu->h_grc_get (FLD (f_rm));
2202     if (UNLIKELY(current_cpu->trace_result_p))
2203       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2204     current_cpu->SETMEMSI (pc, tmp_addr, opval);
2205   }
2206   {
2207     SI opval = tmp_addr;
2208     if (UNLIKELY(current_cpu->trace_result_p))
2209       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2210     current_cpu->h_grc_set (FLD (f_rn), opval);
2211   }
2212 }
2213
2214   current_cpu->done_insn (npc, status);
2215 #undef FLD
2216 }
2217
2218 // ********** movl3-compact: mov.l $rm, @(r0, $rn)
2219
2220 void
2221 sh2_sem_movl3_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2222         sh2::write_stacks &buf)
2223 {
2224 #define FLD(f) abuf->fields.sfmt_movb3_compact.f
2225   sem_status status = SEM_STATUS_NORMAL;
2226   sh2_scache* abuf = sem;
2227   unsigned long long written = 0;
2228   PCADDR pc = abuf->addr;
2229   PCADDR npc = pc + 2;
2230
2231   {
2232     SI opval = current_cpu->h_grc_get (FLD (f_rm));
2233     if (UNLIKELY(current_cpu->trace_result_p))
2234       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 << "  ";
2235     current_cpu->SETMEMSI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))), opval);
2236   }
2237
2238   current_cpu->done_insn (npc, status);
2239 #undef FLD
2240 }
2241
2242 // ********** movl4-compact: mov.l r0, @($imm8x4, gbr)
2243
2244 void
2245 sh2_sem_movl4_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2246         sh2::write_stacks &buf)
2247 {
2248 #define FLD(f) abuf->fields.sfmt_movl4_compact.f
2249   sem_status status = SEM_STATUS_NORMAL;
2250   sh2_scache* abuf = sem;
2251   unsigned long long written = 0;
2252   PCADDR pc = abuf->addr;
2253   PCADDR npc = pc + 2;
2254
2255   {
2256     SI opval = current_cpu->h_grc_get (((UINT) 0));
2257     if (UNLIKELY(current_cpu->trace_result_p))
2258       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x4)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2259     current_cpu->SETMEMSI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x4)), opval);
2260   }
2261
2262   current_cpu->done_insn (npc, status);
2263 #undef FLD
2264 }
2265
2266 // ********** movl5-compact: mov.l $rm, @($imm4x4, $rn)
2267
2268 void
2269 sh2_sem_movl5_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2270         sh2::write_stacks &buf)
2271 {
2272 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
2273   sem_status status = SEM_STATUS_NORMAL;
2274   sh2_scache* abuf = sem;
2275   unsigned long long written = 0;
2276   PCADDR pc = abuf->addr;
2277   PCADDR npc = pc + 2;
2278
2279   {
2280     SI opval = current_cpu->h_grc_get (FLD (f_rm));
2281     if (UNLIKELY(current_cpu->trace_result_p))
2282       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 << "  ";
2283     current_cpu->SETMEMSI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rn)), FLD (f_imm4x4)), opval);
2284   }
2285
2286   current_cpu->done_insn (npc, status);
2287 #undef FLD
2288 }
2289
2290 // ********** movl6-compact: mov.l @$rm, $rn
2291
2292 void
2293 sh2_sem_movl6_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2294         sh2::write_stacks &buf)
2295 {
2296 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
2297   sem_status status = SEM_STATUS_NORMAL;
2298   sh2_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->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rm)));
2305     if (UNLIKELY(current_cpu->trace_result_p))
2306       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2307     current_cpu->h_grc_set (FLD (f_rn), opval);
2308   }
2309
2310   current_cpu->done_insn (npc, status);
2311 #undef FLD
2312 }
2313
2314 // ********** movl7-compact: mov.l @${rm}+, $rn
2315
2316 void
2317 sh2_sem_movl7_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2318         sh2::write_stacks &buf)
2319 {
2320 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2321   sem_status status = SEM_STATUS_NORMAL;
2322   sh2_scache* abuf = sem;
2323   unsigned long long written = 0;
2324   PCADDR pc = abuf->addr;
2325   PCADDR npc = pc + 2;
2326
2327 {
2328   {
2329     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rm)));
2330     if (UNLIKELY(current_cpu->trace_result_p))
2331       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2332     current_cpu->h_grc_set (FLD (f_rn), opval);
2333   }
2334 if (EQSI (FLD (f_rm), FLD (f_rn))) {
2335   {
2336     SI opval = current_cpu->h_grc_get (FLD (f_rn));
2337     written |= (1ULL << 5);
2338     if (UNLIKELY(current_cpu->trace_result_p))
2339       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2340     current_cpu->h_grc_set (FLD (f_rm), opval);
2341   }
2342 } else {
2343   {
2344     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 4);
2345     written |= (1ULL << 5);
2346     if (UNLIKELY(current_cpu->trace_result_p))
2347       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2348     current_cpu->h_grc_set (FLD (f_rm), opval);
2349   }
2350 }
2351 }
2352
2353   abuf->written = written;
2354   current_cpu->done_insn (npc, status);
2355 #undef FLD
2356 }
2357
2358 // ********** movl8-compact: mov.l @(r0, $rm), $rn
2359
2360 void
2361 sh2_sem_movl8_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2362         sh2::write_stacks &buf)
2363 {
2364 #define FLD(f) abuf->fields.sfmt_movb8_compact.f
2365   sem_status status = SEM_STATUS_NORMAL;
2366   sh2_scache* abuf = sem;
2367   unsigned long long written = 0;
2368   PCADDR pc = abuf->addr;
2369   PCADDR npc = pc + 2;
2370
2371   {
2372     SI opval = current_cpu->GETMEMSI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rm))));
2373     if (UNLIKELY(current_cpu->trace_result_p))
2374       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2375     current_cpu->h_grc_set (FLD (f_rn), opval);
2376   }
2377
2378   current_cpu->done_insn (npc, status);
2379 #undef FLD
2380 }
2381
2382 // ********** movl9-compact: mov.l @($imm8x4, gbr), r0
2383
2384 void
2385 sh2_sem_movl9_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2386         sh2::write_stacks &buf)
2387 {
2388 #define FLD(f) abuf->fields.sfmt_movl9_compact.f
2389   sem_status status = SEM_STATUS_NORMAL;
2390   sh2_scache* abuf = sem;
2391   unsigned long long written = 0;
2392   PCADDR pc = abuf->addr;
2393   PCADDR npc = pc + 2;
2394
2395   {
2396     SI opval = current_cpu->GETMEMSI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x4)));
2397     if (UNLIKELY(current_cpu->trace_result_p))
2398       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2399     current_cpu->h_grc_set (((UINT) 0), opval);
2400   }
2401
2402   current_cpu->done_insn (npc, status);
2403 #undef FLD
2404 }
2405
2406 // ********** movl10-compact: mov.l @($imm8x4, pc), $rn
2407
2408 void
2409 sh2_sem_movl10_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2410         sh2::write_stacks &buf)
2411 {
2412 #define FLD(f) abuf->fields.sfmt_movl10_compact.f
2413   sem_status status = SEM_STATUS_NORMAL;
2414   sh2_scache* abuf = sem;
2415   unsigned long long written = 0;
2416   PCADDR pc = abuf->addr;
2417   PCADDR npc = pc + 2;
2418
2419   {
2420     SI opval = current_cpu->GETMEMSI (pc, ADDSI (FLD (f_imm8x4), ANDDI (ADDDI (pc, 4), INVSI (3))));
2421     if (UNLIKELY(current_cpu->trace_result_p))
2422       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2423     current_cpu->h_grc_set (FLD (f_rn), opval);
2424   }
2425
2426   current_cpu->done_insn (npc, status);
2427 #undef FLD
2428 }
2429
2430 // ********** movl11-compact: mov.l @($imm4x4, $rm), $rn
2431
2432 void
2433 sh2_sem_movl11_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2434         sh2::write_stacks &buf)
2435 {
2436 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
2437   sem_status status = SEM_STATUS_NORMAL;
2438   sh2_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 (FLD (f_rm)), FLD (f_imm4x4)));
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 // ********** movw1-compact: mov.w $rm, @$rn
2455
2456 void
2457 sh2_sem_movw1_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2458         sh2::write_stacks &buf)
2459 {
2460 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
2461   sem_status status = SEM_STATUS_NORMAL;
2462   sh2_scache* abuf = sem;
2463   unsigned long long written = 0;
2464   PCADDR pc = abuf->addr;
2465   PCADDR npc = pc + 2;
2466
2467   {
2468     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1);
2469     if (UNLIKELY(current_cpu->trace_result_p))
2470       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2471     current_cpu->SETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
2472   }
2473
2474   current_cpu->done_insn (npc, status);
2475 #undef FLD
2476 }
2477
2478 // ********** movw2-compact: mov.w $rm, @-$rn
2479
2480 void
2481 sh2_sem_movw2_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2482         sh2::write_stacks &buf)
2483 {
2484 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2485   sem_status status = SEM_STATUS_NORMAL;
2486   sh2_scache* abuf = sem;
2487   unsigned long long written = 0;
2488   PCADDR pc = abuf->addr;
2489   PCADDR npc = pc + 2;
2490
2491 {
2492   DI tmp_addr;
2493   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
2494   {
2495     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1);
2496     if (UNLIKELY(current_cpu->trace_result_p))
2497       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2498     current_cpu->SETMEMHI (pc, tmp_addr, opval);
2499   }
2500   {
2501     SI opval = tmp_addr;
2502     if (UNLIKELY(current_cpu->trace_result_p))
2503       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2504     current_cpu->h_grc_set (FLD (f_rn), opval);
2505   }
2506 }
2507
2508   current_cpu->done_insn (npc, status);
2509 #undef FLD
2510 }
2511
2512 // ********** movw3-compact: mov.w $rm, @(r0, $rn)
2513
2514 void
2515 sh2_sem_movw3_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2516         sh2::write_stacks &buf)
2517 {
2518 #define FLD(f) abuf->fields.sfmt_movb3_compact.f
2519   sem_status status = SEM_STATUS_NORMAL;
2520   sh2_scache* abuf = sem;
2521   unsigned long long written = 0;
2522   PCADDR pc = abuf->addr;
2523   PCADDR npc = pc + 2;
2524
2525   {
2526     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1);
2527     if (UNLIKELY(current_cpu->trace_result_p))
2528       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 << "  ";
2529     current_cpu->SETMEMHI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))), opval);
2530   }
2531
2532   current_cpu->done_insn (npc, status);
2533 #undef FLD
2534 }
2535
2536 // ********** movw4-compact: mov.w r0, @($imm8x2, gbr)
2537
2538 void
2539 sh2_sem_movw4_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2540         sh2::write_stacks &buf)
2541 {
2542 #define FLD(f) abuf->fields.sfmt_movw4_compact.f
2543   sem_status status = SEM_STATUS_NORMAL;
2544   sh2_scache* abuf = sem;
2545   unsigned long long written = 0;
2546   PCADDR pc = abuf->addr;
2547   PCADDR npc = pc + 2;
2548
2549   {
2550     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (((UINT) 0)), 1);
2551     if (UNLIKELY(current_cpu->trace_result_p))
2552       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x2)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
2553     current_cpu->SETMEMHI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x2)), opval);
2554   }
2555
2556   current_cpu->done_insn (npc, status);
2557 #undef FLD
2558 }
2559
2560 // ********** movw5-compact: mov.w r0, @($imm4x2, $rm)
2561
2562 void
2563 sh2_sem_movw5_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2564         sh2::write_stacks &buf)
2565 {
2566 #define FLD(f) abuf->fields.sfmt_movw5_compact.f
2567   sem_status status = SEM_STATUS_NORMAL;
2568   sh2_scache* abuf = sem;
2569   unsigned long long written = 0;
2570   PCADDR pc = abuf->addr;
2571   PCADDR npc = pc + 2;
2572
2573   {
2574     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (((UINT) 0)), 1);
2575     if (UNLIKELY(current_cpu->trace_result_p))
2576       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 << "  ";
2577     current_cpu->SETMEMHI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4x2)), opval);
2578   }
2579
2580   current_cpu->done_insn (npc, status);
2581 #undef FLD
2582 }
2583
2584 // ********** movw6-compact: mov.w @$rm, $rn
2585
2586 void
2587 sh2_sem_movw6_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2588         sh2::write_stacks &buf)
2589 {
2590 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
2591   sem_status status = SEM_STATUS_NORMAL;
2592   sh2_scache* abuf = sem;
2593   unsigned long long written = 0;
2594   PCADDR pc = abuf->addr;
2595   PCADDR npc = pc + 2;
2596
2597   {
2598     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rm))));
2599     if (UNLIKELY(current_cpu->trace_result_p))
2600       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2601     current_cpu->h_grc_set (FLD (f_rn), opval);
2602   }
2603
2604   current_cpu->done_insn (npc, status);
2605 #undef FLD
2606 }
2607
2608 // ********** movw7-compact: mov.w @${rm}+, $rn
2609
2610 void
2611 sh2_sem_movw7_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2612         sh2::write_stacks &buf)
2613 {
2614 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2615   sem_status status = SEM_STATUS_NORMAL;
2616   sh2_scache* abuf = sem;
2617   unsigned long long written = 0;
2618   PCADDR pc = abuf->addr;
2619   PCADDR npc = pc + 2;
2620
2621 {
2622   HI tmp_data;
2623   tmp_data = current_cpu->GETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rm)));
2624 if (EQSI (FLD (f_rm), FLD (f_rn))) {
2625   {
2626     SI opval = EXTHISI (tmp_data);
2627     written |= (1ULL << 4);
2628     if (UNLIKELY(current_cpu->trace_result_p))
2629       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2630     current_cpu->h_grc_set (FLD (f_rm), opval);
2631   }
2632 } else {
2633   {
2634     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 2);
2635     written |= (1ULL << 4);
2636     if (UNLIKELY(current_cpu->trace_result_p))
2637       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2638     current_cpu->h_grc_set (FLD (f_rm), opval);
2639   }
2640 }
2641   {
2642     SI opval = EXTHISI (tmp_data);
2643     if (UNLIKELY(current_cpu->trace_result_p))
2644       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2645     current_cpu->h_grc_set (FLD (f_rn), opval);
2646   }
2647 }
2648
2649   abuf->written = written;
2650   current_cpu->done_insn (npc, status);
2651 #undef FLD
2652 }
2653
2654 // ********** movw8-compact: mov.w @(r0, $rm), $rn
2655
2656 void
2657 sh2_sem_movw8_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2658         sh2::write_stacks &buf)
2659 {
2660 #define FLD(f) abuf->fields.sfmt_movb8_compact.f
2661   sem_status status = SEM_STATUS_NORMAL;
2662   sh2_scache* abuf = sem;
2663   unsigned long long written = 0;
2664   PCADDR pc = abuf->addr;
2665   PCADDR npc = pc + 2;
2666
2667   {
2668     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rm)))));
2669     if (UNLIKELY(current_cpu->trace_result_p))
2670       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2671     current_cpu->h_grc_set (FLD (f_rn), opval);
2672   }
2673
2674   current_cpu->done_insn (npc, status);
2675 #undef FLD
2676 }
2677
2678 // ********** movw9-compact: mov.w @($imm8x2, gbr), r0
2679
2680 void
2681 sh2_sem_movw9_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2682         sh2::write_stacks &buf)
2683 {
2684 #define FLD(f) abuf->fields.sfmt_movw9_compact.f
2685   sem_status status = SEM_STATUS_NORMAL;
2686   sh2_scache* abuf = sem;
2687   unsigned long long written = 0;
2688   PCADDR pc = abuf->addr;
2689   PCADDR npc = pc + 2;
2690
2691   {
2692     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x2))));
2693     if (UNLIKELY(current_cpu->trace_result_p))
2694       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2695     current_cpu->h_grc_set (((UINT) 0), opval);
2696   }
2697
2698   current_cpu->done_insn (npc, status);
2699 #undef FLD
2700 }
2701
2702 // ********** movw10-compact: mov.w @($imm8x2, pc), $rn
2703
2704 void
2705 sh2_sem_movw10_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2706         sh2::write_stacks &buf)
2707 {
2708 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
2709   sem_status status = SEM_STATUS_NORMAL;
2710   sh2_scache* abuf = sem;
2711   unsigned long long written = 0;
2712   PCADDR pc = abuf->addr;
2713   PCADDR npc = pc + 2;
2714
2715   {
2716     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, ADDDI (ADDDI (pc, 4), FLD (f_imm8x2))));
2717     if (UNLIKELY(current_cpu->trace_result_p))
2718       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2719     current_cpu->h_grc_set (FLD (f_rn), opval);
2720   }
2721
2722   current_cpu->done_insn (npc, status);
2723 #undef FLD
2724 }
2725
2726 // ********** movw11-compact: mov.w @($imm4x2, $rm), r0
2727
2728 void
2729 sh2_sem_movw11_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2730         sh2::write_stacks &buf)
2731 {
2732 #define FLD(f) abuf->fields.sfmt_movw11_compact.f
2733   sem_status status = SEM_STATUS_NORMAL;
2734   sh2_scache* abuf = sem;
2735   unsigned long long written = 0;
2736   PCADDR pc = abuf->addr;
2737   PCADDR npc = pc + 2;
2738
2739   {
2740     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4x2))));
2741     if (UNLIKELY(current_cpu->trace_result_p))
2742       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2743     current_cpu->h_grc_set (((UINT) 0), opval);
2744   }
2745
2746   current_cpu->done_insn (npc, status);
2747 #undef FLD
2748 }
2749
2750 // ********** mova-compact: mova @($imm8x4, pc), r0
2751
2752 void
2753 sh2_sem_mova_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2754         sh2::write_stacks &buf)
2755 {
2756 #define FLD(f) abuf->fields.sfmt_movl9_compact.f
2757   sem_status status = SEM_STATUS_NORMAL;
2758   sh2_scache* abuf = sem;
2759   unsigned long long written = 0;
2760   PCADDR pc = abuf->addr;
2761   PCADDR npc = pc + 2;
2762
2763   {
2764     SI opval = ADDDI (ANDDI (ADDDI (pc, 4), INVSI (3)), FLD (f_imm8x4));
2765     if (UNLIKELY(current_cpu->trace_result_p))
2766       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2767     current_cpu->h_grc_set (((UINT) 0), opval);
2768   }
2769
2770   current_cpu->done_insn (npc, status);
2771 #undef FLD
2772 }
2773
2774 // ********** movt-compact: movt $rn
2775
2776 void
2777 sh2_sem_movt_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2778         sh2::write_stacks &buf)
2779 {
2780 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
2781   sem_status status = SEM_STATUS_NORMAL;
2782   sh2_scache* abuf = sem;
2783   unsigned long long written = 0;
2784   PCADDR pc = abuf->addr;
2785   PCADDR npc = pc + 2;
2786
2787   {
2788     SI opval = ZEXTBISI (current_cpu->h_tbit_get ());
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 // ********** mull-compact: mul.l $rm, $rn
2799
2800 void
2801 sh2_sem_mull_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2802         sh2::write_stacks &buf)
2803 {
2804 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
2805   sem_status status = SEM_STATUS_NORMAL;
2806   sh2_scache* abuf = sem;
2807   unsigned long long written = 0;
2808   PCADDR pc = abuf->addr;
2809   PCADDR npc = pc + 2;
2810
2811   {
2812     SI opval = MULSI (current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_grc_get (FLD (f_rn)));
2813     if (UNLIKELY(current_cpu->trace_result_p))
2814       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
2815     current_cpu->h_macl_set (opval);
2816   }
2817
2818   current_cpu->done_insn (npc, status);
2819 #undef FLD
2820 }
2821
2822 // ********** mulsw-compact: muls.w $rm, $rn
2823
2824 void
2825 sh2_sem_mulsw_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2826         sh2::write_stacks &buf)
2827 {
2828 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
2829   sem_status status = SEM_STATUS_NORMAL;
2830   sh2_scache* abuf = sem;
2831   unsigned long long written = 0;
2832   PCADDR pc = abuf->addr;
2833   PCADDR npc = pc + 2;
2834
2835   {
2836     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)));
2837     if (UNLIKELY(current_cpu->trace_result_p))
2838       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
2839     current_cpu->h_macl_set (opval);
2840   }
2841
2842   current_cpu->done_insn (npc, status);
2843 #undef FLD
2844 }
2845
2846 // ********** muluw-compact: mulu.w $rm, $rn
2847
2848 void
2849 sh2_sem_muluw_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2850         sh2::write_stacks &buf)
2851 {
2852 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
2853   sem_status status = SEM_STATUS_NORMAL;
2854   sh2_scache* abuf = sem;
2855   unsigned long long written = 0;
2856   PCADDR pc = abuf->addr;
2857   PCADDR npc = pc + 2;
2858
2859   {
2860     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)));
2861     if (UNLIKELY(current_cpu->trace_result_p))
2862       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
2863     current_cpu->h_macl_set (opval);
2864   }
2865
2866   current_cpu->done_insn (npc, status);
2867 #undef FLD
2868 }
2869
2870 // ********** neg-compact: neg $rm, $rn
2871
2872 void
2873 sh2_sem_neg_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2874         sh2::write_stacks &buf)
2875 {
2876 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
2877   sem_status status = SEM_STATUS_NORMAL;
2878   sh2_scache* abuf = sem;
2879   unsigned long long written = 0;
2880   PCADDR pc = abuf->addr;
2881   PCADDR npc = pc + 2;
2882
2883   {
2884     SI opval = NEGSI (current_cpu->h_grc_get (FLD (f_rm)));
2885     if (UNLIKELY(current_cpu->trace_result_p))
2886       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2887     current_cpu->h_grc_set (FLD (f_rn), opval);
2888   }
2889
2890   current_cpu->done_insn (npc, status);
2891 #undef FLD
2892 }
2893
2894 // ********** negc-compact: negc $rm, $rn
2895
2896 void
2897 sh2_sem_negc_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2898         sh2::write_stacks &buf)
2899 {
2900 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
2901   sem_status status = SEM_STATUS_NORMAL;
2902   sh2_scache* abuf = sem;
2903   unsigned long long written = 0;
2904   PCADDR pc = abuf->addr;
2905   PCADDR npc = pc + 2;
2906
2907 {
2908   BI tmp_flag;
2909   tmp_flag = SUBCFSI (0, current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
2910   {
2911     SI opval = SUBCSI (0, current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
2912     if (UNLIKELY(current_cpu->trace_result_p))
2913       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2914     current_cpu->h_grc_set (FLD (f_rn), opval);
2915   }
2916   {
2917     BI opval = tmp_flag;
2918     if (UNLIKELY(current_cpu->trace_result_p))
2919       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
2920     current_cpu->h_tbit_set (opval);
2921   }
2922 }
2923
2924   current_cpu->done_insn (npc, status);
2925 #undef FLD
2926 }
2927
2928 // ********** nop-compact: nop
2929
2930 void
2931 sh2_sem_nop_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2932         sh2::write_stacks &buf)
2933 {
2934 #define FLD(f) abuf->fields.fmt_empty.f
2935   sem_status status = SEM_STATUS_NORMAL;
2936   sh2_scache* abuf = sem;
2937   unsigned long long written = 0;
2938   PCADDR pc = abuf->addr;
2939   PCADDR npc = pc + 2;
2940
2941 ((void) 0); /*nop*/
2942
2943   current_cpu->done_insn (npc, status);
2944 #undef FLD
2945 }
2946
2947 // ********** not-compact: not $rm64, $rn64
2948
2949 void
2950 sh2_sem_not_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2951         sh2::write_stacks &buf)
2952 {
2953 #define FLD(f) abuf->fields.sfmt_and_compact.f
2954   sem_status status = SEM_STATUS_NORMAL;
2955   sh2_scache* abuf = sem;
2956   unsigned long long written = 0;
2957   PCADDR pc = abuf->addr;
2958   PCADDR npc = pc + 2;
2959
2960   {
2961     DI opval = INVDI (current_cpu->h_gr_get (FLD (f_rm)));
2962     if (UNLIKELY(current_cpu->trace_result_p))
2963       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2964     current_cpu->h_gr_set (FLD (f_rn), opval);
2965   }
2966
2967   current_cpu->done_insn (npc, status);
2968 #undef FLD
2969 }
2970
2971 // ********** or-compact: or $rm64, $rn64
2972
2973 void
2974 sh2_sem_or_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2975         sh2::write_stacks &buf)
2976 {
2977 #define FLD(f) abuf->fields.sfmt_and_compact.f
2978   sem_status status = SEM_STATUS_NORMAL;
2979   sh2_scache* abuf = sem;
2980   unsigned long long written = 0;
2981   PCADDR pc = abuf->addr;
2982   PCADDR npc = pc + 2;
2983
2984   {
2985     DI opval = ORDI (current_cpu->h_gr_get (FLD (f_rm)), current_cpu->h_gr_get (FLD (f_rn)));
2986     if (UNLIKELY(current_cpu->trace_result_p))
2987       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2988     current_cpu->h_gr_set (FLD (f_rn), opval);
2989   }
2990
2991   current_cpu->done_insn (npc, status);
2992 #undef FLD
2993 }
2994
2995 // ********** ori-compact: or #$uimm8, r0
2996
2997 void
2998 sh2_sem_ori_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
2999         sh2::write_stacks &buf)
3000 {
3001 #define FLD(f) abuf->fields.sfmt_andi_compact.f
3002   sem_status status = SEM_STATUS_NORMAL;
3003   sh2_scache* abuf = sem;
3004   unsigned long long written = 0;
3005   PCADDR pc = abuf->addr;
3006   PCADDR npc = pc + 2;
3007
3008   {
3009     SI opval = ORSI (current_cpu->h_grc_get (((UINT) 0)), ZEXTSIDI (FLD (f_imm8)));
3010     if (UNLIKELY(current_cpu->trace_result_p))
3011       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
3012     current_cpu->h_grc_set (((UINT) 0), opval);
3013   }
3014
3015   current_cpu->done_insn (npc, status);
3016 #undef FLD
3017 }
3018
3019 // ********** orb-compact: or.b #$imm8, @(r0, gbr)
3020
3021 void
3022 sh2_sem_orb_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3023         sh2::write_stacks &buf)
3024 {
3025 #define FLD(f) abuf->fields.sfmt_andi_compact.f
3026   sem_status status = SEM_STATUS_NORMAL;
3027   sh2_scache* abuf = sem;
3028   unsigned long long written = 0;
3029   PCADDR pc = abuf->addr;
3030   PCADDR npc = pc + 2;
3031
3032 {
3033   DI tmp_addr;
3034   UQI tmp_data;
3035   tmp_addr = ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_gbr_get ());
3036   tmp_data = ORQI (current_cpu->GETMEMUQI (pc, tmp_addr), FLD (f_imm8));
3037   {
3038     UQI opval = tmp_data;
3039     if (UNLIKELY(current_cpu->trace_result_p))
3040       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
3041     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
3042   }
3043 }
3044
3045   current_cpu->done_insn (npc, status);
3046 #undef FLD
3047 }
3048
3049 // ********** rotcl-compact: rotcl $rn
3050
3051 void
3052 sh2_sem_rotcl_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3053         sh2::write_stacks &buf)
3054 {
3055 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3056   sem_status status = SEM_STATUS_NORMAL;
3057   sh2_scache* abuf = sem;
3058   unsigned long long written = 0;
3059   PCADDR pc = abuf->addr;
3060   PCADDR npc = pc + 2;
3061
3062 {
3063   BI tmp_temp;
3064   tmp_temp = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
3065   {
3066     SI opval = ORSI (SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), current_cpu->h_tbit_get ());
3067     if (UNLIKELY(current_cpu->trace_result_p))
3068       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3069     current_cpu->h_grc_set (FLD (f_rn), opval);
3070   }
3071   {
3072     BI opval = ((tmp_temp) ? (1) : (0));
3073     if (UNLIKELY(current_cpu->trace_result_p))
3074       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3075     current_cpu->h_tbit_set (opval);
3076   }
3077 }
3078
3079   current_cpu->done_insn (npc, status);
3080 #undef FLD
3081 }
3082
3083 // ********** rotcr-compact: rotcr $rn
3084
3085 void
3086 sh2_sem_rotcr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3087         sh2::write_stacks &buf)
3088 {
3089 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3090   sem_status status = SEM_STATUS_NORMAL;
3091   sh2_scache* abuf = sem;
3092   unsigned long long written = 0;
3093   PCADDR pc = abuf->addr;
3094   PCADDR npc = pc + 2;
3095
3096 {
3097   BI tmp_lsbit;
3098   SI tmp_temp;
3099   tmp_lsbit = ((EQSI (ANDSI (current_cpu->h_grc_get (FLD (f_rn)), 1), 0)) ? (0) : (1));
3100   tmp_temp = current_cpu->h_tbit_get ();
3101   {
3102     SI opval = ORSI (SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), SLLSI (tmp_temp, 31));
3103     if (UNLIKELY(current_cpu->trace_result_p))
3104       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3105     current_cpu->h_grc_set (FLD (f_rn), opval);
3106   }
3107   {
3108     BI opval = ((tmp_lsbit) ? (1) : (0));
3109     if (UNLIKELY(current_cpu->trace_result_p))
3110       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3111     current_cpu->h_tbit_set (opval);
3112   }
3113 }
3114
3115   current_cpu->done_insn (npc, status);
3116 #undef FLD
3117 }
3118
3119 // ********** rotl-compact: rotl $rn
3120
3121 void
3122 sh2_sem_rotl_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3123         sh2::write_stacks &buf)
3124 {
3125 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3126   sem_status status = SEM_STATUS_NORMAL;
3127   sh2_scache* abuf = sem;
3128   unsigned long long written = 0;
3129   PCADDR pc = abuf->addr;
3130   PCADDR npc = pc + 2;
3131
3132 {
3133   BI tmp_temp;
3134   tmp_temp = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
3135   {
3136     SI opval = ORSI (SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), tmp_temp);
3137     if (UNLIKELY(current_cpu->trace_result_p))
3138       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3139     current_cpu->h_grc_set (FLD (f_rn), opval);
3140   }
3141   {
3142     BI opval = ((tmp_temp) ? (1) : (0));
3143     if (UNLIKELY(current_cpu->trace_result_p))
3144       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3145     current_cpu->h_tbit_set (opval);
3146   }
3147 }
3148
3149   current_cpu->done_insn (npc, status);
3150 #undef FLD
3151 }
3152
3153 // ********** rotr-compact: rotr $rn
3154
3155 void
3156 sh2_sem_rotr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3157         sh2::write_stacks &buf)
3158 {
3159 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3160   sem_status status = SEM_STATUS_NORMAL;
3161   sh2_scache* abuf = sem;
3162   unsigned long long written = 0;
3163   PCADDR pc = abuf->addr;
3164   PCADDR npc = pc + 2;
3165
3166 {
3167   BI tmp_lsbit;
3168   SI tmp_temp;
3169   tmp_lsbit = ((EQSI (ANDSI (current_cpu->h_grc_get (FLD (f_rn)), 1), 0)) ? (0) : (1));
3170   tmp_temp = tmp_lsbit;
3171   {
3172     SI opval = ORSI (SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), SLLSI (tmp_temp, 31));
3173     if (UNLIKELY(current_cpu->trace_result_p))
3174       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3175     current_cpu->h_grc_set (FLD (f_rn), opval);
3176   }
3177   {
3178     BI opval = ((tmp_lsbit) ? (1) : (0));
3179     if (UNLIKELY(current_cpu->trace_result_p))
3180       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3181     current_cpu->h_tbit_set (opval);
3182   }
3183 }
3184
3185   current_cpu->done_insn (npc, status);
3186 #undef FLD
3187 }
3188
3189 // ********** rts-compact: rts
3190
3191 void
3192 sh2_sem_rts_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3193         sh2::write_stacks &buf)
3194 {
3195 #define FLD(f) abuf->fields.fmt_empty.f
3196   sem_status status = SEM_STATUS_NORMAL;
3197   sh2_scache* abuf = sem;
3198   unsigned long long written = 0;
3199   PCADDR pc = abuf->addr;
3200   PCADDR npc = pc + 2;
3201
3202 {
3203   {
3204     UDI opval = ADDDI (pc, 2);
3205     if (UNLIKELY(current_cpu->trace_result_p))
3206       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
3207     current_cpu->branch (opval, npc, status);
3208   }
3209 current_cpu->save_delayed_pc (current_cpu->h_pr_get ());
3210   {
3211     UDI opval = current_cpu->h_pr_get ();
3212     buf.h_pc_writes [(tick + 1) % sh2::pipe_sz].push (sh2::write<UDI>(pc, opval));
3213     if (UNLIKELY(current_cpu->trace_result_p))
3214       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
3215   }
3216 current_cpu->notify_ret (current_cpu->h_pr_get ());
3217 }
3218
3219   current_cpu->done_cti_insn (npc, status);
3220 #undef FLD
3221 }
3222
3223 // ********** sett-compact: sett
3224
3225 void
3226 sh2_sem_sett_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3227         sh2::write_stacks &buf)
3228 {
3229 #define FLD(f) abuf->fields.fmt_empty.f
3230   sem_status status = SEM_STATUS_NORMAL;
3231   sh2_scache* abuf = sem;
3232   unsigned long long written = 0;
3233   PCADDR pc = abuf->addr;
3234   PCADDR npc = pc + 2;
3235
3236   {
3237     BI opval = 1;
3238     if (UNLIKELY(current_cpu->trace_result_p))
3239       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3240     current_cpu->h_tbit_set (opval);
3241   }
3242
3243   current_cpu->done_insn (npc, status);
3244 #undef FLD
3245 }
3246
3247 // ********** shal-compact: shal $rn
3248
3249 void
3250 sh2_sem_shal_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3251         sh2::write_stacks &buf)
3252 {
3253 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3254   sem_status status = SEM_STATUS_NORMAL;
3255   sh2_scache* abuf = sem;
3256   unsigned long long written = 0;
3257   PCADDR pc = abuf->addr;
3258   PCADDR npc = pc + 2;
3259
3260 {
3261   BI tmp_t;
3262   tmp_t = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
3263   {
3264     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
3265     if (UNLIKELY(current_cpu->trace_result_p))
3266       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3267     current_cpu->h_grc_set (FLD (f_rn), opval);
3268   }
3269   {
3270     BI opval = ((tmp_t) ? (1) : (0));
3271     if (UNLIKELY(current_cpu->trace_result_p))
3272       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3273     current_cpu->h_tbit_set (opval);
3274   }
3275 }
3276
3277   current_cpu->done_insn (npc, status);
3278 #undef FLD
3279 }
3280
3281 // ********** shar-compact: shar $rn
3282
3283 void
3284 sh2_sem_shar_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3285         sh2::write_stacks &buf)
3286 {
3287 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3288   sem_status status = SEM_STATUS_NORMAL;
3289   sh2_scache* abuf = sem;
3290   unsigned long long written = 0;
3291   PCADDR pc = abuf->addr;
3292   PCADDR npc = pc + 2;
3293
3294 {
3295   BI tmp_t;
3296   tmp_t = ANDSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
3297   {
3298     SI opval = SRASI (current_cpu->h_grc_get (FLD (f_rn)), 1);
3299     if (UNLIKELY(current_cpu->trace_result_p))
3300       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3301     current_cpu->h_grc_set (FLD (f_rn), opval);
3302   }
3303   {
3304     BI opval = ((tmp_t) ? (1) : (0));
3305     if (UNLIKELY(current_cpu->trace_result_p))
3306       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3307     current_cpu->h_tbit_set (opval);
3308   }
3309 }
3310
3311   current_cpu->done_insn (npc, status);
3312 #undef FLD
3313 }
3314
3315 // ********** shll-compact: shll $rn
3316
3317 void
3318 sh2_sem_shll_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3319         sh2::write_stacks &buf)
3320 {
3321 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3322   sem_status status = SEM_STATUS_NORMAL;
3323   sh2_scache* abuf = sem;
3324   unsigned long long written = 0;
3325   PCADDR pc = abuf->addr;
3326   PCADDR npc = pc + 2;
3327
3328 {
3329   BI tmp_t;
3330   tmp_t = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
3331   {
3332     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
3333     if (UNLIKELY(current_cpu->trace_result_p))
3334       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3335     current_cpu->h_grc_set (FLD (f_rn), opval);
3336   }
3337   {
3338     BI opval = ((tmp_t) ? (1) : (0));
3339     if (UNLIKELY(current_cpu->trace_result_p))
3340       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3341     current_cpu->h_tbit_set (opval);
3342   }
3343 }
3344
3345   current_cpu->done_insn (npc, status);
3346 #undef FLD
3347 }
3348
3349 // ********** shll2-compact: shll2 $rn
3350
3351 void
3352 sh2_sem_shll2_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3353         sh2::write_stacks &buf)
3354 {
3355 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3356   sem_status status = SEM_STATUS_NORMAL;
3357   sh2_scache* abuf = sem;
3358   unsigned long long written = 0;
3359   PCADDR pc = abuf->addr;
3360   PCADDR npc = pc + 2;
3361
3362   {
3363     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
3364     if (UNLIKELY(current_cpu->trace_result_p))
3365       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3366     current_cpu->h_grc_set (FLD (f_rn), opval);
3367   }
3368
3369   current_cpu->done_insn (npc, status);
3370 #undef FLD
3371 }
3372
3373 // ********** shll8-compact: shll8 $rn
3374
3375 void
3376 sh2_sem_shll8_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3377         sh2::write_stacks &buf)
3378 {
3379 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3380   sem_status status = SEM_STATUS_NORMAL;
3381   sh2_scache* abuf = sem;
3382   unsigned long long written = 0;
3383   PCADDR pc = abuf->addr;
3384   PCADDR npc = pc + 2;
3385
3386   {
3387     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 8);
3388     if (UNLIKELY(current_cpu->trace_result_p))
3389       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3390     current_cpu->h_grc_set (FLD (f_rn), opval);
3391   }
3392
3393   current_cpu->done_insn (npc, status);
3394 #undef FLD
3395 }
3396
3397 // ********** shll16-compact: shll16 $rn
3398
3399 void
3400 sh2_sem_shll16_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3401         sh2::write_stacks &buf)
3402 {
3403 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3404   sem_status status = SEM_STATUS_NORMAL;
3405   sh2_scache* abuf = sem;
3406   unsigned long long written = 0;
3407   PCADDR pc = abuf->addr;
3408   PCADDR npc = pc + 2;
3409
3410   {
3411     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 16);
3412     if (UNLIKELY(current_cpu->trace_result_p))
3413       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3414     current_cpu->h_grc_set (FLD (f_rn), opval);
3415   }
3416
3417   current_cpu->done_insn (npc, status);
3418 #undef FLD
3419 }
3420
3421 // ********** shlr-compact: shlr $rn
3422
3423 void
3424 sh2_sem_shlr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3425         sh2::write_stacks &buf)
3426 {
3427 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3428   sem_status status = SEM_STATUS_NORMAL;
3429   sh2_scache* abuf = sem;
3430   unsigned long long written = 0;
3431   PCADDR pc = abuf->addr;
3432   PCADDR npc = pc + 2;
3433
3434 {
3435   BI tmp_t;
3436   tmp_t = ANDSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
3437   {
3438     SI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
3439     if (UNLIKELY(current_cpu->trace_result_p))
3440       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3441     current_cpu->h_grc_set (FLD (f_rn), opval);
3442   }
3443   {
3444     BI opval = ((tmp_t) ? (1) : (0));
3445     if (UNLIKELY(current_cpu->trace_result_p))
3446       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3447     current_cpu->h_tbit_set (opval);
3448   }
3449 }
3450
3451   current_cpu->done_insn (npc, status);
3452 #undef FLD
3453 }
3454
3455 // ********** shlr2-compact: shlr2 $rn
3456
3457 void
3458 sh2_sem_shlr2_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3459         sh2::write_stacks &buf)
3460 {
3461 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3462   sem_status status = SEM_STATUS_NORMAL;
3463   sh2_scache* abuf = sem;
3464   unsigned long long written = 0;
3465   PCADDR pc = abuf->addr;
3466   PCADDR npc = pc + 2;
3467
3468   {
3469     SI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
3470     if (UNLIKELY(current_cpu->trace_result_p))
3471       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3472     current_cpu->h_grc_set (FLD (f_rn), opval);
3473   }
3474
3475   current_cpu->done_insn (npc, status);
3476 #undef FLD
3477 }
3478
3479 // ********** shlr8-compact: shlr8 $rn
3480
3481 void
3482 sh2_sem_shlr8_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3483         sh2::write_stacks &buf)
3484 {
3485 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3486   sem_status status = SEM_STATUS_NORMAL;
3487   sh2_scache* abuf = sem;
3488   unsigned long long written = 0;
3489   PCADDR pc = abuf->addr;
3490   PCADDR npc = pc + 2;
3491
3492   {
3493     SI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 8);
3494     if (UNLIKELY(current_cpu->trace_result_p))
3495       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3496     current_cpu->h_grc_set (FLD (f_rn), opval);
3497   }
3498
3499   current_cpu->done_insn (npc, status);
3500 #undef FLD
3501 }
3502
3503 // ********** shlr16-compact: shlr16 $rn
3504
3505 void
3506 sh2_sem_shlr16_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3507         sh2::write_stacks &buf)
3508 {
3509 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3510   sem_status status = SEM_STATUS_NORMAL;
3511   sh2_scache* abuf = sem;
3512   unsigned long long written = 0;
3513   PCADDR pc = abuf->addr;
3514   PCADDR npc = pc + 2;
3515
3516   {
3517     SI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 16);
3518     if (UNLIKELY(current_cpu->trace_result_p))
3519       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3520     current_cpu->h_grc_set (FLD (f_rn), opval);
3521   }
3522
3523   current_cpu->done_insn (npc, status);
3524 #undef FLD
3525 }
3526
3527 // ********** stc-gbr-compact: stc gbr, $rn
3528
3529 void
3530 sh2_sem_stc_gbr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3531         sh2::write_stacks &buf)
3532 {
3533 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
3534   sem_status status = SEM_STATUS_NORMAL;
3535   sh2_scache* abuf = sem;
3536   unsigned long long written = 0;
3537   PCADDR pc = abuf->addr;
3538   PCADDR npc = pc + 2;
3539
3540   {
3541     SI opval = current_cpu->h_gbr_get ();
3542     if (UNLIKELY(current_cpu->trace_result_p))
3543       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3544     current_cpu->h_grc_set (FLD (f_rn), opval);
3545   }
3546
3547   current_cpu->done_insn (npc, status);
3548 #undef FLD
3549 }
3550
3551 // ********** stc-vbr-compact: stc vbr, $rn
3552
3553 void
3554 sh2_sem_stc_vbr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3555         sh2::write_stacks &buf)
3556 {
3557 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
3558   sem_status status = SEM_STATUS_NORMAL;
3559   sh2_scache* abuf = sem;
3560   unsigned long long written = 0;
3561   PCADDR pc = abuf->addr;
3562   PCADDR npc = pc + 2;
3563
3564   {
3565     SI opval = current_cpu->h_vbr_get ();
3566     if (UNLIKELY(current_cpu->trace_result_p))
3567       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3568     current_cpu->h_grc_set (FLD (f_rn), opval);
3569   }
3570
3571   current_cpu->done_insn (npc, status);
3572 #undef FLD
3573 }
3574
3575 // ********** stcl-gbr-compact: stc.l gbr, @-$rn
3576
3577 void
3578 sh2_sem_stcl_gbr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3579         sh2::write_stacks &buf)
3580 {
3581 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3582   sem_status status = SEM_STATUS_NORMAL;
3583   sh2_scache* abuf = sem;
3584   unsigned long long written = 0;
3585   PCADDR pc = abuf->addr;
3586   PCADDR npc = pc + 2;
3587
3588 {
3589   DI tmp_addr;
3590   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
3591   {
3592     SI opval = current_cpu->h_gbr_get ();
3593     if (UNLIKELY(current_cpu->trace_result_p))
3594       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3595     current_cpu->SETMEMSI (pc, tmp_addr, opval);
3596   }
3597   {
3598     SI opval = tmp_addr;
3599     if (UNLIKELY(current_cpu->trace_result_p))
3600       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3601     current_cpu->h_grc_set (FLD (f_rn), opval);
3602   }
3603 }
3604
3605   current_cpu->done_insn (npc, status);
3606 #undef FLD
3607 }
3608
3609 // ********** stcl-vbr-compact: stc.l vbr, @-$rn
3610
3611 void
3612 sh2_sem_stcl_vbr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3613         sh2::write_stacks &buf)
3614 {
3615 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3616   sem_status status = SEM_STATUS_NORMAL;
3617   sh2_scache* abuf = sem;
3618   unsigned long long written = 0;
3619   PCADDR pc = abuf->addr;
3620   PCADDR npc = pc + 2;
3621
3622 {
3623   DI tmp_addr;
3624   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
3625   {
3626     SI opval = current_cpu->h_vbr_get ();
3627     if (UNLIKELY(current_cpu->trace_result_p))
3628       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3629     current_cpu->SETMEMSI (pc, tmp_addr, opval);
3630   }
3631   {
3632     SI opval = tmp_addr;
3633     if (UNLIKELY(current_cpu->trace_result_p))
3634       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3635     current_cpu->h_grc_set (FLD (f_rn), opval);
3636   }
3637 }
3638
3639   current_cpu->done_insn (npc, status);
3640 #undef FLD
3641 }
3642
3643 // ********** sts-mach-compact: sts mach, $rn
3644
3645 void
3646 sh2_sem_sts_mach_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3647         sh2::write_stacks &buf)
3648 {
3649 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
3650   sem_status status = SEM_STATUS_NORMAL;
3651   sh2_scache* abuf = sem;
3652   unsigned long long written = 0;
3653   PCADDR pc = abuf->addr;
3654   PCADDR npc = pc + 2;
3655
3656   {
3657     SI opval = current_cpu->h_mach_get ();
3658     if (UNLIKELY(current_cpu->trace_result_p))
3659       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3660     current_cpu->h_grc_set (FLD (f_rn), opval);
3661   }
3662
3663   current_cpu->done_insn (npc, status);
3664 #undef FLD
3665 }
3666
3667 // ********** stsl-mach-compact: sts.l mach, @-$rn
3668
3669 void
3670 sh2_sem_stsl_mach_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3671         sh2::write_stacks &buf)
3672 {
3673 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3674   sem_status status = SEM_STATUS_NORMAL;
3675   sh2_scache* abuf = sem;
3676   unsigned long long written = 0;
3677   PCADDR pc = abuf->addr;
3678   PCADDR npc = pc + 2;
3679
3680 {
3681   DI tmp_addr;
3682   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
3683   {
3684     SI opval = current_cpu->h_mach_get ();
3685     if (UNLIKELY(current_cpu->trace_result_p))
3686       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3687     current_cpu->SETMEMSI (pc, tmp_addr, opval);
3688   }
3689   {
3690     SI opval = tmp_addr;
3691     if (UNLIKELY(current_cpu->trace_result_p))
3692       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3693     current_cpu->h_grc_set (FLD (f_rn), opval);
3694   }
3695 }
3696
3697   current_cpu->done_insn (npc, status);
3698 #undef FLD
3699 }
3700
3701 // ********** sts-macl-compact: sts macl, $rn
3702
3703 void
3704 sh2_sem_sts_macl_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3705         sh2::write_stacks &buf)
3706 {
3707 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
3708   sem_status status = SEM_STATUS_NORMAL;
3709   sh2_scache* abuf = sem;
3710   unsigned long long written = 0;
3711   PCADDR pc = abuf->addr;
3712   PCADDR npc = pc + 2;
3713
3714   {
3715     SI opval = current_cpu->h_macl_get ();
3716     if (UNLIKELY(current_cpu->trace_result_p))
3717       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3718     current_cpu->h_grc_set (FLD (f_rn), opval);
3719   }
3720
3721   current_cpu->done_insn (npc, status);
3722 #undef FLD
3723 }
3724
3725 // ********** stsl-macl-compact: sts.l macl, @-$rn
3726
3727 void
3728 sh2_sem_stsl_macl_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3729         sh2::write_stacks &buf)
3730 {
3731 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3732   sem_status status = SEM_STATUS_NORMAL;
3733   sh2_scache* abuf = sem;
3734   unsigned long long written = 0;
3735   PCADDR pc = abuf->addr;
3736   PCADDR npc = pc + 2;
3737
3738 {
3739   DI tmp_addr;
3740   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
3741   {
3742     SI opval = current_cpu->h_macl_get ();
3743     if (UNLIKELY(current_cpu->trace_result_p))
3744       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3745     current_cpu->SETMEMSI (pc, tmp_addr, opval);
3746   }
3747   {
3748     SI opval = tmp_addr;
3749     if (UNLIKELY(current_cpu->trace_result_p))
3750       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3751     current_cpu->h_grc_set (FLD (f_rn), opval);
3752   }
3753 }
3754
3755   current_cpu->done_insn (npc, status);
3756 #undef FLD
3757 }
3758
3759 // ********** sts-pr-compact: sts pr, $rn
3760
3761 void
3762 sh2_sem_sts_pr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3763         sh2::write_stacks &buf)
3764 {
3765 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
3766   sem_status status = SEM_STATUS_NORMAL;
3767   sh2_scache* abuf = sem;
3768   unsigned long long written = 0;
3769   PCADDR pc = abuf->addr;
3770   PCADDR npc = pc + 2;
3771
3772   {
3773     SI opval = current_cpu->h_pr_get ();
3774     if (UNLIKELY(current_cpu->trace_result_p))
3775       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3776     current_cpu->h_grc_set (FLD (f_rn), opval);
3777   }
3778
3779   current_cpu->done_insn (npc, status);
3780 #undef FLD
3781 }
3782
3783 // ********** stsl-pr-compact: sts.l pr, @-$rn
3784
3785 void
3786 sh2_sem_stsl_pr_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3787         sh2::write_stacks &buf)
3788 {
3789 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3790   sem_status status = SEM_STATUS_NORMAL;
3791   sh2_scache* abuf = sem;
3792   unsigned long long written = 0;
3793   PCADDR pc = abuf->addr;
3794   PCADDR npc = pc + 2;
3795
3796 {
3797   DI tmp_addr;
3798   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
3799   {
3800     SI opval = current_cpu->h_pr_get ();
3801     if (UNLIKELY(current_cpu->trace_result_p))
3802       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3803     current_cpu->SETMEMSI (pc, tmp_addr, opval);
3804   }
3805   {
3806     SI opval = tmp_addr;
3807     if (UNLIKELY(current_cpu->trace_result_p))
3808       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3809     current_cpu->h_grc_set (FLD (f_rn), opval);
3810   }
3811 }
3812
3813   current_cpu->done_insn (npc, status);
3814 #undef FLD
3815 }
3816
3817 // ********** sub-compact: sub $rm, $rn
3818
3819 void
3820 sh2_sem_sub_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3821         sh2::write_stacks &buf)
3822 {
3823 #define FLD(f) abuf->fields.sfmt_macl_compact.f
3824   sem_status status = SEM_STATUS_NORMAL;
3825   sh2_scache* abuf = sem;
3826   unsigned long long written = 0;
3827   PCADDR pc = abuf->addr;
3828   PCADDR npc = pc + 2;
3829
3830   {
3831     SI opval = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
3832     if (UNLIKELY(current_cpu->trace_result_p))
3833       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3834     current_cpu->h_grc_set (FLD (f_rn), opval);
3835   }
3836
3837   current_cpu->done_insn (npc, status);
3838 #undef FLD
3839 }
3840
3841 // ********** subc-compact: subc $rm, $rn
3842
3843 void
3844 sh2_sem_subc_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3845         sh2::write_stacks &buf)
3846 {
3847 #define FLD(f) abuf->fields.sfmt_macl_compact.f
3848   sem_status status = SEM_STATUS_NORMAL;
3849   sh2_scache* abuf = sem;
3850   unsigned long long written = 0;
3851   PCADDR pc = abuf->addr;
3852   PCADDR npc = pc + 2;
3853
3854 {
3855   BI tmp_flag;
3856   tmp_flag = SUBCFSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
3857   {
3858     SI opval = SUBCSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
3859     if (UNLIKELY(current_cpu->trace_result_p))
3860       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3861     current_cpu->h_grc_set (FLD (f_rn), opval);
3862   }
3863   {
3864     BI opval = tmp_flag;
3865     if (UNLIKELY(current_cpu->trace_result_p))
3866       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3867     current_cpu->h_tbit_set (opval);
3868   }
3869 }
3870
3871   current_cpu->done_insn (npc, status);
3872 #undef FLD
3873 }
3874
3875 // ********** subv-compact: subv $rm, $rn
3876
3877 void
3878 sh2_sem_subv_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3879         sh2::write_stacks &buf)
3880 {
3881 #define FLD(f) abuf->fields.sfmt_macl_compact.f
3882   sem_status status = SEM_STATUS_NORMAL;
3883   sh2_scache* abuf = sem;
3884   unsigned long long written = 0;
3885   PCADDR pc = abuf->addr;
3886   PCADDR npc = pc + 2;
3887
3888 {
3889   BI tmp_t;
3890   tmp_t = SUBOFSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)), 0);
3891   {
3892     SI opval = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
3893     if (UNLIKELY(current_cpu->trace_result_p))
3894       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3895     current_cpu->h_grc_set (FLD (f_rn), opval);
3896   }
3897   {
3898     BI opval = ((tmp_t) ? (1) : (0));
3899     if (UNLIKELY(current_cpu->trace_result_p))
3900       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3901     current_cpu->h_tbit_set (opval);
3902   }
3903 }
3904
3905   current_cpu->done_insn (npc, status);
3906 #undef FLD
3907 }
3908
3909 // ********** swapb-compact: swap.b $rm, $rn
3910
3911 void
3912 sh2_sem_swapb_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3913         sh2::write_stacks &buf)
3914 {
3915 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
3916   sem_status status = SEM_STATUS_NORMAL;
3917   sh2_scache* abuf = sem;
3918   unsigned long long written = 0;
3919   PCADDR pc = abuf->addr;
3920   PCADDR npc = pc + 2;
3921
3922 {
3923   UHI tmp_top_half;
3924   UQI tmp_byte1;
3925   UQI tmp_byte0;
3926   tmp_top_half = SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 0);
3927   tmp_byte1 = SUBWORDSIQI (current_cpu->h_grc_get (FLD (f_rm)), 2);
3928   tmp_byte0 = SUBWORDSIQI (current_cpu->h_grc_get (FLD (f_rm)), 3);
3929   {
3930     SI opval = ORSI (SLLSI (tmp_top_half, 16), ORSI (SLLSI (tmp_byte0, 8), tmp_byte1));
3931     if (UNLIKELY(current_cpu->trace_result_p))
3932       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3933     current_cpu->h_grc_set (FLD (f_rn), opval);
3934   }
3935 }
3936
3937   current_cpu->done_insn (npc, status);
3938 #undef FLD
3939 }
3940
3941 // ********** swapw-compact: swap.w $rm, $rn
3942
3943 void
3944 sh2_sem_swapw_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3945         sh2::write_stacks &buf)
3946 {
3947 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
3948   sem_status status = SEM_STATUS_NORMAL;
3949   sh2_scache* abuf = sem;
3950   unsigned long long written = 0;
3951   PCADDR pc = abuf->addr;
3952   PCADDR npc = pc + 2;
3953
3954   {
3955     SI opval = ORSI (SRLSI (current_cpu->h_grc_get (FLD (f_rm)), 16), SLLSI (current_cpu->h_grc_get (FLD (f_rm)), 16));
3956     if (UNLIKELY(current_cpu->trace_result_p))
3957       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3958     current_cpu->h_grc_set (FLD (f_rn), opval);
3959   }
3960
3961   current_cpu->done_insn (npc, status);
3962 #undef FLD
3963 }
3964
3965 // ********** tasb-compact: tas.b @$rn
3966
3967 void
3968 sh2_sem_tasb_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
3969         sh2::write_stacks &buf)
3970 {
3971 #define FLD(f) abuf->fields.sfmt_addi_compact.f
3972   sem_status status = SEM_STATUS_NORMAL;
3973   sh2_scache* abuf = sem;
3974   unsigned long long written = 0;
3975   PCADDR pc = abuf->addr;
3976   PCADDR npc = pc + 2;
3977
3978 {
3979   UQI tmp_byte;
3980   tmp_byte = current_cpu->GETMEMUQI (pc, current_cpu->h_grc_get (FLD (f_rn)));
3981   {
3982     BI opval = ((EQQI (tmp_byte, 0)) ? (1) : (0));
3983     if (UNLIKELY(current_cpu->trace_result_p))
3984       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3985     current_cpu->h_tbit_set (opval);
3986   }
3987   tmp_byte = ORQI (tmp_byte, 128);
3988   {
3989     UQI opval = tmp_byte;
3990     if (UNLIKELY(current_cpu->trace_result_p))
3991       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
3992     current_cpu->SETMEMUQI (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
3993   }
3994 }
3995
3996   current_cpu->done_insn (npc, status);
3997 #undef FLD
3998 }
3999
4000 // ********** trapa-compact: trapa #$uimm8
4001
4002 void
4003 sh2_sem_trapa_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
4004         sh2::write_stacks &buf)
4005 {
4006 #define FLD(f) abuf->fields.sfmt_andi_compact.f
4007   sem_status status = SEM_STATUS_NORMAL;
4008   sh2_scache* abuf = sem;
4009   unsigned long long written = 0;
4010   PCADDR pc = abuf->addr;
4011   PCADDR npc = pc + 2;
4012
4013 current_cpu->sh64_compact_trapa (FLD (f_imm8), pc);
4014
4015   current_cpu->done_insn (npc, status);
4016 #undef FLD
4017 }
4018
4019 // ********** tst-compact: tst $rm, $rn
4020
4021 void
4022 sh2_sem_tst_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
4023         sh2::write_stacks &buf)
4024 {
4025 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
4026   sem_status status = SEM_STATUS_NORMAL;
4027   sh2_scache* abuf = sem;
4028   unsigned long long written = 0;
4029   PCADDR pc = abuf->addr;
4030   PCADDR npc = pc + 2;
4031
4032   {
4033     BI opval = ((EQSI (ANDSI (current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_grc_get (FLD (f_rn))), 0)) ? (1) : (0));
4034     if (UNLIKELY(current_cpu->trace_result_p))
4035       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4036     current_cpu->h_tbit_set (opval);
4037   }
4038
4039   current_cpu->done_insn (npc, status);
4040 #undef FLD
4041 }
4042
4043 // ********** tsti-compact: tst #$uimm8, r0
4044
4045 void
4046 sh2_sem_tsti_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
4047         sh2::write_stacks &buf)
4048 {
4049 #define FLD(f) abuf->fields.sfmt_andi_compact.f
4050   sem_status status = SEM_STATUS_NORMAL;
4051   sh2_scache* abuf = sem;
4052   unsigned long long written = 0;
4053   PCADDR pc = abuf->addr;
4054   PCADDR npc = pc + 2;
4055
4056   {
4057     BI opval = ((EQSI (ANDSI (current_cpu->h_grc_get (((UINT) 0)), ZEXTSISI (FLD (f_imm8))), 0)) ? (1) : (0));
4058     if (UNLIKELY(current_cpu->trace_result_p))
4059       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4060     current_cpu->h_tbit_set (opval);
4061   }
4062
4063   current_cpu->done_insn (npc, status);
4064 #undef FLD
4065 }
4066
4067 // ********** tstb-compact: tst.b #$imm8, @(r0, gbr)
4068
4069 void
4070 sh2_sem_tstb_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
4071         sh2::write_stacks &buf)
4072 {
4073 #define FLD(f) abuf->fields.sfmt_andi_compact.f
4074   sem_status status = SEM_STATUS_NORMAL;
4075   sh2_scache* abuf = sem;
4076   unsigned long long written = 0;
4077   PCADDR pc = abuf->addr;
4078   PCADDR npc = pc + 2;
4079
4080 {
4081   DI tmp_addr;
4082   tmp_addr = ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_gbr_get ());
4083   {
4084     BI opval = ((EQQI (ANDQI (current_cpu->GETMEMUQI (pc, tmp_addr), FLD (f_imm8)), 0)) ? (1) : (0));
4085     if (UNLIKELY(current_cpu->trace_result_p))
4086       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4087     current_cpu->h_tbit_set (opval);
4088   }
4089 }
4090
4091   current_cpu->done_insn (npc, status);
4092 #undef FLD
4093 }
4094
4095 // ********** xor-compact: xor $rm64, $rn64
4096
4097 void
4098 sh2_sem_xor_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
4099         sh2::write_stacks &buf)
4100 {
4101 #define FLD(f) abuf->fields.sfmt_and_compact.f
4102   sem_status status = SEM_STATUS_NORMAL;
4103   sh2_scache* abuf = sem;
4104   unsigned long long written = 0;
4105   PCADDR pc = abuf->addr;
4106   PCADDR npc = pc + 2;
4107
4108   {
4109     DI opval = XORDI (current_cpu->h_gr_get (FLD (f_rn)), current_cpu->h_gr_get (FLD (f_rm)));
4110     if (UNLIKELY(current_cpu->trace_result_p))
4111       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4112     current_cpu->h_gr_set (FLD (f_rn), opval);
4113   }
4114
4115   current_cpu->done_insn (npc, status);
4116 #undef FLD
4117 }
4118
4119 // ********** xori-compact: xor #$uimm8, r0
4120
4121 void
4122 sh2_sem_xori_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
4123         sh2::write_stacks &buf)
4124 {
4125 #define FLD(f) abuf->fields.sfmt_andi_compact.f
4126   sem_status status = SEM_STATUS_NORMAL;
4127   sh2_scache* abuf = sem;
4128   unsigned long long written = 0;
4129   PCADDR pc = abuf->addr;
4130   PCADDR npc = pc + 2;
4131
4132   {
4133     SI opval = XORSI (current_cpu->h_grc_get (((UINT) 0)), ZEXTSIDI (FLD (f_imm8)));
4134     if (UNLIKELY(current_cpu->trace_result_p))
4135       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
4136     current_cpu->h_grc_set (((UINT) 0), opval);
4137   }
4138
4139   current_cpu->done_insn (npc, status);
4140 #undef FLD
4141 }
4142
4143 // ********** xorb-compact: xor.b #$imm8, @(r0, gbr)
4144
4145 void
4146 sh2_sem_xorb_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
4147         sh2::write_stacks &buf)
4148 {
4149 #define FLD(f) abuf->fields.sfmt_andi_compact.f
4150   sem_status status = SEM_STATUS_NORMAL;
4151   sh2_scache* abuf = sem;
4152   unsigned long long written = 0;
4153   PCADDR pc = abuf->addr;
4154   PCADDR npc = pc + 2;
4155
4156 {
4157   DI tmp_addr;
4158   UQI tmp_data;
4159   tmp_addr = ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_gbr_get ());
4160   tmp_data = XORQI (current_cpu->GETMEMUQI (pc, tmp_addr), FLD (f_imm8));
4161   {
4162     UQI opval = tmp_data;
4163     if (UNLIKELY(current_cpu->trace_result_p))
4164       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
4165     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
4166   }
4167 }
4168
4169   current_cpu->done_insn (npc, status);
4170 #undef FLD
4171 }
4172
4173 // ********** xtrct-compact: xtrct $rm, $rn
4174
4175 void
4176 sh2_sem_xtrct_compact (sh2_cpu* current_cpu, sh2_scache* sem, const int tick, 
4177         sh2::write_stacks &buf)
4178 {
4179 #define FLD(f) abuf->fields.sfmt_macl_compact.f
4180   sem_status status = SEM_STATUS_NORMAL;
4181   sh2_scache* abuf = sem;
4182   unsigned long long written = 0;
4183   PCADDR pc = abuf->addr;
4184   PCADDR npc = pc + 2;
4185
4186   {
4187     SI opval = ORSI (SLLSI (current_cpu->h_grc_get (FLD (f_rm)), 16), SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 16));
4188     if (UNLIKELY(current_cpu->trace_result_p))
4189       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4190     current_cpu->h_grc_set (FLD (f_rn), opval);
4191   }
4192
4193   current_cpu->done_insn (npc, status);
4194 #undef FLD
4195 }
4196