OSDN Git Service

294444866bf9aa814c840100840d64bdac56726c
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / cgen-cpu / sh / sh2e-sem.cxx
1 /* Simulator instruction semantics for sh2e.
2
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
4
5 Copyright (C) 2000-2009 Red Hat, Inc.
6
7 This file is part of the Red Hat simulators.
8
9
10 */
11
12
13 #if HAVE_CONFIG_H
14 #include "config.h"
15 #endif
16 #include "sh2e.h"
17
18 using namespace sh2e; // FIXME: namespace organization still wip
19 using namespace sh2e; // FIXME: namespace organization still wip
20 #define GET_ATTR(name) GET_ATTR_##name ()
21
22
23 // ********** x-invalid: --invalid--
24
25 void
26 sh2e_sem_x_invalid (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
27         sh2e::write_stacks &buf)
28 {
29 #define FLD(f) abuf->fields.fmt_empty.f
30   sem_status status = SEM_STATUS_NORMAL;
31   sh2e_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 sh2e_sem_add_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
50         sh2e::write_stacks &buf)
51 {
52 #define FLD(f) abuf->fields.sfmt_macl_compact.f
53   sem_status status = SEM_STATUS_NORMAL;
54   sh2e_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 sh2e_sem_addi_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
74         sh2e::write_stacks &buf)
75 {
76 #define FLD(f) abuf->fields.sfmt_addi_compact.f
77   sem_status status = SEM_STATUS_NORMAL;
78   sh2e_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 sh2e_sem_addc_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
98         sh2e::write_stacks &buf)
99 {
100 #define FLD(f) abuf->fields.sfmt_macl_compact.f
101   sem_status status = SEM_STATUS_NORMAL;
102   sh2e_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 sh2e_sem_addv_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
132         sh2e::write_stacks &buf)
133 {
134 #define FLD(f) abuf->fields.sfmt_macl_compact.f
135   sem_status status = SEM_STATUS_NORMAL;
136   sh2e_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 sh2e_sem_and_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
166         sh2e::write_stacks &buf)
167 {
168 #define FLD(f) abuf->fields.sfmt_and_compact.f
169   sem_status status = SEM_STATUS_NORMAL;
170   sh2e_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 sh2e_sem_andi_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
190         sh2e::write_stacks &buf)
191 {
192 #define FLD(f) abuf->fields.sfmt_andi_compact.f
193   sem_status status = SEM_STATUS_NORMAL;
194   sh2e_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 sh2e_sem_andb_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
214         sh2e::write_stacks &buf)
215 {
216 #define FLD(f) abuf->fields.sfmt_andi_compact.f
217   sem_status status = SEM_STATUS_NORMAL;
218   sh2e_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 sh2e_sem_bf_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
244         sh2e::write_stacks &buf)
245 {
246 #define FLD(f) abuf->fields.sfmt_bf_compact.f
247   sem_status status = SEM_STATUS_NORMAL;
248   sh2e_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 sh2e_sem_bfs_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
272         sh2e::write_stacks &buf)
273 {
274 #define FLD(f) abuf->fields.sfmt_bf_compact.f
275   sem_status status = SEM_STATUS_NORMAL;
276   sh2e_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) % sh2e::pipe_sz].push (sh2e::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 sh2e_sem_bra_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
309         sh2e::write_stacks &buf)
310 {
311 #define FLD(f) abuf->fields.sfmt_bra_compact.f
312   sem_status status = SEM_STATUS_NORMAL;
313   sh2e_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) % sh2e::pipe_sz].push (sh2e::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 sh2e_sem_braf_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
342         sh2e::write_stacks &buf)
343 {
344 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
345   sem_status status = SEM_STATUS_NORMAL;
346   sh2e_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) % sh2e::pipe_sz].push (sh2e::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 sh2e_sem_bsr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
375         sh2e::write_stacks &buf)
376 {
377 #define FLD(f) abuf->fields.sfmt_bra_compact.f
378   sem_status status = SEM_STATUS_NORMAL;
379   sh2e_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) % sh2e::pipe_sz].push (sh2e::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) % sh2e::pipe_sz].push (sh2e::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 sh2e_sem_bsrf_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
414         sh2e::write_stacks &buf)
415 {
416 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
417   sem_status status = SEM_STATUS_NORMAL;
418   sh2e_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) % sh2e::pipe_sz].push (sh2e::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) % sh2e::pipe_sz].push (sh2e::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 sh2e_sem_bt_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
453         sh2e::write_stacks &buf)
454 {
455 #define FLD(f) abuf->fields.sfmt_bf_compact.f
456   sem_status status = SEM_STATUS_NORMAL;
457   sh2e_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 sh2e_sem_bts_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
481         sh2e::write_stacks &buf)
482 {
483 #define FLD(f) abuf->fields.sfmt_bf_compact.f
484   sem_status status = SEM_STATUS_NORMAL;
485   sh2e_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) % sh2e::pipe_sz].push (sh2e::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 sh2e_sem_clrmac_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
518         sh2e::write_stacks &buf)
519 {
520 #define FLD(f) abuf->fields.fmt_empty.f
521   sem_status status = SEM_STATUS_NORMAL;
522   sh2e_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 sh2e_sem_clrt_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
550         sh2e::write_stacks &buf)
551 {
552 #define FLD(f) abuf->fields.fmt_empty.f
553   sem_status status = SEM_STATUS_NORMAL;
554   sh2e_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 sh2e_sem_cmpeq_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
574         sh2e::write_stacks &buf)
575 {
576 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
577   sem_status status = SEM_STATUS_NORMAL;
578   sh2e_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 sh2e_sem_cmpeqi_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
598         sh2e::write_stacks &buf)
599 {
600 #define FLD(f) abuf->fields.sfmt_andi_compact.f
601   sem_status status = SEM_STATUS_NORMAL;
602   sh2e_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 sh2e_sem_cmpge_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
622         sh2e::write_stacks &buf)
623 {
624 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
625   sem_status status = SEM_STATUS_NORMAL;
626   sh2e_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 sh2e_sem_cmpgt_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
646         sh2e::write_stacks &buf)
647 {
648 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
649   sem_status status = SEM_STATUS_NORMAL;
650   sh2e_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 sh2e_sem_cmphi_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
670         sh2e::write_stacks &buf)
671 {
672 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
673   sem_status status = SEM_STATUS_NORMAL;
674   sh2e_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 sh2e_sem_cmphs_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
694         sh2e::write_stacks &buf)
695 {
696 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
697   sem_status status = SEM_STATUS_NORMAL;
698   sh2e_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 sh2e_sem_cmppl_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
718         sh2e::write_stacks &buf)
719 {
720 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
721   sem_status status = SEM_STATUS_NORMAL;
722   sh2e_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 sh2e_sem_cmppz_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
742         sh2e::write_stacks &buf)
743 {
744 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
745   sem_status status = SEM_STATUS_NORMAL;
746   sh2e_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 sh2e_sem_cmpstr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
766         sh2e::write_stacks &buf)
767 {
768 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
769   sem_status status = SEM_STATUS_NORMAL;
770   sh2e_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 sh2e_sem_div0s_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
799         sh2e::write_stacks &buf)
800 {
801 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
802   sem_status status = SEM_STATUS_NORMAL;
803   sh2e_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 sh2e_sem_div0u_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
837         sh2e::write_stacks &buf)
838 {
839 #define FLD(f) abuf->fields.fmt_empty.f
840   sem_status status = SEM_STATUS_NORMAL;
841   sh2e_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 sh2e_sem_div1_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
875         sh2e::write_stacks &buf)
876 {
877 #define FLD(f) abuf->fields.sfmt_macl_compact.f
878   sem_status status = SEM_STATUS_NORMAL;
879   sh2e_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 sh2e_sem_dmulsl_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1026         sh2e::write_stacks &buf)
1027 {
1028 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
1029   sem_status status = SEM_STATUS_NORMAL;
1030   sh2e_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 sh2e_sem_dmulul_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1060         sh2e::write_stacks &buf)
1061 {
1062 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
1063   sem_status status = SEM_STATUS_NORMAL;
1064   sh2e_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 sh2e_sem_dt_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1094         sh2e::write_stacks &buf)
1095 {
1096 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
1097   sem_status status = SEM_STATUS_NORMAL;
1098   sh2e_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 sh2e_sem_extsb_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1126         sh2e::write_stacks &buf)
1127 {
1128 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
1129   sem_status status = SEM_STATUS_NORMAL;
1130   sh2e_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 sh2e_sem_extsw_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1150         sh2e::write_stacks &buf)
1151 {
1152 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
1153   sem_status status = SEM_STATUS_NORMAL;
1154   sh2e_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 sh2e_sem_extub_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1174         sh2e::write_stacks &buf)
1175 {
1176 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
1177   sem_status status = SEM_STATUS_NORMAL;
1178   sh2e_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 sh2e_sem_extuw_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1198         sh2e::write_stacks &buf)
1199 {
1200 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
1201   sem_status status = SEM_STATUS_NORMAL;
1202   sh2e_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 // ********** fabs-compact: fabs $fsdn
1219
1220 void
1221 sh2e_sem_fabs_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1222         sh2e::write_stacks &buf)
1223 {
1224 #define FLD(f) abuf->fields.sfmt_fadd_compact.f
1225   sem_status status = SEM_STATUS_NORMAL;
1226   sh2e_scache* abuf = sem;
1227   unsigned long long written = 0;
1228   PCADDR pc = abuf->addr;
1229   PCADDR npc = pc + 2;
1230
1231 if (current_cpu->h_prbit_get ()) {
1232   {
1233     DF opval = current_cpu->sh64_fabsd (current_cpu->h_fsd_get (FLD (f_rn)));
1234     written |= (1ULL << 2);
1235     if (UNLIKELY(current_cpu->trace_result_p))
1236       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1237     current_cpu->h_fsd_set (FLD (f_rn), opval);
1238   }
1239 } else {
1240   {
1241     DF opval = current_cpu->sh64_fabss (current_cpu->h_fsd_get (FLD (f_rn)));
1242     written |= (1ULL << 2);
1243     if (UNLIKELY(current_cpu->trace_result_p))
1244       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1245     current_cpu->h_fsd_set (FLD (f_rn), opval);
1246   }
1247 }
1248
1249   abuf->written = written;
1250   current_cpu->done_insn (npc, status);
1251 #undef FLD
1252 }
1253
1254 // ********** fadd-compact: fadd $fsdm, $fsdn
1255
1256 void
1257 sh2e_sem_fadd_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1258         sh2e::write_stacks &buf)
1259 {
1260 #define FLD(f) abuf->fields.sfmt_fadd_compact.f
1261   sem_status status = SEM_STATUS_NORMAL;
1262   sh2e_scache* abuf = sem;
1263   unsigned long long written = 0;
1264   PCADDR pc = abuf->addr;
1265   PCADDR npc = pc + 2;
1266
1267 if (current_cpu->h_prbit_get ()) {
1268   {
1269     DF opval = current_cpu->sh64_faddd (current_cpu->h_fsd_get (FLD (f_rm)), current_cpu->h_fsd_get (FLD (f_rn)));
1270     written |= (1ULL << 3);
1271     if (UNLIKELY(current_cpu->trace_result_p))
1272       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1273     current_cpu->h_fsd_set (FLD (f_rn), opval);
1274   }
1275 } else {
1276   {
1277     DF opval = current_cpu->sh64_fadds (current_cpu->h_fsd_get (FLD (f_rm)), current_cpu->h_fsd_get (FLD (f_rn)));
1278     written |= (1ULL << 3);
1279     if (UNLIKELY(current_cpu->trace_result_p))
1280       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1281     current_cpu->h_fsd_set (FLD (f_rn), opval);
1282   }
1283 }
1284
1285   abuf->written = written;
1286   current_cpu->done_insn (npc, status);
1287 #undef FLD
1288 }
1289
1290 // ********** fcmpeq-compact: fcmp/eq $fsdm, $fsdn
1291
1292 void
1293 sh2e_sem_fcmpeq_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1294         sh2e::write_stacks &buf)
1295 {
1296 #define FLD(f) abuf->fields.sfmt_fadd_compact.f
1297   sem_status status = SEM_STATUS_NORMAL;
1298   sh2e_scache* abuf = sem;
1299   unsigned long long written = 0;
1300   PCADDR pc = abuf->addr;
1301   PCADDR npc = pc + 2;
1302
1303 if (current_cpu->h_prbit_get ()) {
1304   {
1305     BI opval = current_cpu->sh64_fcmpeqd (current_cpu->h_fsd_get (FLD (f_rm)), current_cpu->h_fsd_get (FLD (f_rn)));
1306     written |= (1ULL << 3);
1307     if (UNLIKELY(current_cpu->trace_result_p))
1308       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
1309     current_cpu->h_tbit_set (opval);
1310   }
1311 } else {
1312   {
1313     BI opval = current_cpu->sh64_fcmpeqs (current_cpu->h_fsd_get (FLD (f_rm)), current_cpu->h_fsd_get (FLD (f_rn)));
1314     written |= (1ULL << 3);
1315     if (UNLIKELY(current_cpu->trace_result_p))
1316       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
1317     current_cpu->h_tbit_set (opval);
1318   }
1319 }
1320
1321   abuf->written = written;
1322   current_cpu->done_insn (npc, status);
1323 #undef FLD
1324 }
1325
1326 // ********** fcmpgt-compact: fcmp/gt $fsdm, $fsdn
1327
1328 void
1329 sh2e_sem_fcmpgt_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1330         sh2e::write_stacks &buf)
1331 {
1332 #define FLD(f) abuf->fields.sfmt_fadd_compact.f
1333   sem_status status = SEM_STATUS_NORMAL;
1334   sh2e_scache* abuf = sem;
1335   unsigned long long written = 0;
1336   PCADDR pc = abuf->addr;
1337   PCADDR npc = pc + 2;
1338
1339 if (current_cpu->h_prbit_get ()) {
1340   {
1341     BI opval = current_cpu->sh64_fcmpgtd (current_cpu->h_fsd_get (FLD (f_rn)), current_cpu->h_fsd_get (FLD (f_rm)));
1342     written |= (1ULL << 3);
1343     if (UNLIKELY(current_cpu->trace_result_p))
1344       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
1345     current_cpu->h_tbit_set (opval);
1346   }
1347 } else {
1348   {
1349     BI opval = current_cpu->sh64_fcmpgts (current_cpu->h_fsd_get (FLD (f_rn)), current_cpu->h_fsd_get (FLD (f_rm)));
1350     written |= (1ULL << 3);
1351     if (UNLIKELY(current_cpu->trace_result_p))
1352       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
1353     current_cpu->h_tbit_set (opval);
1354   }
1355 }
1356
1357   abuf->written = written;
1358   current_cpu->done_insn (npc, status);
1359 #undef FLD
1360 }
1361
1362 // ********** fdiv-compact: fdiv $fsdm, $fsdn
1363
1364 void
1365 sh2e_sem_fdiv_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1366         sh2e::write_stacks &buf)
1367 {
1368 #define FLD(f) abuf->fields.sfmt_fadd_compact.f
1369   sem_status status = SEM_STATUS_NORMAL;
1370   sh2e_scache* abuf = sem;
1371   unsigned long long written = 0;
1372   PCADDR pc = abuf->addr;
1373   PCADDR npc = pc + 2;
1374
1375 if (current_cpu->h_prbit_get ()) {
1376   {
1377     DF opval = current_cpu->sh64_fdivd (current_cpu->h_fsd_get (FLD (f_rn)), current_cpu->h_fsd_get (FLD (f_rm)));
1378     written |= (1ULL << 3);
1379     if (UNLIKELY(current_cpu->trace_result_p))
1380       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1381     current_cpu->h_fsd_set (FLD (f_rn), opval);
1382   }
1383 } else {
1384   {
1385     DF opval = current_cpu->sh64_fdivs (current_cpu->h_fsd_get (FLD (f_rn)), current_cpu->h_fsd_get (FLD (f_rm)));
1386     written |= (1ULL << 3);
1387     if (UNLIKELY(current_cpu->trace_result_p))
1388       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1389     current_cpu->h_fsd_set (FLD (f_rn), opval);
1390   }
1391 }
1392
1393   abuf->written = written;
1394   current_cpu->done_insn (npc, status);
1395 #undef FLD
1396 }
1397
1398 // ********** flds-compact: flds $frn, fpul
1399
1400 void
1401 sh2e_sem_flds_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1402         sh2e::write_stacks &buf)
1403 {
1404 #define FLD(f) abuf->fields.sfmt_flds_compact.f
1405   sem_status status = SEM_STATUS_NORMAL;
1406   sh2e_scache* abuf = sem;
1407   unsigned long long written = 0;
1408   PCADDR pc = abuf->addr;
1409   PCADDR npc = pc + 2;
1410
1411   {
1412     SF opval = current_cpu->h_frc_get (FLD (f_rn));
1413     if (UNLIKELY(current_cpu->trace_result_p))
1414       current_cpu->trace_stream << "fr" << '[' << ((UINT) 32) << ']' << ":=0x" << hex << opval << dec << "  ";
1415     current_cpu->hardware.h_fr[((UINT) 32)] = opval;
1416   }
1417
1418   current_cpu->done_insn (npc, status);
1419 #undef FLD
1420 }
1421
1422 // ********** fldi0-compact: fldi0 $frn
1423
1424 void
1425 sh2e_sem_fldi0_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1426         sh2e::write_stacks &buf)
1427 {
1428 #define FLD(f) abuf->fields.sfmt_fsts_compact.f
1429   sem_status status = SEM_STATUS_NORMAL;
1430   sh2e_scache* abuf = sem;
1431   unsigned long long written = 0;
1432   PCADDR pc = abuf->addr;
1433   PCADDR npc = pc + 2;
1434
1435   {
1436     SF opval = current_cpu->sh64_fldi0 ();
1437     if (UNLIKELY(current_cpu->trace_result_p))
1438       current_cpu->trace_stream << "frc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1439     current_cpu->h_frc_set (FLD (f_rn), opval);
1440   }
1441
1442   current_cpu->done_insn (npc, status);
1443 #undef FLD
1444 }
1445
1446 // ********** fldi1-compact: fldi1 $frn
1447
1448 void
1449 sh2e_sem_fldi1_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1450         sh2e::write_stacks &buf)
1451 {
1452 #define FLD(f) abuf->fields.sfmt_fsts_compact.f
1453   sem_status status = SEM_STATUS_NORMAL;
1454   sh2e_scache* abuf = sem;
1455   unsigned long long written = 0;
1456   PCADDR pc = abuf->addr;
1457   PCADDR npc = pc + 2;
1458
1459   {
1460     SF opval = current_cpu->sh64_fldi1 ();
1461     if (UNLIKELY(current_cpu->trace_result_p))
1462       current_cpu->trace_stream << "frc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1463     current_cpu->h_frc_set (FLD (f_rn), opval);
1464   }
1465
1466   current_cpu->done_insn (npc, status);
1467 #undef FLD
1468 }
1469
1470 // ********** float-compact: float fpul, $fsdn
1471
1472 void
1473 sh2e_sem_float_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1474         sh2e::write_stacks &buf)
1475 {
1476 #define FLD(f) abuf->fields.sfmt_float_compact.f
1477   sem_status status = SEM_STATUS_NORMAL;
1478   sh2e_scache* abuf = sem;
1479   unsigned long long written = 0;
1480   PCADDR pc = abuf->addr;
1481   PCADDR npc = pc + 2;
1482
1483 if (current_cpu->h_prbit_get ()) {
1484   {
1485     DF opval = current_cpu->sh64_floatld (current_cpu->hardware.h_fr[((UINT) 32)]);
1486     written |= (1ULL << 2);
1487     if (UNLIKELY(current_cpu->trace_result_p))
1488       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1489     current_cpu->h_fsd_set (FLD (f_rn), opval);
1490   }
1491 } else {
1492   {
1493     DF opval = current_cpu->sh64_floatls (current_cpu->hardware.h_fr[((UINT) 32)]);
1494     written |= (1ULL << 2);
1495     if (UNLIKELY(current_cpu->trace_result_p))
1496       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1497     current_cpu->h_fsd_set (FLD (f_rn), opval);
1498   }
1499 }
1500
1501   abuf->written = written;
1502   current_cpu->done_insn (npc, status);
1503 #undef FLD
1504 }
1505
1506 // ********** fmac-compact: fmac fr0, $frm, $frn
1507
1508 void
1509 sh2e_sem_fmac_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1510         sh2e::write_stacks &buf)
1511 {
1512 #define FLD(f) abuf->fields.sfmt_fmac_compact.f
1513   sem_status status = SEM_STATUS_NORMAL;
1514   sh2e_scache* abuf = sem;
1515   unsigned long long written = 0;
1516   PCADDR pc = abuf->addr;
1517   PCADDR npc = pc + 2;
1518
1519   {
1520     SF opval = current_cpu->sh64_fmacs (current_cpu->h_frc_get (((UINT) 0)), current_cpu->h_frc_get (FLD (f_rm)), current_cpu->h_frc_get (FLD (f_rn)));
1521     if (UNLIKELY(current_cpu->trace_result_p))
1522       current_cpu->trace_stream << "frc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1523     current_cpu->h_frc_set (FLD (f_rn), opval);
1524   }
1525
1526   current_cpu->done_insn (npc, status);
1527 #undef FLD
1528 }
1529
1530 // ********** fmov1-compact: fmov $fmovm, $fmovn
1531
1532 void
1533 sh2e_sem_fmov1_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1534         sh2e::write_stacks &buf)
1535 {
1536 #define FLD(f) abuf->fields.sfmt_fmov1_compact.f
1537   sem_status status = SEM_STATUS_NORMAL;
1538   sh2e_scache* abuf = sem;
1539   unsigned long long written = 0;
1540   PCADDR pc = abuf->addr;
1541   PCADDR npc = pc + 2;
1542
1543   {
1544     DF opval = current_cpu->h_fmov_get (FLD (f_rm));
1545     if (UNLIKELY(current_cpu->trace_result_p))
1546       current_cpu->trace_stream << "fmov" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1547     current_cpu->h_fmov_set (FLD (f_rn), opval);
1548   }
1549
1550   current_cpu->done_insn (npc, status);
1551 #undef FLD
1552 }
1553
1554 // ********** fmov2-compact: fmov @$rm, $fmovn
1555
1556 void
1557 sh2e_sem_fmov2_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1558         sh2e::write_stacks &buf)
1559 {
1560 #define FLD(f) abuf->fields.sfmt_fmov4_compact.f
1561   sem_status status = SEM_STATUS_NORMAL;
1562   sh2e_scache* abuf = sem;
1563   unsigned long long written = 0;
1564   PCADDR pc = abuf->addr;
1565   PCADDR npc = pc + 2;
1566
1567 if (NOTBI (current_cpu->h_szbit_get ())) {
1568   {
1569     DF opval = current_cpu->GETMEMSF (pc, current_cpu->h_grc_get (FLD (f_rm)));
1570     written |= (1ULL << 4);
1571     if (UNLIKELY(current_cpu->trace_result_p))
1572       current_cpu->trace_stream << "fmov" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1573     current_cpu->h_fmov_set (FLD (f_rn), opval);
1574   }
1575 } else {
1576   {
1577     DF opval = current_cpu->GETMEMDF (pc, current_cpu->h_grc_get (FLD (f_rm)));
1578     written |= (1ULL << 4);
1579     if (UNLIKELY(current_cpu->trace_result_p))
1580       current_cpu->trace_stream << "fmov" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1581     current_cpu->h_fmov_set (FLD (f_rn), opval);
1582   }
1583 }
1584
1585   abuf->written = written;
1586   current_cpu->done_insn (npc, status);
1587 #undef FLD
1588 }
1589
1590 // ********** fmov3-compact: fmov @${rm}+, fmovn
1591
1592 void
1593 sh2e_sem_fmov3_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1594         sh2e::write_stacks &buf)
1595 {
1596 #define FLD(f) abuf->fields.sfmt_fmov3_compact.f
1597   sem_status status = SEM_STATUS_NORMAL;
1598   sh2e_scache* abuf = sem;
1599   unsigned long long written = 0;
1600   PCADDR pc = abuf->addr;
1601   PCADDR npc = pc + 2;
1602
1603 if (NOTBI (current_cpu->h_szbit_get ())) {
1604 {
1605   {
1606     DF opval = current_cpu->GETMEMSF (pc, current_cpu->h_grc_get (FLD (f_rm)));
1607     written |= (1ULL << 4);
1608     if (UNLIKELY(current_cpu->trace_result_p))
1609       current_cpu->trace_stream << "fmov" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1610     current_cpu->h_fmov_set (FLD (f_rn), opval);
1611   }
1612   {
1613     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 4);
1614     written |= (1ULL << 5);
1615     if (UNLIKELY(current_cpu->trace_result_p))
1616       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
1617     current_cpu->h_grc_set (FLD (f_rm), opval);
1618   }
1619 }
1620 } else {
1621 {
1622   {
1623     DF opval = current_cpu->GETMEMDF (pc, current_cpu->h_grc_get (FLD (f_rm)));
1624     written |= (1ULL << 4);
1625     if (UNLIKELY(current_cpu->trace_result_p))
1626       current_cpu->trace_stream << "fmov" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1627     current_cpu->h_fmov_set (FLD (f_rn), opval);
1628   }
1629   {
1630     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 8);
1631     written |= (1ULL << 5);
1632     if (UNLIKELY(current_cpu->trace_result_p))
1633       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
1634     current_cpu->h_grc_set (FLD (f_rm), opval);
1635   }
1636 }
1637 }
1638
1639   abuf->written = written;
1640   current_cpu->done_insn (npc, status);
1641 #undef FLD
1642 }
1643
1644 // ********** fmov4-compact: fmov @(r0, $rm), $fmovn
1645
1646 void
1647 sh2e_sem_fmov4_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1648         sh2e::write_stacks &buf)
1649 {
1650 #define FLD(f) abuf->fields.sfmt_fmov4_compact.f
1651   sem_status status = SEM_STATUS_NORMAL;
1652   sh2e_scache* abuf = sem;
1653   unsigned long long written = 0;
1654   PCADDR pc = abuf->addr;
1655   PCADDR npc = pc + 2;
1656
1657 if (NOTBI (current_cpu->h_szbit_get ())) {
1658   {
1659     DF opval = current_cpu->GETMEMSF (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rm))));
1660     written |= (1ULL << 5);
1661     if (UNLIKELY(current_cpu->trace_result_p))
1662       current_cpu->trace_stream << "fmov" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1663     current_cpu->h_fmov_set (FLD (f_rn), opval);
1664   }
1665 } else {
1666   {
1667     DF opval = current_cpu->GETMEMDF (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rm))));
1668     written |= (1ULL << 5);
1669     if (UNLIKELY(current_cpu->trace_result_p))
1670       current_cpu->trace_stream << "fmov" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1671     current_cpu->h_fmov_set (FLD (f_rn), opval);
1672   }
1673 }
1674
1675   abuf->written = written;
1676   current_cpu->done_insn (npc, status);
1677 #undef FLD
1678 }
1679
1680 // ********** fmov5-compact: fmov $fmovm, @$rn
1681
1682 void
1683 sh2e_sem_fmov5_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1684         sh2e::write_stacks &buf)
1685 {
1686 #define FLD(f) abuf->fields.sfmt_fmov7_compact.f
1687   sem_status status = SEM_STATUS_NORMAL;
1688   sh2e_scache* abuf = sem;
1689   unsigned long long written = 0;
1690   PCADDR pc = abuf->addr;
1691   PCADDR npc = pc + 2;
1692
1693 if (NOTBI (current_cpu->h_szbit_get ())) {
1694   {
1695     SF opval = current_cpu->h_fmov_get (FLD (f_rm));
1696     written |= (1ULL << 4);
1697     if (UNLIKELY(current_cpu->trace_result_p))
1698       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
1699     current_cpu->SETMEMSF (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
1700   }
1701 } else {
1702   {
1703     DF opval = current_cpu->h_fmov_get (FLD (f_rm));
1704     written |= (1ULL << 3);
1705     if (UNLIKELY(current_cpu->trace_result_p))
1706       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
1707     current_cpu->SETMEMDF (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
1708   }
1709 }
1710
1711   abuf->written = written;
1712   current_cpu->done_insn (npc, status);
1713 #undef FLD
1714 }
1715
1716 // ********** fmov6-compact: fmov $fmovm, @-$rn
1717
1718 void
1719 sh2e_sem_fmov6_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1720         sh2e::write_stacks &buf)
1721 {
1722 #define FLD(f) abuf->fields.sfmt_fmov6_compact.f
1723   sem_status status = SEM_STATUS_NORMAL;
1724   sh2e_scache* abuf = sem;
1725   unsigned long long written = 0;
1726   PCADDR pc = abuf->addr;
1727   PCADDR npc = pc + 2;
1728
1729 if (NOTBI (current_cpu->h_szbit_get ())) {
1730 {
1731   {
1732     SI opval = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
1733     written |= (1ULL << 5);
1734     if (UNLIKELY(current_cpu->trace_result_p))
1735       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1736     current_cpu->h_grc_set (FLD (f_rn), opval);
1737   }
1738   {
1739     SF opval = current_cpu->h_fmov_get (FLD (f_rm));
1740     written |= (1ULL << 4);
1741     if (UNLIKELY(current_cpu->trace_result_p))
1742       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
1743     current_cpu->SETMEMSF (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
1744   }
1745 }
1746 } else {
1747 {
1748   {
1749     SI opval = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 8);
1750     written |= (1ULL << 5);
1751     if (UNLIKELY(current_cpu->trace_result_p))
1752       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1753     current_cpu->h_grc_set (FLD (f_rn), opval);
1754   }
1755   {
1756     DF opval = current_cpu->h_fmov_get (FLD (f_rm));
1757     written |= (1ULL << 3);
1758     if (UNLIKELY(current_cpu->trace_result_p))
1759       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
1760     current_cpu->SETMEMDF (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
1761   }
1762 }
1763 }
1764
1765   abuf->written = written;
1766   current_cpu->done_insn (npc, status);
1767 #undef FLD
1768 }
1769
1770 // ********** fmov7-compact: fmov $fmovm, @(r0, $rn)
1771
1772 void
1773 sh2e_sem_fmov7_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1774         sh2e::write_stacks &buf)
1775 {
1776 #define FLD(f) abuf->fields.sfmt_fmov7_compact.f
1777   sem_status status = SEM_STATUS_NORMAL;
1778   sh2e_scache* abuf = sem;
1779   unsigned long long written = 0;
1780   PCADDR pc = abuf->addr;
1781   PCADDR npc = pc + 2;
1782
1783 if (NOTBI (current_cpu->h_szbit_get ())) {
1784   {
1785     SF opval = current_cpu->h_fmov_get (FLD (f_rm));
1786     written |= (1ULL << 5);
1787     if (UNLIKELY(current_cpu->trace_result_p))
1788       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 << "  ";
1789     current_cpu->SETMEMSF (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))), opval);
1790   }
1791 } else {
1792   {
1793     DF opval = current_cpu->h_fmov_get (FLD (f_rm));
1794     written |= (1ULL << 4);
1795     if (UNLIKELY(current_cpu->trace_result_p))
1796       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 << "  ";
1797     current_cpu->SETMEMDF (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))), opval);
1798   }
1799 }
1800
1801   abuf->written = written;
1802   current_cpu->done_insn (npc, status);
1803 #undef FLD
1804 }
1805
1806 // ********** fmul-compact: fmul $fsdm, $fsdn
1807
1808 void
1809 sh2e_sem_fmul_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1810         sh2e::write_stacks &buf)
1811 {
1812 #define FLD(f) abuf->fields.sfmt_fadd_compact.f
1813   sem_status status = SEM_STATUS_NORMAL;
1814   sh2e_scache* abuf = sem;
1815   unsigned long long written = 0;
1816   PCADDR pc = abuf->addr;
1817   PCADDR npc = pc + 2;
1818
1819 if (current_cpu->h_prbit_get ()) {
1820   {
1821     DF opval = current_cpu->sh64_fmuld (current_cpu->h_fsd_get (FLD (f_rm)), current_cpu->h_fsd_get (FLD (f_rn)));
1822     written |= (1ULL << 3);
1823     if (UNLIKELY(current_cpu->trace_result_p))
1824       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1825     current_cpu->h_fsd_set (FLD (f_rn), opval);
1826   }
1827 } else {
1828   {
1829     DF opval = current_cpu->sh64_fmuls (current_cpu->h_fsd_get (FLD (f_rm)), current_cpu->h_fsd_get (FLD (f_rn)));
1830     written |= (1ULL << 3);
1831     if (UNLIKELY(current_cpu->trace_result_p))
1832       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1833     current_cpu->h_fsd_set (FLD (f_rn), opval);
1834   }
1835 }
1836
1837   abuf->written = written;
1838   current_cpu->done_insn (npc, status);
1839 #undef FLD
1840 }
1841
1842 // ********** fneg-compact: fneg $fsdn
1843
1844 void
1845 sh2e_sem_fneg_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1846         sh2e::write_stacks &buf)
1847 {
1848 #define FLD(f) abuf->fields.sfmt_fadd_compact.f
1849   sem_status status = SEM_STATUS_NORMAL;
1850   sh2e_scache* abuf = sem;
1851   unsigned long long written = 0;
1852   PCADDR pc = abuf->addr;
1853   PCADDR npc = pc + 2;
1854
1855 if (current_cpu->h_prbit_get ()) {
1856   {
1857     DF opval = current_cpu->sh64_fnegd (current_cpu->h_fsd_get (FLD (f_rn)));
1858     written |= (1ULL << 2);
1859     if (UNLIKELY(current_cpu->trace_result_p))
1860       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1861     current_cpu->h_fsd_set (FLD (f_rn), opval);
1862   }
1863 } else {
1864   {
1865     DF opval = current_cpu->sh64_fnegs (current_cpu->h_fsd_get (FLD (f_rn)));
1866     written |= (1ULL << 2);
1867     if (UNLIKELY(current_cpu->trace_result_p))
1868       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1869     current_cpu->h_fsd_set (FLD (f_rn), opval);
1870   }
1871 }
1872
1873   abuf->written = written;
1874   current_cpu->done_insn (npc, status);
1875 #undef FLD
1876 }
1877
1878 // ********** frchg-compact: frchg
1879
1880 void
1881 sh2e_sem_frchg_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1882         sh2e::write_stacks &buf)
1883 {
1884 #define FLD(f) abuf->fields.fmt_empty.f
1885   sem_status status = SEM_STATUS_NORMAL;
1886   sh2e_scache* abuf = sem;
1887   unsigned long long written = 0;
1888   PCADDR pc = abuf->addr;
1889   PCADDR npc = pc + 2;
1890
1891   {
1892     BI opval = NOTBI (current_cpu->h_frbit_get ());
1893     if (UNLIKELY(current_cpu->trace_result_p))
1894       current_cpu->trace_stream << "frbit" << ":=0x" << hex << opval << dec << "  ";
1895     current_cpu->h_frbit_set (opval);
1896   }
1897
1898   current_cpu->done_insn (npc, status);
1899 #undef FLD
1900 }
1901
1902 // ********** fschg-compact: fschg
1903
1904 void
1905 sh2e_sem_fschg_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1906         sh2e::write_stacks &buf)
1907 {
1908 #define FLD(f) abuf->fields.fmt_empty.f
1909   sem_status status = SEM_STATUS_NORMAL;
1910   sh2e_scache* abuf = sem;
1911   unsigned long long written = 0;
1912   PCADDR pc = abuf->addr;
1913   PCADDR npc = pc + 2;
1914
1915   {
1916     BI opval = NOTBI (current_cpu->h_szbit_get ());
1917     if (UNLIKELY(current_cpu->trace_result_p))
1918       current_cpu->trace_stream << "szbit" << ":=0x" << hex << opval << dec << "  ";
1919     current_cpu->h_szbit_set (opval);
1920   }
1921
1922   current_cpu->done_insn (npc, status);
1923 #undef FLD
1924 }
1925
1926 // ********** fsts-compact: fsts fpul, $frn
1927
1928 void
1929 sh2e_sem_fsts_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1930         sh2e::write_stacks &buf)
1931 {
1932 #define FLD(f) abuf->fields.sfmt_fsts_compact.f
1933   sem_status status = SEM_STATUS_NORMAL;
1934   sh2e_scache* abuf = sem;
1935   unsigned long long written = 0;
1936   PCADDR pc = abuf->addr;
1937   PCADDR npc = pc + 2;
1938
1939   {
1940     SF opval = current_cpu->hardware.h_fr[((UINT) 32)];
1941     if (UNLIKELY(current_cpu->trace_result_p))
1942       current_cpu->trace_stream << "frc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1943     current_cpu->h_frc_set (FLD (f_rn), opval);
1944   }
1945
1946   current_cpu->done_insn (npc, status);
1947 #undef FLD
1948 }
1949
1950 // ********** fsub-compact: fsub $fsdm, $fsdn
1951
1952 void
1953 sh2e_sem_fsub_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1954         sh2e::write_stacks &buf)
1955 {
1956 #define FLD(f) abuf->fields.sfmt_fadd_compact.f
1957   sem_status status = SEM_STATUS_NORMAL;
1958   sh2e_scache* abuf = sem;
1959   unsigned long long written = 0;
1960   PCADDR pc = abuf->addr;
1961   PCADDR npc = pc + 2;
1962
1963 if (current_cpu->h_prbit_get ()) {
1964   {
1965     DF opval = current_cpu->sh64_fsubd (current_cpu->h_fsd_get (FLD (f_rn)), current_cpu->h_fsd_get (FLD (f_rm)));
1966     written |= (1ULL << 3);
1967     if (UNLIKELY(current_cpu->trace_result_p))
1968       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1969     current_cpu->h_fsd_set (FLD (f_rn), opval);
1970   }
1971 } else {
1972   {
1973     DF opval = current_cpu->sh64_fsubs (current_cpu->h_fsd_get (FLD (f_rn)), current_cpu->h_fsd_get (FLD (f_rm)));
1974     written |= (1ULL << 3);
1975     if (UNLIKELY(current_cpu->trace_result_p))
1976       current_cpu->trace_stream << "fsd" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
1977     current_cpu->h_fsd_set (FLD (f_rn), opval);
1978   }
1979 }
1980
1981   abuf->written = written;
1982   current_cpu->done_insn (npc, status);
1983 #undef FLD
1984 }
1985
1986 // ********** ftrc-compact: ftrc $fsdn, fpul
1987
1988 void
1989 sh2e_sem_ftrc_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
1990         sh2e::write_stacks &buf)
1991 {
1992 #define FLD(f) abuf->fields.sfmt_ftrc_compact.f
1993   sem_status status = SEM_STATUS_NORMAL;
1994   sh2e_scache* abuf = sem;
1995   unsigned long long written = 0;
1996   PCADDR pc = abuf->addr;
1997   PCADDR npc = pc + 2;
1998
1999   {
2000     SF opval = ((current_cpu->h_prbit_get ()) ? (current_cpu->sh64_ftrcdl (current_cpu->h_fsd_get (FLD (f_rn)))) : (current_cpu->sh64_ftrcsl (current_cpu->h_fsd_get (FLD (f_rn)))));
2001     if (UNLIKELY(current_cpu->trace_result_p))
2002       current_cpu->trace_stream << "fr" << '[' << ((UINT) 32) << ']' << ":=0x" << hex << opval << dec << "  ";
2003     current_cpu->hardware.h_fr[((UINT) 32)] = opval;
2004   }
2005
2006   current_cpu->done_insn (npc, status);
2007 #undef FLD
2008 }
2009
2010 // ********** jmp-compact: jmp @$rn
2011
2012 void
2013 sh2e_sem_jmp_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2014         sh2e::write_stacks &buf)
2015 {
2016 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2017   sem_status status = SEM_STATUS_NORMAL;
2018   sh2e_scache* abuf = sem;
2019   unsigned long long written = 0;
2020   PCADDR pc = abuf->addr;
2021   PCADDR npc = pc + 2;
2022
2023 {
2024   {
2025     UDI opval = ADDDI (pc, 2);
2026     if (UNLIKELY(current_cpu->trace_result_p))
2027       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
2028     current_cpu->branch (opval, npc, status);
2029   }
2030 current_cpu->save_delayed_pc (current_cpu->h_grc_get (FLD (f_rn)));
2031   {
2032     UDI opval = current_cpu->h_grc_get (FLD (f_rn));
2033     buf.h_pc_writes [(tick + 1) % sh2e::pipe_sz].push (sh2e::write<UDI>(pc, opval));
2034     if (UNLIKELY(current_cpu->trace_result_p))
2035       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
2036   }
2037 current_cpu->cg_profile (pc, current_cpu->h_grc_get (FLD (f_rn)));
2038 }
2039
2040   current_cpu->done_cti_insn (npc, status);
2041 #undef FLD
2042 }
2043
2044 // ********** jsr-compact: jsr @$rn
2045
2046 void
2047 sh2e_sem_jsr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2048         sh2e::write_stacks &buf)
2049 {
2050 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2051   sem_status status = SEM_STATUS_NORMAL;
2052   sh2e_scache* abuf = sem;
2053   unsigned long long written = 0;
2054   PCADDR pc = abuf->addr;
2055   PCADDR npc = pc + 2;
2056
2057 {
2058   {
2059     SI opval = ADDDI (pc, 4);
2060     buf.h_pr_writes [(tick + 1) % sh2e::pipe_sz].push (sh2e::write<SI>(pc, opval));
2061     if (UNLIKELY(current_cpu->trace_result_p))
2062       current_cpu->trace_stream << "pr" << ":=0x" << hex << opval << dec << "  ";
2063   }
2064   {
2065     UDI opval = ADDDI (pc, 2);
2066     if (UNLIKELY(current_cpu->trace_result_p))
2067       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
2068     current_cpu->branch (opval, npc, status);
2069   }
2070 current_cpu->save_delayed_pc (current_cpu->h_grc_get (FLD (f_rn)));
2071   {
2072     UDI opval = current_cpu->h_grc_get (FLD (f_rn));
2073     buf.h_pc_writes [(tick + 1) % sh2e::pipe_sz].push (sh2e::write<UDI>(pc, opval));
2074     if (UNLIKELY(current_cpu->trace_result_p))
2075       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
2076   }
2077 current_cpu->cg_profile (pc, current_cpu->h_grc_get (FLD (f_rn)));
2078 }
2079
2080   current_cpu->done_cti_insn (npc, status);
2081 #undef FLD
2082 }
2083
2084 // ********** ldc-gbr-compact: ldc $rn, gbr
2085
2086 void
2087 sh2e_sem_ldc_gbr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2088         sh2e::write_stacks &buf)
2089 {
2090 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2091   sem_status status = SEM_STATUS_NORMAL;
2092   sh2e_scache* abuf = sem;
2093   unsigned long long written = 0;
2094   PCADDR pc = abuf->addr;
2095   PCADDR npc = pc + 2;
2096
2097   {
2098     SI opval = current_cpu->h_grc_get (FLD (f_rn));
2099     if (UNLIKELY(current_cpu->trace_result_p))
2100       current_cpu->trace_stream << "gbr" << ":=0x" << hex << opval << dec << "  ";
2101     current_cpu->h_gbr_set (opval);
2102   }
2103
2104   current_cpu->done_insn (npc, status);
2105 #undef FLD
2106 }
2107
2108 // ********** ldc-vbr-compact: ldc $rn, vbr
2109
2110 void
2111 sh2e_sem_ldc_vbr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2112         sh2e::write_stacks &buf)
2113 {
2114 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2115   sem_status status = SEM_STATUS_NORMAL;
2116   sh2e_scache* abuf = sem;
2117   unsigned long long written = 0;
2118   PCADDR pc = abuf->addr;
2119   PCADDR npc = pc + 2;
2120
2121   {
2122     SI opval = current_cpu->h_grc_get (FLD (f_rn));
2123     if (UNLIKELY(current_cpu->trace_result_p))
2124       current_cpu->trace_stream << "vbr" << ":=0x" << hex << opval << dec << "  ";
2125     current_cpu->h_vbr_set (opval);
2126   }
2127
2128   current_cpu->done_insn (npc, status);
2129 #undef FLD
2130 }
2131
2132 // ********** ldc-sr-compact: ldc $rn, sr
2133
2134 void
2135 sh2e_sem_ldc_sr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2136         sh2e::write_stacks &buf)
2137 {
2138 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2139   sem_status status = SEM_STATUS_NORMAL;
2140   sh2e_scache* abuf = sem;
2141   unsigned long long written = 0;
2142   PCADDR pc = abuf->addr;
2143   PCADDR npc = pc + 2;
2144
2145   {
2146     SI opval = current_cpu->h_grc_get (FLD (f_rn));
2147     if (UNLIKELY(current_cpu->trace_result_p))
2148       current_cpu->trace_stream << "sr" << ":=0x" << hex << opval << dec << "  ";
2149     current_cpu->hardware.h_sr = opval;
2150   }
2151
2152   current_cpu->done_insn (npc, status);
2153 #undef FLD
2154 }
2155
2156 // ********** ldcl-gbr-compact: ldc.l @${rn}+, gbr
2157
2158 void
2159 sh2e_sem_ldcl_gbr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2160         sh2e::write_stacks &buf)
2161 {
2162 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2163   sem_status status = SEM_STATUS_NORMAL;
2164   sh2e_scache* abuf = sem;
2165   unsigned long long written = 0;
2166   PCADDR pc = abuf->addr;
2167   PCADDR npc = pc + 2;
2168
2169 {
2170   {
2171     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
2172     if (UNLIKELY(current_cpu->trace_result_p))
2173       current_cpu->trace_stream << "gbr" << ":=0x" << hex << opval << dec << "  ";
2174     current_cpu->h_gbr_set (opval);
2175   }
2176   {
2177     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
2178     if (UNLIKELY(current_cpu->trace_result_p))
2179       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2180     current_cpu->h_grc_set (FLD (f_rn), opval);
2181   }
2182 }
2183
2184   current_cpu->done_insn (npc, status);
2185 #undef FLD
2186 }
2187
2188 // ********** ldcl-vbr-compact: ldc.l @${rn}+, vbr
2189
2190 void
2191 sh2e_sem_ldcl_vbr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2192         sh2e::write_stacks &buf)
2193 {
2194 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2195   sem_status status = SEM_STATUS_NORMAL;
2196   sh2e_scache* abuf = sem;
2197   unsigned long long written = 0;
2198   PCADDR pc = abuf->addr;
2199   PCADDR npc = pc + 2;
2200
2201 {
2202   {
2203     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
2204     if (UNLIKELY(current_cpu->trace_result_p))
2205       current_cpu->trace_stream << "vbr" << ":=0x" << hex << opval << dec << "  ";
2206     current_cpu->h_vbr_set (opval);
2207   }
2208   {
2209     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
2210     if (UNLIKELY(current_cpu->trace_result_p))
2211       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2212     current_cpu->h_grc_set (FLD (f_rn), opval);
2213   }
2214 }
2215
2216   current_cpu->done_insn (npc, status);
2217 #undef FLD
2218 }
2219
2220 // ********** lds-fpscr-compact: lds $rn, fpscr
2221
2222 void
2223 sh2e_sem_lds_fpscr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2224         sh2e::write_stacks &buf)
2225 {
2226 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2227   sem_status status = SEM_STATUS_NORMAL;
2228   sh2e_scache* abuf = sem;
2229   unsigned long long written = 0;
2230   PCADDR pc = abuf->addr;
2231   PCADDR npc = pc + 2;
2232
2233   {
2234     SI opval = current_cpu->h_grc_get (FLD (f_rn));
2235     if (UNLIKELY(current_cpu->trace_result_p))
2236       current_cpu->trace_stream << "fpscr" << ":=0x" << hex << opval << dec << "  ";
2237     current_cpu->hardware.h_fpscr = opval;
2238   }
2239
2240   current_cpu->done_insn (npc, status);
2241 #undef FLD
2242 }
2243
2244 // ********** ldsl-fpscr-compact: lds.l @${rn}+, fpscr
2245
2246 void
2247 sh2e_sem_ldsl_fpscr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2248         sh2e::write_stacks &buf)
2249 {
2250 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2251   sem_status status = SEM_STATUS_NORMAL;
2252   sh2e_scache* abuf = sem;
2253   unsigned long long written = 0;
2254   PCADDR pc = abuf->addr;
2255   PCADDR npc = pc + 2;
2256
2257 {
2258   {
2259     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
2260     if (UNLIKELY(current_cpu->trace_result_p))
2261       current_cpu->trace_stream << "fpscr" << ":=0x" << hex << opval << dec << "  ";
2262     current_cpu->hardware.h_fpscr = opval;
2263   }
2264   {
2265     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
2266     if (UNLIKELY(current_cpu->trace_result_p))
2267       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2268     current_cpu->h_grc_set (FLD (f_rn), opval);
2269   }
2270 }
2271
2272   current_cpu->done_insn (npc, status);
2273 #undef FLD
2274 }
2275
2276 // ********** lds-fpul-compact: lds $rn, fpul
2277
2278 void
2279 sh2e_sem_lds_fpul_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2280         sh2e::write_stacks &buf)
2281 {
2282 #define FLD(f) abuf->fields.sfmt_ldsl_fpul_compact.f
2283   sem_status status = SEM_STATUS_NORMAL;
2284   sh2e_scache* abuf = sem;
2285   unsigned long long written = 0;
2286   PCADDR pc = abuf->addr;
2287   PCADDR npc = pc + 2;
2288
2289   {
2290     SF opval = SUBWORDSISF (current_cpu->h_grc_get (FLD (f_rn)));
2291     if (UNLIKELY(current_cpu->trace_result_p))
2292       current_cpu->trace_stream << "fr" << '[' << ((UINT) 32) << ']' << ":=0x" << hex << opval << dec << "  ";
2293     current_cpu->hardware.h_fr[((UINT) 32)] = opval;
2294   }
2295
2296   current_cpu->done_insn (npc, status);
2297 #undef FLD
2298 }
2299
2300 // ********** ldsl-fpul-compact: lds.l @${rn}+, fpul
2301
2302 void
2303 sh2e_sem_ldsl_fpul_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2304         sh2e::write_stacks &buf)
2305 {
2306 #define FLD(f) abuf->fields.sfmt_ldsl_fpul_compact.f
2307   sem_status status = SEM_STATUS_NORMAL;
2308   sh2e_scache* abuf = sem;
2309   unsigned long long written = 0;
2310   PCADDR pc = abuf->addr;
2311   PCADDR npc = pc + 2;
2312
2313 {
2314   {
2315     SF opval = current_cpu->GETMEMSF (pc, current_cpu->h_grc_get (FLD (f_rn)));
2316     if (UNLIKELY(current_cpu->trace_result_p))
2317       current_cpu->trace_stream << "fr" << '[' << ((UINT) 32) << ']' << ":=0x" << hex << opval << dec << "  ";
2318     current_cpu->hardware.h_fr[((UINT) 32)] = opval;
2319   }
2320   {
2321     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
2322     if (UNLIKELY(current_cpu->trace_result_p))
2323       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2324     current_cpu->h_grc_set (FLD (f_rn), opval);
2325   }
2326 }
2327
2328   current_cpu->done_insn (npc, status);
2329 #undef FLD
2330 }
2331
2332 // ********** lds-mach-compact: lds $rn, mach
2333
2334 void
2335 sh2e_sem_lds_mach_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2336         sh2e::write_stacks &buf)
2337 {
2338 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2339   sem_status status = SEM_STATUS_NORMAL;
2340   sh2e_scache* abuf = sem;
2341   unsigned long long written = 0;
2342   PCADDR pc = abuf->addr;
2343   PCADDR npc = pc + 2;
2344
2345   {
2346     SI opval = current_cpu->h_grc_get (FLD (f_rn));
2347     if (UNLIKELY(current_cpu->trace_result_p))
2348       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
2349     current_cpu->h_mach_set (opval);
2350   }
2351
2352   current_cpu->done_insn (npc, status);
2353 #undef FLD
2354 }
2355
2356 // ********** ldsl-mach-compact: lds.l @${rn}+, mach
2357
2358 void
2359 sh2e_sem_ldsl_mach_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2360         sh2e::write_stacks &buf)
2361 {
2362 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2363   sem_status status = SEM_STATUS_NORMAL;
2364   sh2e_scache* abuf = sem;
2365   unsigned long long written = 0;
2366   PCADDR pc = abuf->addr;
2367   PCADDR npc = pc + 2;
2368
2369 {
2370   {
2371     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
2372     if (UNLIKELY(current_cpu->trace_result_p))
2373       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
2374     current_cpu->h_mach_set (opval);
2375   }
2376   {
2377     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
2378     if (UNLIKELY(current_cpu->trace_result_p))
2379       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2380     current_cpu->h_grc_set (FLD (f_rn), opval);
2381   }
2382 }
2383
2384   current_cpu->done_insn (npc, status);
2385 #undef FLD
2386 }
2387
2388 // ********** lds-macl-compact: lds $rn, macl
2389
2390 void
2391 sh2e_sem_lds_macl_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2392         sh2e::write_stacks &buf)
2393 {
2394 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2395   sem_status status = SEM_STATUS_NORMAL;
2396   sh2e_scache* abuf = sem;
2397   unsigned long long written = 0;
2398   PCADDR pc = abuf->addr;
2399   PCADDR npc = pc + 2;
2400
2401   {
2402     SI opval = current_cpu->h_grc_get (FLD (f_rn));
2403     if (UNLIKELY(current_cpu->trace_result_p))
2404       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
2405     current_cpu->h_macl_set (opval);
2406   }
2407
2408   current_cpu->done_insn (npc, status);
2409 #undef FLD
2410 }
2411
2412 // ********** ldsl-macl-compact: lds.l @${rn}+, macl
2413
2414 void
2415 sh2e_sem_ldsl_macl_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2416         sh2e::write_stacks &buf)
2417 {
2418 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2419   sem_status status = SEM_STATUS_NORMAL;
2420   sh2e_scache* abuf = sem;
2421   unsigned long long written = 0;
2422   PCADDR pc = abuf->addr;
2423   PCADDR npc = pc + 2;
2424
2425 {
2426   {
2427     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
2428     if (UNLIKELY(current_cpu->trace_result_p))
2429       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
2430     current_cpu->h_macl_set (opval);
2431   }
2432   {
2433     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
2434     if (UNLIKELY(current_cpu->trace_result_p))
2435       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2436     current_cpu->h_grc_set (FLD (f_rn), opval);
2437   }
2438 }
2439
2440   current_cpu->done_insn (npc, status);
2441 #undef FLD
2442 }
2443
2444 // ********** lds-pr-compact: lds $rn, pr
2445
2446 void
2447 sh2e_sem_lds_pr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2448         sh2e::write_stacks &buf)
2449 {
2450 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2451   sem_status status = SEM_STATUS_NORMAL;
2452   sh2e_scache* abuf = sem;
2453   unsigned long long written = 0;
2454   PCADDR pc = abuf->addr;
2455   PCADDR npc = pc + 2;
2456
2457   {
2458     SI opval = current_cpu->h_grc_get (FLD (f_rn));
2459     if (UNLIKELY(current_cpu->trace_result_p))
2460       current_cpu->trace_stream << "pr" << ":=0x" << hex << opval << dec << "  ";
2461     current_cpu->h_pr_set (opval);
2462   }
2463
2464   current_cpu->done_insn (npc, status);
2465 #undef FLD
2466 }
2467
2468 // ********** ldsl-pr-compact: lds.l @${rn}+, pr
2469
2470 void
2471 sh2e_sem_ldsl_pr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2472         sh2e::write_stacks &buf)
2473 {
2474 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
2475   sem_status status = SEM_STATUS_NORMAL;
2476   sh2e_scache* abuf = sem;
2477   unsigned long long written = 0;
2478   PCADDR pc = abuf->addr;
2479   PCADDR npc = pc + 2;
2480
2481 {
2482   {
2483     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
2484     if (UNLIKELY(current_cpu->trace_result_p))
2485       current_cpu->trace_stream << "pr" << ":=0x" << hex << opval << dec << "  ";
2486     current_cpu->h_pr_set (opval);
2487   }
2488   {
2489     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
2490     if (UNLIKELY(current_cpu->trace_result_p))
2491       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2492     current_cpu->h_grc_set (FLD (f_rn), opval);
2493   }
2494 }
2495
2496   current_cpu->done_insn (npc, status);
2497 #undef FLD
2498 }
2499
2500 // ********** macl-compact: mac.l @${rm}+, @${rn}+
2501
2502 void
2503 sh2e_sem_macl_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2504         sh2e::write_stacks &buf)
2505 {
2506 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2507   sem_status status = SEM_STATUS_NORMAL;
2508   sh2e_scache* abuf = sem;
2509   unsigned long long written = 0;
2510   PCADDR pc = abuf->addr;
2511   PCADDR npc = pc + 2;
2512
2513 {
2514   DI tmp_tmpry;
2515   DI tmp_mac;
2516   DI tmp_result;
2517   SI tmp_x;
2518   SI tmp_y;
2519   tmp_x = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)));
2520   {
2521     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
2522     if (UNLIKELY(current_cpu->trace_result_p))
2523       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2524     current_cpu->h_grc_set (FLD (f_rn), opval);
2525   }
2526 if (EQSI (FLD (f_rn), FLD (f_rm))) {
2527 {
2528   {
2529     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
2530     if (UNLIKELY(current_cpu->trace_result_p))
2531       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2532     current_cpu->h_grc_set (FLD (f_rn), opval);
2533   }
2534   {
2535     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 4);
2536     written |= (1ULL << 11);
2537     if (UNLIKELY(current_cpu->trace_result_p))
2538       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2539     current_cpu->h_grc_set (FLD (f_rm), opval);
2540   }
2541 }
2542 }
2543   tmp_y = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rm)));
2544   {
2545     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 4);
2546     written |= (1ULL << 11);
2547     if (UNLIKELY(current_cpu->trace_result_p))
2548       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2549     current_cpu->h_grc_set (FLD (f_rm), opval);
2550   }
2551   tmp_tmpry = MULDI (ZEXTSIDI (tmp_x), ZEXTSIDI (tmp_y));
2552   tmp_mac = ORDI (SLLDI (ZEXTSIDI (current_cpu->h_mach_get ()), 32), ZEXTSIDI (current_cpu->h_macl_get ()));
2553   tmp_result = ADDDI (tmp_mac, tmp_tmpry);
2554 {
2555 if (current_cpu->h_sbit_get ()) {
2556 {
2557   SI tmp_min;
2558   SI tmp_max;
2559   tmp_max = SRLDI (INVDI (0), 16);
2560   tmp_min = SRLDI (INVDI (0), 15);
2561 if (GTDI (tmp_result, tmp_max)) {
2562   tmp_result = tmp_max;
2563 } else {
2564 if (LTDI (tmp_result, tmp_min)) {
2565   tmp_result = tmp_min;
2566 }
2567 }
2568 }
2569 }
2570   {
2571     SI opval = SUBWORDDISI (tmp_result, 0);
2572     if (UNLIKELY(current_cpu->trace_result_p))
2573       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
2574     current_cpu->h_mach_set (opval);
2575   }
2576   {
2577     SI opval = SUBWORDDISI (tmp_result, 1);
2578     if (UNLIKELY(current_cpu->trace_result_p))
2579       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
2580     current_cpu->h_macl_set (opval);
2581   }
2582 }
2583 }
2584
2585   abuf->written = written;
2586   current_cpu->done_insn (npc, status);
2587 #undef FLD
2588 }
2589
2590 // ********** macw-compact: mac.w @${rm}+, @${rn}+
2591
2592 void
2593 sh2e_sem_macw_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2594         sh2e::write_stacks &buf)
2595 {
2596 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2597   sem_status status = SEM_STATUS_NORMAL;
2598   sh2e_scache* abuf = sem;
2599   unsigned long long written = 0;
2600   PCADDR pc = abuf->addr;
2601   PCADDR npc = pc + 2;
2602
2603 {
2604   SI tmp_tmpry;
2605   DI tmp_mac;
2606   DI tmp_result;
2607   HI tmp_x;
2608   HI tmp_y;
2609   tmp_x = current_cpu->GETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rn)));
2610   {
2611     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
2612     if (UNLIKELY(current_cpu->trace_result_p))
2613       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2614     current_cpu->h_grc_set (FLD (f_rn), opval);
2615   }
2616 if (EQSI (FLD (f_rn), FLD (f_rm))) {
2617 {
2618   {
2619     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
2620     if (UNLIKELY(current_cpu->trace_result_p))
2621       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2622     current_cpu->h_grc_set (FLD (f_rn), opval);
2623   }
2624   {
2625     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 2);
2626     written |= (1ULL << 11);
2627     if (UNLIKELY(current_cpu->trace_result_p))
2628       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2629     current_cpu->h_grc_set (FLD (f_rm), opval);
2630   }
2631 }
2632 }
2633   tmp_y = current_cpu->GETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rm)));
2634   {
2635     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 2);
2636     written |= (1ULL << 11);
2637     if (UNLIKELY(current_cpu->trace_result_p))
2638       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2639     current_cpu->h_grc_set (FLD (f_rm), opval);
2640   }
2641   tmp_tmpry = MULSI (ZEXTHISI (tmp_x), ZEXTHISI (tmp_y));
2642 if (current_cpu->h_sbit_get ()) {
2643 {
2644 if (ADDOFSI (tmp_tmpry, current_cpu->h_macl_get (), 0)) {
2645   {
2646     SI opval = 1;
2647     written |= (1ULL << 9);
2648     if (UNLIKELY(current_cpu->trace_result_p))
2649       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
2650     current_cpu->h_mach_set (opval);
2651   }
2652 }
2653   {
2654     SI opval = ADDSI (tmp_tmpry, current_cpu->h_macl_get ());
2655     written |= (1ULL << 10);
2656     if (UNLIKELY(current_cpu->trace_result_p))
2657       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
2658     current_cpu->h_macl_set (opval);
2659   }
2660 }
2661 } else {
2662 {
2663   tmp_mac = ORDI (SLLDI (ZEXTSIDI (current_cpu->h_mach_get ()), 32), ZEXTSIDI (current_cpu->h_macl_get ()));
2664   tmp_result = ADDDI (tmp_mac, EXTSIDI (tmp_tmpry));
2665   {
2666     SI opval = SUBWORDDISI (tmp_result, 0);
2667     written |= (1ULL << 9);
2668     if (UNLIKELY(current_cpu->trace_result_p))
2669       current_cpu->trace_stream << "mach" << ":=0x" << hex << opval << dec << "  ";
2670     current_cpu->h_mach_set (opval);
2671   }
2672   {
2673     SI opval = SUBWORDDISI (tmp_result, 1);
2674     written |= (1ULL << 10);
2675     if (UNLIKELY(current_cpu->trace_result_p))
2676       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
2677     current_cpu->h_macl_set (opval);
2678   }
2679 }
2680 }
2681 }
2682
2683   abuf->written = written;
2684   current_cpu->done_insn (npc, status);
2685 #undef FLD
2686 }
2687
2688 // ********** mov-compact: mov $rm64, $rn64
2689
2690 void
2691 sh2e_sem_mov_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2692         sh2e::write_stacks &buf)
2693 {
2694 #define FLD(f) abuf->fields.sfmt_and_compact.f
2695   sem_status status = SEM_STATUS_NORMAL;
2696   sh2e_scache* abuf = sem;
2697   unsigned long long written = 0;
2698   PCADDR pc = abuf->addr;
2699   PCADDR npc = pc + 2;
2700
2701   {
2702     DI opval = current_cpu->h_gr_get (FLD (f_rm));
2703     if (UNLIKELY(current_cpu->trace_result_p))
2704       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2705     current_cpu->h_gr_set (FLD (f_rn), opval);
2706   }
2707
2708   current_cpu->done_insn (npc, status);
2709 #undef FLD
2710 }
2711
2712 // ********** movi-compact: mov #$imm8, $rn
2713
2714 void
2715 sh2e_sem_movi_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2716         sh2e::write_stacks &buf)
2717 {
2718 #define FLD(f) abuf->fields.sfmt_addi_compact.f
2719   sem_status status = SEM_STATUS_NORMAL;
2720   sh2e_scache* abuf = sem;
2721   unsigned long long written = 0;
2722   PCADDR pc = abuf->addr;
2723   PCADDR npc = pc + 2;
2724
2725   {
2726     SI opval = EXTQIDI (ANDQI (FLD (f_imm8), 255));
2727     if (UNLIKELY(current_cpu->trace_result_p))
2728       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2729     current_cpu->h_grc_set (FLD (f_rn), opval);
2730   }
2731
2732   current_cpu->done_insn (npc, status);
2733 #undef FLD
2734 }
2735
2736 // ********** movb1-compact: mov.b $rm, @$rn
2737
2738 void
2739 sh2e_sem_movb1_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2740         sh2e::write_stacks &buf)
2741 {
2742 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
2743   sem_status status = SEM_STATUS_NORMAL;
2744   sh2e_scache* abuf = sem;
2745   unsigned long long written = 0;
2746   PCADDR pc = abuf->addr;
2747   PCADDR npc = pc + 2;
2748
2749   {
2750     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (FLD (f_rm)), 3);
2751     if (UNLIKELY(current_cpu->trace_result_p))
2752       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
2753     current_cpu->SETMEMUQI (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
2754   }
2755
2756   current_cpu->done_insn (npc, status);
2757 #undef FLD
2758 }
2759
2760 // ********** movb2-compact: mov.b $rm, @-$rn
2761
2762 void
2763 sh2e_sem_movb2_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2764         sh2e::write_stacks &buf)
2765 {
2766 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2767   sem_status status = SEM_STATUS_NORMAL;
2768   sh2e_scache* abuf = sem;
2769   unsigned long long written = 0;
2770   PCADDR pc = abuf->addr;
2771   PCADDR npc = pc + 2;
2772
2773 {
2774   DI tmp_addr;
2775   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
2776   {
2777     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (FLD (f_rm)), 3);
2778     if (UNLIKELY(current_cpu->trace_result_p))
2779       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
2780     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
2781   }
2782   {
2783     SI opval = tmp_addr;
2784     if (UNLIKELY(current_cpu->trace_result_p))
2785       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2786     current_cpu->h_grc_set (FLD (f_rn), opval);
2787   }
2788 }
2789
2790   current_cpu->done_insn (npc, status);
2791 #undef FLD
2792 }
2793
2794 // ********** movb3-compact: mov.b $rm, @(r0,$rn)
2795
2796 void
2797 sh2e_sem_movb3_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2798         sh2e::write_stacks &buf)
2799 {
2800 #define FLD(f) abuf->fields.sfmt_movb3_compact.f
2801   sem_status status = SEM_STATUS_NORMAL;
2802   sh2e_scache* abuf = sem;
2803   unsigned long long written = 0;
2804   PCADDR pc = abuf->addr;
2805   PCADDR npc = pc + 2;
2806
2807   {
2808     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (FLD (f_rm)), 3);
2809     if (UNLIKELY(current_cpu->trace_result_p))
2810       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 << "  ";
2811     current_cpu->SETMEMUQI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))), opval);
2812   }
2813
2814   current_cpu->done_insn (npc, status);
2815 #undef FLD
2816 }
2817
2818 // ********** movb4-compact: mov.b r0, @($imm8, gbr)
2819
2820 void
2821 sh2e_sem_movb4_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2822         sh2e::write_stacks &buf)
2823 {
2824 #define FLD(f) abuf->fields.sfmt_andi_compact.f
2825   sem_status status = SEM_STATUS_NORMAL;
2826   sh2e_scache* abuf = sem;
2827   unsigned long long written = 0;
2828   PCADDR pc = abuf->addr;
2829   PCADDR npc = pc + 2;
2830
2831 {
2832   DI tmp_addr;
2833   tmp_addr = ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8));
2834   {
2835     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (((UINT) 0)), 3);
2836     if (UNLIKELY(current_cpu->trace_result_p))
2837       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
2838     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
2839   }
2840 }
2841
2842   current_cpu->done_insn (npc, status);
2843 #undef FLD
2844 }
2845
2846 // ********** movb5-compact: mov.b r0, @($imm4, $rm)
2847
2848 void
2849 sh2e_sem_movb5_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2850         sh2e::write_stacks &buf)
2851 {
2852 #define FLD(f) abuf->fields.sfmt_movb5_compact.f
2853   sem_status status = SEM_STATUS_NORMAL;
2854   sh2e_scache* abuf = sem;
2855   unsigned long long written = 0;
2856   PCADDR pc = abuf->addr;
2857   PCADDR npc = pc + 2;
2858
2859 {
2860   DI tmp_addr;
2861   tmp_addr = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4));
2862   {
2863     UQI opval = SUBWORDSIUQI (current_cpu->h_grc_get (((UINT) 0)), 3);
2864     if (UNLIKELY(current_cpu->trace_result_p))
2865       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
2866     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
2867   }
2868 }
2869
2870   current_cpu->done_insn (npc, status);
2871 #undef FLD
2872 }
2873
2874 // ********** movb6-compact: mov.b @$rm, $rn
2875
2876 void
2877 sh2e_sem_movb6_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2878         sh2e::write_stacks &buf)
2879 {
2880 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
2881   sem_status status = SEM_STATUS_NORMAL;
2882   sh2e_scache* abuf = sem;
2883   unsigned long long written = 0;
2884   PCADDR pc = abuf->addr;
2885   PCADDR npc = pc + 2;
2886
2887   {
2888     SI opval = EXTQISI (current_cpu->GETMEMQI (pc, current_cpu->h_grc_get (FLD (f_rm))));
2889     if (UNLIKELY(current_cpu->trace_result_p))
2890       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2891     current_cpu->h_grc_set (FLD (f_rn), opval);
2892   }
2893
2894   current_cpu->done_insn (npc, status);
2895 #undef FLD
2896 }
2897
2898 // ********** movb7-compact: mov.b @${rm}+, $rn
2899
2900 void
2901 sh2e_sem_movb7_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2902         sh2e::write_stacks &buf)
2903 {
2904 #define FLD(f) abuf->fields.sfmt_macl_compact.f
2905   sem_status status = SEM_STATUS_NORMAL;
2906   sh2e_scache* abuf = sem;
2907   unsigned long long written = 0;
2908   PCADDR pc = abuf->addr;
2909   PCADDR npc = pc + 2;
2910
2911 {
2912   QI tmp_data;
2913   tmp_data = current_cpu->GETMEMQI (pc, current_cpu->h_grc_get (FLD (f_rm)));
2914 if (EQSI (FLD (f_rm), FLD (f_rn))) {
2915   {
2916     SI opval = EXTQISI (tmp_data);
2917     written |= (1ULL << 4);
2918     if (UNLIKELY(current_cpu->trace_result_p))
2919       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2920     current_cpu->h_grc_set (FLD (f_rm), opval);
2921   }
2922 } else {
2923   {
2924     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 1);
2925     written |= (1ULL << 4);
2926     if (UNLIKELY(current_cpu->trace_result_p))
2927       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
2928     current_cpu->h_grc_set (FLD (f_rm), opval);
2929   }
2930 }
2931   {
2932     SI opval = EXTQISI (tmp_data);
2933     if (UNLIKELY(current_cpu->trace_result_p))
2934       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2935     current_cpu->h_grc_set (FLD (f_rn), opval);
2936   }
2937 }
2938
2939   abuf->written = written;
2940   current_cpu->done_insn (npc, status);
2941 #undef FLD
2942 }
2943
2944 // ********** movb8-compact: mov.b @(r0, $rm), $rn
2945
2946 void
2947 sh2e_sem_movb8_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2948         sh2e::write_stacks &buf)
2949 {
2950 #define FLD(f) abuf->fields.sfmt_movb8_compact.f
2951   sem_status status = SEM_STATUS_NORMAL;
2952   sh2e_scache* abuf = sem;
2953   unsigned long long written = 0;
2954   PCADDR pc = abuf->addr;
2955   PCADDR npc = pc + 2;
2956
2957   {
2958     SI opval = EXTQISI (current_cpu->GETMEMQI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rm)))));
2959     if (UNLIKELY(current_cpu->trace_result_p))
2960       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
2961     current_cpu->h_grc_set (FLD (f_rn), opval);
2962   }
2963
2964   current_cpu->done_insn (npc, status);
2965 #undef FLD
2966 }
2967
2968 // ********** movb9-compact: mov.b @($imm8, gbr), r0
2969
2970 void
2971 sh2e_sem_movb9_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2972         sh2e::write_stacks &buf)
2973 {
2974 #define FLD(f) abuf->fields.sfmt_andi_compact.f
2975   sem_status status = SEM_STATUS_NORMAL;
2976   sh2e_scache* abuf = sem;
2977   unsigned long long written = 0;
2978   PCADDR pc = abuf->addr;
2979   PCADDR npc = pc + 2;
2980
2981   {
2982     SI opval = EXTQISI (current_cpu->GETMEMQI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8))));
2983     if (UNLIKELY(current_cpu->trace_result_p))
2984       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
2985     current_cpu->h_grc_set (((UINT) 0), opval);
2986   }
2987
2988   current_cpu->done_insn (npc, status);
2989 #undef FLD
2990 }
2991
2992 // ********** movb10-compact: mov.b @($imm4, $rm), r0
2993
2994 void
2995 sh2e_sem_movb10_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
2996         sh2e::write_stacks &buf)
2997 {
2998 #define FLD(f) abuf->fields.sfmt_movb10_compact.f
2999   sem_status status = SEM_STATUS_NORMAL;
3000   sh2e_scache* abuf = sem;
3001   unsigned long long written = 0;
3002   PCADDR pc = abuf->addr;
3003   PCADDR npc = pc + 2;
3004
3005   {
3006     SI opval = EXTQISI (current_cpu->GETMEMQI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4))));
3007     if (UNLIKELY(current_cpu->trace_result_p))
3008       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
3009     current_cpu->h_grc_set (((UINT) 0), opval);
3010   }
3011
3012   current_cpu->done_insn (npc, status);
3013 #undef FLD
3014 }
3015
3016 // ********** movl1-compact: mov.l $rm, @$rn
3017
3018 void
3019 sh2e_sem_movl1_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3020         sh2e::write_stacks &buf)
3021 {
3022 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
3023   sem_status status = SEM_STATUS_NORMAL;
3024   sh2e_scache* abuf = sem;
3025   unsigned long long written = 0;
3026   PCADDR pc = abuf->addr;
3027   PCADDR npc = pc + 2;
3028
3029   {
3030     SI opval = current_cpu->h_grc_get (FLD (f_rm));
3031     if (UNLIKELY(current_cpu->trace_result_p))
3032       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3033     current_cpu->SETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
3034   }
3035
3036   current_cpu->done_insn (npc, status);
3037 #undef FLD
3038 }
3039
3040 // ********** movl2-compact: mov.l $rm, @-$rn
3041
3042 void
3043 sh2e_sem_movl2_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3044         sh2e::write_stacks &buf)
3045 {
3046 #define FLD(f) abuf->fields.sfmt_macl_compact.f
3047   sem_status status = SEM_STATUS_NORMAL;
3048   sh2e_scache* abuf = sem;
3049   unsigned long long written = 0;
3050   PCADDR pc = abuf->addr;
3051   PCADDR npc = pc + 2;
3052
3053 {
3054   SI tmp_addr;
3055   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
3056   {
3057     SI opval = current_cpu->h_grc_get (FLD (f_rm));
3058     if (UNLIKELY(current_cpu->trace_result_p))
3059       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3060     current_cpu->SETMEMSI (pc, tmp_addr, opval);
3061   }
3062   {
3063     SI opval = tmp_addr;
3064     if (UNLIKELY(current_cpu->trace_result_p))
3065       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3066     current_cpu->h_grc_set (FLD (f_rn), opval);
3067   }
3068 }
3069
3070   current_cpu->done_insn (npc, status);
3071 #undef FLD
3072 }
3073
3074 // ********** movl3-compact: mov.l $rm, @(r0, $rn)
3075
3076 void
3077 sh2e_sem_movl3_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3078         sh2e::write_stacks &buf)
3079 {
3080 #define FLD(f) abuf->fields.sfmt_movb3_compact.f
3081   sem_status status = SEM_STATUS_NORMAL;
3082   sh2e_scache* abuf = sem;
3083   unsigned long long written = 0;
3084   PCADDR pc = abuf->addr;
3085   PCADDR npc = pc + 2;
3086
3087   {
3088     SI opval = current_cpu->h_grc_get (FLD (f_rm));
3089     if (UNLIKELY(current_cpu->trace_result_p))
3090       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 << "  ";
3091     current_cpu->SETMEMSI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))), opval);
3092   }
3093
3094   current_cpu->done_insn (npc, status);
3095 #undef FLD
3096 }
3097
3098 // ********** movl4-compact: mov.l r0, @($imm8x4, gbr)
3099
3100 void
3101 sh2e_sem_movl4_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3102         sh2e::write_stacks &buf)
3103 {
3104 #define FLD(f) abuf->fields.sfmt_movl4_compact.f
3105   sem_status status = SEM_STATUS_NORMAL;
3106   sh2e_scache* abuf = sem;
3107   unsigned long long written = 0;
3108   PCADDR pc = abuf->addr;
3109   PCADDR npc = pc + 2;
3110
3111   {
3112     SI opval = current_cpu->h_grc_get (((UINT) 0));
3113     if (UNLIKELY(current_cpu->trace_result_p))
3114       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x4)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3115     current_cpu->SETMEMSI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x4)), opval);
3116   }
3117
3118   current_cpu->done_insn (npc, status);
3119 #undef FLD
3120 }
3121
3122 // ********** movl5-compact: mov.l $rm, @($imm4x4, $rn)
3123
3124 void
3125 sh2e_sem_movl5_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3126         sh2e::write_stacks &buf)
3127 {
3128 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
3129   sem_status status = SEM_STATUS_NORMAL;
3130   sh2e_scache* abuf = sem;
3131   unsigned long long written = 0;
3132   PCADDR pc = abuf->addr;
3133   PCADDR npc = pc + 2;
3134
3135   {
3136     SI opval = current_cpu->h_grc_get (FLD (f_rm));
3137     if (UNLIKELY(current_cpu->trace_result_p))
3138       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 << "  ";
3139     current_cpu->SETMEMSI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rn)), FLD (f_imm4x4)), opval);
3140   }
3141
3142   current_cpu->done_insn (npc, status);
3143 #undef FLD
3144 }
3145
3146 // ********** movl6-compact: mov.l @$rm, $rn
3147
3148 void
3149 sh2e_sem_movl6_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3150         sh2e::write_stacks &buf)
3151 {
3152 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
3153   sem_status status = SEM_STATUS_NORMAL;
3154   sh2e_scache* abuf = sem;
3155   unsigned long long written = 0;
3156   PCADDR pc = abuf->addr;
3157   PCADDR npc = pc + 2;
3158
3159   {
3160     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rm)));
3161     if (UNLIKELY(current_cpu->trace_result_p))
3162       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3163     current_cpu->h_grc_set (FLD (f_rn), opval);
3164   }
3165
3166   current_cpu->done_insn (npc, status);
3167 #undef FLD
3168 }
3169
3170 // ********** movl7-compact: mov.l @${rm}+, $rn
3171
3172 void
3173 sh2e_sem_movl7_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3174         sh2e::write_stacks &buf)
3175 {
3176 #define FLD(f) abuf->fields.sfmt_macl_compact.f
3177   sem_status status = SEM_STATUS_NORMAL;
3178   sh2e_scache* abuf = sem;
3179   unsigned long long written = 0;
3180   PCADDR pc = abuf->addr;
3181   PCADDR npc = pc + 2;
3182
3183 {
3184   {
3185     SI opval = current_cpu->GETMEMSI (pc, current_cpu->h_grc_get (FLD (f_rm)));
3186     if (UNLIKELY(current_cpu->trace_result_p))
3187       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3188     current_cpu->h_grc_set (FLD (f_rn), opval);
3189   }
3190 if (EQSI (FLD (f_rm), FLD (f_rn))) {
3191   {
3192     SI opval = current_cpu->h_grc_get (FLD (f_rn));
3193     written |= (1ULL << 5);
3194     if (UNLIKELY(current_cpu->trace_result_p))
3195       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
3196     current_cpu->h_grc_set (FLD (f_rm), opval);
3197   }
3198 } else {
3199   {
3200     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 4);
3201     written |= (1ULL << 5);
3202     if (UNLIKELY(current_cpu->trace_result_p))
3203       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
3204     current_cpu->h_grc_set (FLD (f_rm), opval);
3205   }
3206 }
3207 }
3208
3209   abuf->written = written;
3210   current_cpu->done_insn (npc, status);
3211 #undef FLD
3212 }
3213
3214 // ********** movl8-compact: mov.l @(r0, $rm), $rn
3215
3216 void
3217 sh2e_sem_movl8_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3218         sh2e::write_stacks &buf)
3219 {
3220 #define FLD(f) abuf->fields.sfmt_movb8_compact.f
3221   sem_status status = SEM_STATUS_NORMAL;
3222   sh2e_scache* abuf = sem;
3223   unsigned long long written = 0;
3224   PCADDR pc = abuf->addr;
3225   PCADDR npc = pc + 2;
3226
3227   {
3228     SI opval = current_cpu->GETMEMSI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rm))));
3229     if (UNLIKELY(current_cpu->trace_result_p))
3230       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3231     current_cpu->h_grc_set (FLD (f_rn), opval);
3232   }
3233
3234   current_cpu->done_insn (npc, status);
3235 #undef FLD
3236 }
3237
3238 // ********** movl9-compact: mov.l @($imm8x4, gbr), r0
3239
3240 void
3241 sh2e_sem_movl9_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3242         sh2e::write_stacks &buf)
3243 {
3244 #define FLD(f) abuf->fields.sfmt_movl9_compact.f
3245   sem_status status = SEM_STATUS_NORMAL;
3246   sh2e_scache* abuf = sem;
3247   unsigned long long written = 0;
3248   PCADDR pc = abuf->addr;
3249   PCADDR npc = pc + 2;
3250
3251   {
3252     SI opval = current_cpu->GETMEMSI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x4)));
3253     if (UNLIKELY(current_cpu->trace_result_p))
3254       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
3255     current_cpu->h_grc_set (((UINT) 0), opval);
3256   }
3257
3258   current_cpu->done_insn (npc, status);
3259 #undef FLD
3260 }
3261
3262 // ********** movl10-compact: mov.l @($imm8x4, pc), $rn
3263
3264 void
3265 sh2e_sem_movl10_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3266         sh2e::write_stacks &buf)
3267 {
3268 #define FLD(f) abuf->fields.sfmt_movl10_compact.f
3269   sem_status status = SEM_STATUS_NORMAL;
3270   sh2e_scache* abuf = sem;
3271   unsigned long long written = 0;
3272   PCADDR pc = abuf->addr;
3273   PCADDR npc = pc + 2;
3274
3275   {
3276     SI opval = current_cpu->GETMEMSI (pc, ADDSI (FLD (f_imm8x4), ANDDI (ADDDI (pc, 4), INVSI (3))));
3277     if (UNLIKELY(current_cpu->trace_result_p))
3278       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3279     current_cpu->h_grc_set (FLD (f_rn), opval);
3280   }
3281
3282   current_cpu->done_insn (npc, status);
3283 #undef FLD
3284 }
3285
3286 // ********** movl11-compact: mov.l @($imm4x4, $rm), $rn
3287
3288 void
3289 sh2e_sem_movl11_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3290         sh2e::write_stacks &buf)
3291 {
3292 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
3293   sem_status status = SEM_STATUS_NORMAL;
3294   sh2e_scache* abuf = sem;
3295   unsigned long long written = 0;
3296   PCADDR pc = abuf->addr;
3297   PCADDR npc = pc + 2;
3298
3299   {
3300     SI opval = current_cpu->GETMEMSI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4x4)));
3301     if (UNLIKELY(current_cpu->trace_result_p))
3302       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3303     current_cpu->h_grc_set (FLD (f_rn), opval);
3304   }
3305
3306   current_cpu->done_insn (npc, status);
3307 #undef FLD
3308 }
3309
3310 // ********** movw1-compact: mov.w $rm, @$rn
3311
3312 void
3313 sh2e_sem_movw1_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3314         sh2e::write_stacks &buf)
3315 {
3316 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
3317   sem_status status = SEM_STATUS_NORMAL;
3318   sh2e_scache* abuf = sem;
3319   unsigned long long written = 0;
3320   PCADDR pc = abuf->addr;
3321   PCADDR npc = pc + 2;
3322
3323   {
3324     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1);
3325     if (UNLIKELY(current_cpu->trace_result_p))
3326       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3327     current_cpu->SETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
3328   }
3329
3330   current_cpu->done_insn (npc, status);
3331 #undef FLD
3332 }
3333
3334 // ********** movw2-compact: mov.w $rm, @-$rn
3335
3336 void
3337 sh2e_sem_movw2_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3338         sh2e::write_stacks &buf)
3339 {
3340 #define FLD(f) abuf->fields.sfmt_macl_compact.f
3341   sem_status status = SEM_STATUS_NORMAL;
3342   sh2e_scache* abuf = sem;
3343   unsigned long long written = 0;
3344   PCADDR pc = abuf->addr;
3345   PCADDR npc = pc + 2;
3346
3347 {
3348   DI tmp_addr;
3349   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
3350   {
3351     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1);
3352     if (UNLIKELY(current_cpu->trace_result_p))
3353       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3354     current_cpu->SETMEMHI (pc, tmp_addr, opval);
3355   }
3356   {
3357     SI opval = tmp_addr;
3358     if (UNLIKELY(current_cpu->trace_result_p))
3359       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3360     current_cpu->h_grc_set (FLD (f_rn), opval);
3361   }
3362 }
3363
3364   current_cpu->done_insn (npc, status);
3365 #undef FLD
3366 }
3367
3368 // ********** movw3-compact: mov.w $rm, @(r0, $rn)
3369
3370 void
3371 sh2e_sem_movw3_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3372         sh2e::write_stacks &buf)
3373 {
3374 #define FLD(f) abuf->fields.sfmt_movb3_compact.f
3375   sem_status status = SEM_STATUS_NORMAL;
3376   sh2e_scache* abuf = sem;
3377   unsigned long long written = 0;
3378   PCADDR pc = abuf->addr;
3379   PCADDR npc = pc + 2;
3380
3381   {
3382     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 1);
3383     if (UNLIKELY(current_cpu->trace_result_p))
3384       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 << "  ";
3385     current_cpu->SETMEMHI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rn))), opval);
3386   }
3387
3388   current_cpu->done_insn (npc, status);
3389 #undef FLD
3390 }
3391
3392 // ********** movw4-compact: mov.w r0, @($imm8x2, gbr)
3393
3394 void
3395 sh2e_sem_movw4_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3396         sh2e::write_stacks &buf)
3397 {
3398 #define FLD(f) abuf->fields.sfmt_movw4_compact.f
3399   sem_status status = SEM_STATUS_NORMAL;
3400   sh2e_scache* abuf = sem;
3401   unsigned long long written = 0;
3402   PCADDR pc = abuf->addr;
3403   PCADDR npc = pc + 2;
3404
3405   {
3406     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (((UINT) 0)), 1);
3407     if (UNLIKELY(current_cpu->trace_result_p))
3408       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x2)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
3409     current_cpu->SETMEMHI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x2)), opval);
3410   }
3411
3412   current_cpu->done_insn (npc, status);
3413 #undef FLD
3414 }
3415
3416 // ********** movw5-compact: mov.w r0, @($imm4x2, $rm)
3417
3418 void
3419 sh2e_sem_movw5_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3420         sh2e::write_stacks &buf)
3421 {
3422 #define FLD(f) abuf->fields.sfmt_movw5_compact.f
3423   sem_status status = SEM_STATUS_NORMAL;
3424   sh2e_scache* abuf = sem;
3425   unsigned long long written = 0;
3426   PCADDR pc = abuf->addr;
3427   PCADDR npc = pc + 2;
3428
3429   {
3430     HI opval = SUBWORDSIHI (current_cpu->h_grc_get (((UINT) 0)), 1);
3431     if (UNLIKELY(current_cpu->trace_result_p))
3432       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 << "  ";
3433     current_cpu->SETMEMHI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4x2)), opval);
3434   }
3435
3436   current_cpu->done_insn (npc, status);
3437 #undef FLD
3438 }
3439
3440 // ********** movw6-compact: mov.w @$rm, $rn
3441
3442 void
3443 sh2e_sem_movw6_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3444         sh2e::write_stacks &buf)
3445 {
3446 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
3447   sem_status status = SEM_STATUS_NORMAL;
3448   sh2e_scache* abuf = sem;
3449   unsigned long long written = 0;
3450   PCADDR pc = abuf->addr;
3451   PCADDR npc = pc + 2;
3452
3453   {
3454     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rm))));
3455     if (UNLIKELY(current_cpu->trace_result_p))
3456       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3457     current_cpu->h_grc_set (FLD (f_rn), opval);
3458   }
3459
3460   current_cpu->done_insn (npc, status);
3461 #undef FLD
3462 }
3463
3464 // ********** movw7-compact: mov.w @${rm}+, $rn
3465
3466 void
3467 sh2e_sem_movw7_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3468         sh2e::write_stacks &buf)
3469 {
3470 #define FLD(f) abuf->fields.sfmt_macl_compact.f
3471   sem_status status = SEM_STATUS_NORMAL;
3472   sh2e_scache* abuf = sem;
3473   unsigned long long written = 0;
3474   PCADDR pc = abuf->addr;
3475   PCADDR npc = pc + 2;
3476
3477 {
3478   HI tmp_data;
3479   tmp_data = current_cpu->GETMEMHI (pc, current_cpu->h_grc_get (FLD (f_rm)));
3480 if (EQSI (FLD (f_rm), FLD (f_rn))) {
3481   {
3482     SI opval = EXTHISI (tmp_data);
3483     written |= (1ULL << 4);
3484     if (UNLIKELY(current_cpu->trace_result_p))
3485       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
3486     current_cpu->h_grc_set (FLD (f_rm), opval);
3487   }
3488 } else {
3489   {
3490     SI opval = ADDSI (current_cpu->h_grc_get (FLD (f_rm)), 2);
3491     written |= (1ULL << 4);
3492     if (UNLIKELY(current_cpu->trace_result_p))
3493       current_cpu->trace_stream << "grc" << '[' << FLD (f_rm) << ']' << ":=0x" << hex << opval << dec << "  ";
3494     current_cpu->h_grc_set (FLD (f_rm), opval);
3495   }
3496 }
3497   {
3498     SI opval = EXTHISI (tmp_data);
3499     if (UNLIKELY(current_cpu->trace_result_p))
3500       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3501     current_cpu->h_grc_set (FLD (f_rn), opval);
3502   }
3503 }
3504
3505   abuf->written = written;
3506   current_cpu->done_insn (npc, status);
3507 #undef FLD
3508 }
3509
3510 // ********** movw8-compact: mov.w @(r0, $rm), $rn
3511
3512 void
3513 sh2e_sem_movw8_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3514         sh2e::write_stacks &buf)
3515 {
3516 #define FLD(f) abuf->fields.sfmt_movb8_compact.f
3517   sem_status status = SEM_STATUS_NORMAL;
3518   sh2e_scache* abuf = sem;
3519   unsigned long long written = 0;
3520   PCADDR pc = abuf->addr;
3521   PCADDR npc = pc + 2;
3522
3523   {
3524     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_grc_get (FLD (f_rm)))));
3525     if (UNLIKELY(current_cpu->trace_result_p))
3526       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3527     current_cpu->h_grc_set (FLD (f_rn), opval);
3528   }
3529
3530   current_cpu->done_insn (npc, status);
3531 #undef FLD
3532 }
3533
3534 // ********** movw9-compact: mov.w @($imm8x2, gbr), r0
3535
3536 void
3537 sh2e_sem_movw9_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3538         sh2e::write_stacks &buf)
3539 {
3540 #define FLD(f) abuf->fields.sfmt_movw9_compact.f
3541   sem_status status = SEM_STATUS_NORMAL;
3542   sh2e_scache* abuf = sem;
3543   unsigned long long written = 0;
3544   PCADDR pc = abuf->addr;
3545   PCADDR npc = pc + 2;
3546
3547   {
3548     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, ADDSI (current_cpu->h_gbr_get (), FLD (f_imm8x2))));
3549     if (UNLIKELY(current_cpu->trace_result_p))
3550       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
3551     current_cpu->h_grc_set (((UINT) 0), opval);
3552   }
3553
3554   current_cpu->done_insn (npc, status);
3555 #undef FLD
3556 }
3557
3558 // ********** movw10-compact: mov.w @($imm8x2, pc), $rn
3559
3560 void
3561 sh2e_sem_movw10_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3562         sh2e::write_stacks &buf)
3563 {
3564 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
3565   sem_status status = SEM_STATUS_NORMAL;
3566   sh2e_scache* abuf = sem;
3567   unsigned long long written = 0;
3568   PCADDR pc = abuf->addr;
3569   PCADDR npc = pc + 2;
3570
3571   {
3572     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, ADDDI (ADDDI (pc, 4), FLD (f_imm8x2))));
3573     if (UNLIKELY(current_cpu->trace_result_p))
3574       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3575     current_cpu->h_grc_set (FLD (f_rn), opval);
3576   }
3577
3578   current_cpu->done_insn (npc, status);
3579 #undef FLD
3580 }
3581
3582 // ********** movw11-compact: mov.w @($imm4x2, $rm), r0
3583
3584 void
3585 sh2e_sem_movw11_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3586         sh2e::write_stacks &buf)
3587 {
3588 #define FLD(f) abuf->fields.sfmt_movw11_compact.f
3589   sem_status status = SEM_STATUS_NORMAL;
3590   sh2e_scache* abuf = sem;
3591   unsigned long long written = 0;
3592   PCADDR pc = abuf->addr;
3593   PCADDR npc = pc + 2;
3594
3595   {
3596     SI opval = EXTHISI (current_cpu->GETMEMHI (pc, ADDSI (current_cpu->h_grc_get (FLD (f_rm)), FLD (f_imm4x2))));
3597     if (UNLIKELY(current_cpu->trace_result_p))
3598       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
3599     current_cpu->h_grc_set (((UINT) 0), opval);
3600   }
3601
3602   current_cpu->done_insn (npc, status);
3603 #undef FLD
3604 }
3605
3606 // ********** mova-compact: mova @($imm8x4, pc), r0
3607
3608 void
3609 sh2e_sem_mova_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3610         sh2e::write_stacks &buf)
3611 {
3612 #define FLD(f) abuf->fields.sfmt_movl9_compact.f
3613   sem_status status = SEM_STATUS_NORMAL;
3614   sh2e_scache* abuf = sem;
3615   unsigned long long written = 0;
3616   PCADDR pc = abuf->addr;
3617   PCADDR npc = pc + 2;
3618
3619   {
3620     SI opval = ADDDI (ANDDI (ADDDI (pc, 4), INVSI (3)), FLD (f_imm8x4));
3621     if (UNLIKELY(current_cpu->trace_result_p))
3622       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
3623     current_cpu->h_grc_set (((UINT) 0), opval);
3624   }
3625
3626   current_cpu->done_insn (npc, status);
3627 #undef FLD
3628 }
3629
3630 // ********** movt-compact: movt $rn
3631
3632 void
3633 sh2e_sem_movt_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3634         sh2e::write_stacks &buf)
3635 {
3636 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
3637   sem_status status = SEM_STATUS_NORMAL;
3638   sh2e_scache* abuf = sem;
3639   unsigned long long written = 0;
3640   PCADDR pc = abuf->addr;
3641   PCADDR npc = pc + 2;
3642
3643   {
3644     SI opval = ZEXTBISI (current_cpu->h_tbit_get ());
3645     if (UNLIKELY(current_cpu->trace_result_p))
3646       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3647     current_cpu->h_grc_set (FLD (f_rn), opval);
3648   }
3649
3650   current_cpu->done_insn (npc, status);
3651 #undef FLD
3652 }
3653
3654 // ********** mull-compact: mul.l $rm, $rn
3655
3656 void
3657 sh2e_sem_mull_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3658         sh2e::write_stacks &buf)
3659 {
3660 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
3661   sem_status status = SEM_STATUS_NORMAL;
3662   sh2e_scache* abuf = sem;
3663   unsigned long long written = 0;
3664   PCADDR pc = abuf->addr;
3665   PCADDR npc = pc + 2;
3666
3667   {
3668     SI opval = MULSI (current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_grc_get (FLD (f_rn)));
3669     if (UNLIKELY(current_cpu->trace_result_p))
3670       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
3671     current_cpu->h_macl_set (opval);
3672   }
3673
3674   current_cpu->done_insn (npc, status);
3675 #undef FLD
3676 }
3677
3678 // ********** mulsw-compact: muls.w $rm, $rn
3679
3680 void
3681 sh2e_sem_mulsw_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3682         sh2e::write_stacks &buf)
3683 {
3684 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
3685   sem_status status = SEM_STATUS_NORMAL;
3686   sh2e_scache* abuf = sem;
3687   unsigned long long written = 0;
3688   PCADDR pc = abuf->addr;
3689   PCADDR npc = pc + 2;
3690
3691   {
3692     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)));
3693     if (UNLIKELY(current_cpu->trace_result_p))
3694       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
3695     current_cpu->h_macl_set (opval);
3696   }
3697
3698   current_cpu->done_insn (npc, status);
3699 #undef FLD
3700 }
3701
3702 // ********** muluw-compact: mulu.w $rm, $rn
3703
3704 void
3705 sh2e_sem_muluw_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3706         sh2e::write_stacks &buf)
3707 {
3708 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
3709   sem_status status = SEM_STATUS_NORMAL;
3710   sh2e_scache* abuf = sem;
3711   unsigned long long written = 0;
3712   PCADDR pc = abuf->addr;
3713   PCADDR npc = pc + 2;
3714
3715   {
3716     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)));
3717     if (UNLIKELY(current_cpu->trace_result_p))
3718       current_cpu->trace_stream << "macl" << ":=0x" << hex << opval << dec << "  ";
3719     current_cpu->h_macl_set (opval);
3720   }
3721
3722   current_cpu->done_insn (npc, status);
3723 #undef FLD
3724 }
3725
3726 // ********** neg-compact: neg $rm, $rn
3727
3728 void
3729 sh2e_sem_neg_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3730         sh2e::write_stacks &buf)
3731 {
3732 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
3733   sem_status status = SEM_STATUS_NORMAL;
3734   sh2e_scache* abuf = sem;
3735   unsigned long long written = 0;
3736   PCADDR pc = abuf->addr;
3737   PCADDR npc = pc + 2;
3738
3739   {
3740     SI opval = NEGSI (current_cpu->h_grc_get (FLD (f_rm)));
3741     if (UNLIKELY(current_cpu->trace_result_p))
3742       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3743     current_cpu->h_grc_set (FLD (f_rn), opval);
3744   }
3745
3746   current_cpu->done_insn (npc, status);
3747 #undef FLD
3748 }
3749
3750 // ********** negc-compact: negc $rm, $rn
3751
3752 void
3753 sh2e_sem_negc_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3754         sh2e::write_stacks &buf)
3755 {
3756 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
3757   sem_status status = SEM_STATUS_NORMAL;
3758   sh2e_scache* abuf = sem;
3759   unsigned long long written = 0;
3760   PCADDR pc = abuf->addr;
3761   PCADDR npc = pc + 2;
3762
3763 {
3764   BI tmp_flag;
3765   tmp_flag = SUBCFSI (0, current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
3766   {
3767     SI opval = SUBCSI (0, current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
3768     if (UNLIKELY(current_cpu->trace_result_p))
3769       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3770     current_cpu->h_grc_set (FLD (f_rn), opval);
3771   }
3772   {
3773     BI opval = tmp_flag;
3774     if (UNLIKELY(current_cpu->trace_result_p))
3775       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3776     current_cpu->h_tbit_set (opval);
3777   }
3778 }
3779
3780   current_cpu->done_insn (npc, status);
3781 #undef FLD
3782 }
3783
3784 // ********** nop-compact: nop
3785
3786 void
3787 sh2e_sem_nop_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3788         sh2e::write_stacks &buf)
3789 {
3790 #define FLD(f) abuf->fields.fmt_empty.f
3791   sem_status status = SEM_STATUS_NORMAL;
3792   sh2e_scache* abuf = sem;
3793   unsigned long long written = 0;
3794   PCADDR pc = abuf->addr;
3795   PCADDR npc = pc + 2;
3796
3797 ((void) 0); /*nop*/
3798
3799   current_cpu->done_insn (npc, status);
3800 #undef FLD
3801 }
3802
3803 // ********** not-compact: not $rm64, $rn64
3804
3805 void
3806 sh2e_sem_not_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3807         sh2e::write_stacks &buf)
3808 {
3809 #define FLD(f) abuf->fields.sfmt_and_compact.f
3810   sem_status status = SEM_STATUS_NORMAL;
3811   sh2e_scache* abuf = sem;
3812   unsigned long long written = 0;
3813   PCADDR pc = abuf->addr;
3814   PCADDR npc = pc + 2;
3815
3816   {
3817     DI opval = INVDI (current_cpu->h_gr_get (FLD (f_rm)));
3818     if (UNLIKELY(current_cpu->trace_result_p))
3819       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3820     current_cpu->h_gr_set (FLD (f_rn), opval);
3821   }
3822
3823   current_cpu->done_insn (npc, status);
3824 #undef FLD
3825 }
3826
3827 // ********** or-compact: or $rm64, $rn64
3828
3829 void
3830 sh2e_sem_or_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3831         sh2e::write_stacks &buf)
3832 {
3833 #define FLD(f) abuf->fields.sfmt_and_compact.f
3834   sem_status status = SEM_STATUS_NORMAL;
3835   sh2e_scache* abuf = sem;
3836   unsigned long long written = 0;
3837   PCADDR pc = abuf->addr;
3838   PCADDR npc = pc + 2;
3839
3840   {
3841     DI opval = ORDI (current_cpu->h_gr_get (FLD (f_rm)), current_cpu->h_gr_get (FLD (f_rn)));
3842     if (UNLIKELY(current_cpu->trace_result_p))
3843       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3844     current_cpu->h_gr_set (FLD (f_rn), opval);
3845   }
3846
3847   current_cpu->done_insn (npc, status);
3848 #undef FLD
3849 }
3850
3851 // ********** ori-compact: or #$uimm8, r0
3852
3853 void
3854 sh2e_sem_ori_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3855         sh2e::write_stacks &buf)
3856 {
3857 #define FLD(f) abuf->fields.sfmt_andi_compact.f
3858   sem_status status = SEM_STATUS_NORMAL;
3859   sh2e_scache* abuf = sem;
3860   unsigned long long written = 0;
3861   PCADDR pc = abuf->addr;
3862   PCADDR npc = pc + 2;
3863
3864   {
3865     SI opval = ORSI (current_cpu->h_grc_get (((UINT) 0)), ZEXTSIDI (FLD (f_imm8)));
3866     if (UNLIKELY(current_cpu->trace_result_p))
3867       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
3868     current_cpu->h_grc_set (((UINT) 0), opval);
3869   }
3870
3871   current_cpu->done_insn (npc, status);
3872 #undef FLD
3873 }
3874
3875 // ********** orb-compact: or.b #$imm8, @(r0, gbr)
3876
3877 void
3878 sh2e_sem_orb_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3879         sh2e::write_stacks &buf)
3880 {
3881 #define FLD(f) abuf->fields.sfmt_andi_compact.f
3882   sem_status status = SEM_STATUS_NORMAL;
3883   sh2e_scache* abuf = sem;
3884   unsigned long long written = 0;
3885   PCADDR pc = abuf->addr;
3886   PCADDR npc = pc + 2;
3887
3888 {
3889   DI tmp_addr;
3890   UQI tmp_data;
3891   tmp_addr = ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_gbr_get ());
3892   tmp_data = ORQI (current_cpu->GETMEMUQI (pc, tmp_addr), FLD (f_imm8));
3893   {
3894     UQI opval = tmp_data;
3895     if (UNLIKELY(current_cpu->trace_result_p))
3896       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
3897     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
3898   }
3899 }
3900
3901   current_cpu->done_insn (npc, status);
3902 #undef FLD
3903 }
3904
3905 // ********** rotcl-compact: rotcl $rn
3906
3907 void
3908 sh2e_sem_rotcl_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3909         sh2e::write_stacks &buf)
3910 {
3911 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
3912   sem_status status = SEM_STATUS_NORMAL;
3913   sh2e_scache* abuf = sem;
3914   unsigned long long written = 0;
3915   PCADDR pc = abuf->addr;
3916   PCADDR npc = pc + 2;
3917
3918 {
3919   BI tmp_temp;
3920   tmp_temp = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
3921   {
3922     SI opval = ORSI (SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), current_cpu->h_tbit_get ());
3923     if (UNLIKELY(current_cpu->trace_result_p))
3924       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3925     current_cpu->h_grc_set (FLD (f_rn), opval);
3926   }
3927   {
3928     BI opval = ((tmp_temp) ? (1) : (0));
3929     if (UNLIKELY(current_cpu->trace_result_p))
3930       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3931     current_cpu->h_tbit_set (opval);
3932   }
3933 }
3934
3935   current_cpu->done_insn (npc, status);
3936 #undef FLD
3937 }
3938
3939 // ********** rotcr-compact: rotcr $rn
3940
3941 void
3942 sh2e_sem_rotcr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3943         sh2e::write_stacks &buf)
3944 {
3945 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
3946   sem_status status = SEM_STATUS_NORMAL;
3947   sh2e_scache* abuf = sem;
3948   unsigned long long written = 0;
3949   PCADDR pc = abuf->addr;
3950   PCADDR npc = pc + 2;
3951
3952 {
3953   BI tmp_lsbit;
3954   SI tmp_temp;
3955   tmp_lsbit = ((EQSI (ANDSI (current_cpu->h_grc_get (FLD (f_rn)), 1), 0)) ? (0) : (1));
3956   tmp_temp = current_cpu->h_tbit_get ();
3957   {
3958     SI opval = ORSI (SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), SLLSI (tmp_temp, 31));
3959     if (UNLIKELY(current_cpu->trace_result_p))
3960       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3961     current_cpu->h_grc_set (FLD (f_rn), opval);
3962   }
3963   {
3964     BI opval = ((tmp_lsbit) ? (1) : (0));
3965     if (UNLIKELY(current_cpu->trace_result_p))
3966       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
3967     current_cpu->h_tbit_set (opval);
3968   }
3969 }
3970
3971   current_cpu->done_insn (npc, status);
3972 #undef FLD
3973 }
3974
3975 // ********** rotl-compact: rotl $rn
3976
3977 void
3978 sh2e_sem_rotl_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
3979         sh2e::write_stacks &buf)
3980 {
3981 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
3982   sem_status status = SEM_STATUS_NORMAL;
3983   sh2e_scache* abuf = sem;
3984   unsigned long long written = 0;
3985   PCADDR pc = abuf->addr;
3986   PCADDR npc = pc + 2;
3987
3988 {
3989   BI tmp_temp;
3990   tmp_temp = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
3991   {
3992     SI opval = ORSI (SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), tmp_temp);
3993     if (UNLIKELY(current_cpu->trace_result_p))
3994       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
3995     current_cpu->h_grc_set (FLD (f_rn), opval);
3996   }
3997   {
3998     BI opval = ((tmp_temp) ? (1) : (0));
3999     if (UNLIKELY(current_cpu->trace_result_p))
4000       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4001     current_cpu->h_tbit_set (opval);
4002   }
4003 }
4004
4005   current_cpu->done_insn (npc, status);
4006 #undef FLD
4007 }
4008
4009 // ********** rotr-compact: rotr $rn
4010
4011 void
4012 sh2e_sem_rotr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4013         sh2e::write_stacks &buf)
4014 {
4015 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4016   sem_status status = SEM_STATUS_NORMAL;
4017   sh2e_scache* abuf = sem;
4018   unsigned long long written = 0;
4019   PCADDR pc = abuf->addr;
4020   PCADDR npc = pc + 2;
4021
4022 {
4023   BI tmp_lsbit;
4024   SI tmp_temp;
4025   tmp_lsbit = ((EQSI (ANDSI (current_cpu->h_grc_get (FLD (f_rn)), 1), 0)) ? (0) : (1));
4026   tmp_temp = tmp_lsbit;
4027   {
4028     SI opval = ORSI (SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 1), SLLSI (tmp_temp, 31));
4029     if (UNLIKELY(current_cpu->trace_result_p))
4030       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4031     current_cpu->h_grc_set (FLD (f_rn), opval);
4032   }
4033   {
4034     BI opval = ((tmp_lsbit) ? (1) : (0));
4035     if (UNLIKELY(current_cpu->trace_result_p))
4036       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4037     current_cpu->h_tbit_set (opval);
4038   }
4039 }
4040
4041   current_cpu->done_insn (npc, status);
4042 #undef FLD
4043 }
4044
4045 // ********** rts-compact: rts
4046
4047 void
4048 sh2e_sem_rts_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4049         sh2e::write_stacks &buf)
4050 {
4051 #define FLD(f) abuf->fields.fmt_empty.f
4052   sem_status status = SEM_STATUS_NORMAL;
4053   sh2e_scache* abuf = sem;
4054   unsigned long long written = 0;
4055   PCADDR pc = abuf->addr;
4056   PCADDR npc = pc + 2;
4057
4058 {
4059   {
4060     UDI opval = ADDDI (pc, 2);
4061     if (UNLIKELY(current_cpu->trace_result_p))
4062       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
4063     current_cpu->branch (opval, npc, status);
4064   }
4065 current_cpu->save_delayed_pc (current_cpu->h_pr_get ());
4066   {
4067     UDI opval = current_cpu->h_pr_get ();
4068     buf.h_pc_writes [(tick + 1) % sh2e::pipe_sz].push (sh2e::write<UDI>(pc, opval));
4069     if (UNLIKELY(current_cpu->trace_result_p))
4070       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
4071   }
4072 current_cpu->notify_ret (current_cpu->h_pr_get ());
4073 }
4074
4075   current_cpu->done_cti_insn (npc, status);
4076 #undef FLD
4077 }
4078
4079 // ********** sett-compact: sett
4080
4081 void
4082 sh2e_sem_sett_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4083         sh2e::write_stacks &buf)
4084 {
4085 #define FLD(f) abuf->fields.fmt_empty.f
4086   sem_status status = SEM_STATUS_NORMAL;
4087   sh2e_scache* abuf = sem;
4088   unsigned long long written = 0;
4089   PCADDR pc = abuf->addr;
4090   PCADDR npc = pc + 2;
4091
4092   {
4093     BI opval = 1;
4094     if (UNLIKELY(current_cpu->trace_result_p))
4095       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4096     current_cpu->h_tbit_set (opval);
4097   }
4098
4099   current_cpu->done_insn (npc, status);
4100 #undef FLD
4101 }
4102
4103 // ********** shal-compact: shal $rn
4104
4105 void
4106 sh2e_sem_shal_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4107         sh2e::write_stacks &buf)
4108 {
4109 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4110   sem_status status = SEM_STATUS_NORMAL;
4111   sh2e_scache* abuf = sem;
4112   unsigned long long written = 0;
4113   PCADDR pc = abuf->addr;
4114   PCADDR npc = pc + 2;
4115
4116 {
4117   BI tmp_t;
4118   tmp_t = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
4119   {
4120     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
4121     if (UNLIKELY(current_cpu->trace_result_p))
4122       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4123     current_cpu->h_grc_set (FLD (f_rn), opval);
4124   }
4125   {
4126     BI opval = ((tmp_t) ? (1) : (0));
4127     if (UNLIKELY(current_cpu->trace_result_p))
4128       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4129     current_cpu->h_tbit_set (opval);
4130   }
4131 }
4132
4133   current_cpu->done_insn (npc, status);
4134 #undef FLD
4135 }
4136
4137 // ********** shar-compact: shar $rn
4138
4139 void
4140 sh2e_sem_shar_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4141         sh2e::write_stacks &buf)
4142 {
4143 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4144   sem_status status = SEM_STATUS_NORMAL;
4145   sh2e_scache* abuf = sem;
4146   unsigned long long written = 0;
4147   PCADDR pc = abuf->addr;
4148   PCADDR npc = pc + 2;
4149
4150 {
4151   BI tmp_t;
4152   tmp_t = ANDSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
4153   {
4154     SI opval = SRASI (current_cpu->h_grc_get (FLD (f_rn)), 1);
4155     if (UNLIKELY(current_cpu->trace_result_p))
4156       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4157     current_cpu->h_grc_set (FLD (f_rn), opval);
4158   }
4159   {
4160     BI opval = ((tmp_t) ? (1) : (0));
4161     if (UNLIKELY(current_cpu->trace_result_p))
4162       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4163     current_cpu->h_tbit_set (opval);
4164   }
4165 }
4166
4167   current_cpu->done_insn (npc, status);
4168 #undef FLD
4169 }
4170
4171 // ********** shll-compact: shll $rn
4172
4173 void
4174 sh2e_sem_shll_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4175         sh2e::write_stacks &buf)
4176 {
4177 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4178   sem_status status = SEM_STATUS_NORMAL;
4179   sh2e_scache* abuf = sem;
4180   unsigned long long written = 0;
4181   PCADDR pc = abuf->addr;
4182   PCADDR npc = pc + 2;
4183
4184 {
4185   BI tmp_t;
4186   tmp_t = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 31);
4187   {
4188     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
4189     if (UNLIKELY(current_cpu->trace_result_p))
4190       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4191     current_cpu->h_grc_set (FLD (f_rn), opval);
4192   }
4193   {
4194     BI opval = ((tmp_t) ? (1) : (0));
4195     if (UNLIKELY(current_cpu->trace_result_p))
4196       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4197     current_cpu->h_tbit_set (opval);
4198   }
4199 }
4200
4201   current_cpu->done_insn (npc, status);
4202 #undef FLD
4203 }
4204
4205 // ********** shll2-compact: shll2 $rn
4206
4207 void
4208 sh2e_sem_shll2_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4209         sh2e::write_stacks &buf)
4210 {
4211 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4212   sem_status status = SEM_STATUS_NORMAL;
4213   sh2e_scache* abuf = sem;
4214   unsigned long long written = 0;
4215   PCADDR pc = abuf->addr;
4216   PCADDR npc = pc + 2;
4217
4218   {
4219     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
4220     if (UNLIKELY(current_cpu->trace_result_p))
4221       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4222     current_cpu->h_grc_set (FLD (f_rn), opval);
4223   }
4224
4225   current_cpu->done_insn (npc, status);
4226 #undef FLD
4227 }
4228
4229 // ********** shll8-compact: shll8 $rn
4230
4231 void
4232 sh2e_sem_shll8_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4233         sh2e::write_stacks &buf)
4234 {
4235 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4236   sem_status status = SEM_STATUS_NORMAL;
4237   sh2e_scache* abuf = sem;
4238   unsigned long long written = 0;
4239   PCADDR pc = abuf->addr;
4240   PCADDR npc = pc + 2;
4241
4242   {
4243     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 8);
4244     if (UNLIKELY(current_cpu->trace_result_p))
4245       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4246     current_cpu->h_grc_set (FLD (f_rn), opval);
4247   }
4248
4249   current_cpu->done_insn (npc, status);
4250 #undef FLD
4251 }
4252
4253 // ********** shll16-compact: shll16 $rn
4254
4255 void
4256 sh2e_sem_shll16_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4257         sh2e::write_stacks &buf)
4258 {
4259 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4260   sem_status status = SEM_STATUS_NORMAL;
4261   sh2e_scache* abuf = sem;
4262   unsigned long long written = 0;
4263   PCADDR pc = abuf->addr;
4264   PCADDR npc = pc + 2;
4265
4266   {
4267     SI opval = SLLSI (current_cpu->h_grc_get (FLD (f_rn)), 16);
4268     if (UNLIKELY(current_cpu->trace_result_p))
4269       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4270     current_cpu->h_grc_set (FLD (f_rn), opval);
4271   }
4272
4273   current_cpu->done_insn (npc, status);
4274 #undef FLD
4275 }
4276
4277 // ********** shlr-compact: shlr $rn
4278
4279 void
4280 sh2e_sem_shlr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4281         sh2e::write_stacks &buf)
4282 {
4283 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4284   sem_status status = SEM_STATUS_NORMAL;
4285   sh2e_scache* abuf = sem;
4286   unsigned long long written = 0;
4287   PCADDR pc = abuf->addr;
4288   PCADDR npc = pc + 2;
4289
4290 {
4291   BI tmp_t;
4292   tmp_t = ANDSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
4293   {
4294     SI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 1);
4295     if (UNLIKELY(current_cpu->trace_result_p))
4296       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4297     current_cpu->h_grc_set (FLD (f_rn), opval);
4298   }
4299   {
4300     BI opval = ((tmp_t) ? (1) : (0));
4301     if (UNLIKELY(current_cpu->trace_result_p))
4302       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4303     current_cpu->h_tbit_set (opval);
4304   }
4305 }
4306
4307   current_cpu->done_insn (npc, status);
4308 #undef FLD
4309 }
4310
4311 // ********** shlr2-compact: shlr2 $rn
4312
4313 void
4314 sh2e_sem_shlr2_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4315         sh2e::write_stacks &buf)
4316 {
4317 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4318   sem_status status = SEM_STATUS_NORMAL;
4319   sh2e_scache* abuf = sem;
4320   unsigned long long written = 0;
4321   PCADDR pc = abuf->addr;
4322   PCADDR npc = pc + 2;
4323
4324   {
4325     SI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 2);
4326     if (UNLIKELY(current_cpu->trace_result_p))
4327       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4328     current_cpu->h_grc_set (FLD (f_rn), opval);
4329   }
4330
4331   current_cpu->done_insn (npc, status);
4332 #undef FLD
4333 }
4334
4335 // ********** shlr8-compact: shlr8 $rn
4336
4337 void
4338 sh2e_sem_shlr8_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4339         sh2e::write_stacks &buf)
4340 {
4341 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4342   sem_status status = SEM_STATUS_NORMAL;
4343   sh2e_scache* abuf = sem;
4344   unsigned long long written = 0;
4345   PCADDR pc = abuf->addr;
4346   PCADDR npc = pc + 2;
4347
4348   {
4349     SI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 8);
4350     if (UNLIKELY(current_cpu->trace_result_p))
4351       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4352     current_cpu->h_grc_set (FLD (f_rn), opval);
4353   }
4354
4355   current_cpu->done_insn (npc, status);
4356 #undef FLD
4357 }
4358
4359 // ********** shlr16-compact: shlr16 $rn
4360
4361 void
4362 sh2e_sem_shlr16_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4363         sh2e::write_stacks &buf)
4364 {
4365 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4366   sem_status status = SEM_STATUS_NORMAL;
4367   sh2e_scache* abuf = sem;
4368   unsigned long long written = 0;
4369   PCADDR pc = abuf->addr;
4370   PCADDR npc = pc + 2;
4371
4372   {
4373     SI opval = SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 16);
4374     if (UNLIKELY(current_cpu->trace_result_p))
4375       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4376     current_cpu->h_grc_set (FLD (f_rn), opval);
4377   }
4378
4379   current_cpu->done_insn (npc, status);
4380 #undef FLD
4381 }
4382
4383 // ********** stc-gbr-compact: stc gbr, $rn
4384
4385 void
4386 sh2e_sem_stc_gbr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4387         sh2e::write_stacks &buf)
4388 {
4389 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
4390   sem_status status = SEM_STATUS_NORMAL;
4391   sh2e_scache* abuf = sem;
4392   unsigned long long written = 0;
4393   PCADDR pc = abuf->addr;
4394   PCADDR npc = pc + 2;
4395
4396   {
4397     SI opval = current_cpu->h_gbr_get ();
4398     if (UNLIKELY(current_cpu->trace_result_p))
4399       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4400     current_cpu->h_grc_set (FLD (f_rn), opval);
4401   }
4402
4403   current_cpu->done_insn (npc, status);
4404 #undef FLD
4405 }
4406
4407 // ********** stc-vbr-compact: stc vbr, $rn
4408
4409 void
4410 sh2e_sem_stc_vbr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4411         sh2e::write_stacks &buf)
4412 {
4413 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
4414   sem_status status = SEM_STATUS_NORMAL;
4415   sh2e_scache* abuf = sem;
4416   unsigned long long written = 0;
4417   PCADDR pc = abuf->addr;
4418   PCADDR npc = pc + 2;
4419
4420   {
4421     SI opval = current_cpu->h_vbr_get ();
4422     if (UNLIKELY(current_cpu->trace_result_p))
4423       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4424     current_cpu->h_grc_set (FLD (f_rn), opval);
4425   }
4426
4427   current_cpu->done_insn (npc, status);
4428 #undef FLD
4429 }
4430
4431 // ********** stcl-gbr-compact: stc.l gbr, @-$rn
4432
4433 void
4434 sh2e_sem_stcl_gbr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4435         sh2e::write_stacks &buf)
4436 {
4437 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4438   sem_status status = SEM_STATUS_NORMAL;
4439   sh2e_scache* abuf = sem;
4440   unsigned long long written = 0;
4441   PCADDR pc = abuf->addr;
4442   PCADDR npc = pc + 2;
4443
4444 {
4445   DI tmp_addr;
4446   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
4447   {
4448     SI opval = current_cpu->h_gbr_get ();
4449     if (UNLIKELY(current_cpu->trace_result_p))
4450       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
4451     current_cpu->SETMEMSI (pc, tmp_addr, opval);
4452   }
4453   {
4454     SI opval = tmp_addr;
4455     if (UNLIKELY(current_cpu->trace_result_p))
4456       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4457     current_cpu->h_grc_set (FLD (f_rn), opval);
4458   }
4459 }
4460
4461   current_cpu->done_insn (npc, status);
4462 #undef FLD
4463 }
4464
4465 // ********** stcl-vbr-compact: stc.l vbr, @-$rn
4466
4467 void
4468 sh2e_sem_stcl_vbr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4469         sh2e::write_stacks &buf)
4470 {
4471 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4472   sem_status status = SEM_STATUS_NORMAL;
4473   sh2e_scache* abuf = sem;
4474   unsigned long long written = 0;
4475   PCADDR pc = abuf->addr;
4476   PCADDR npc = pc + 2;
4477
4478 {
4479   DI tmp_addr;
4480   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
4481   {
4482     SI opval = current_cpu->h_vbr_get ();
4483     if (UNLIKELY(current_cpu->trace_result_p))
4484       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
4485     current_cpu->SETMEMSI (pc, tmp_addr, opval);
4486   }
4487   {
4488     SI opval = tmp_addr;
4489     if (UNLIKELY(current_cpu->trace_result_p))
4490       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4491     current_cpu->h_grc_set (FLD (f_rn), opval);
4492   }
4493 }
4494
4495   current_cpu->done_insn (npc, status);
4496 #undef FLD
4497 }
4498
4499 // ********** sts-fpscr-compact: sts fpscr, $rn
4500
4501 void
4502 sh2e_sem_sts_fpscr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4503         sh2e::write_stacks &buf)
4504 {
4505 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
4506   sem_status status = SEM_STATUS_NORMAL;
4507   sh2e_scache* abuf = sem;
4508   unsigned long long written = 0;
4509   PCADDR pc = abuf->addr;
4510   PCADDR npc = pc + 2;
4511
4512   {
4513     SI opval = current_cpu->hardware.h_fpscr;
4514     if (UNLIKELY(current_cpu->trace_result_p))
4515       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4516     current_cpu->h_grc_set (FLD (f_rn), opval);
4517   }
4518
4519   current_cpu->done_insn (npc, status);
4520 #undef FLD
4521 }
4522
4523 // ********** stsl-fpscr-compact: sts.l fpscr, @-$rn
4524
4525 void
4526 sh2e_sem_stsl_fpscr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4527         sh2e::write_stacks &buf)
4528 {
4529 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4530   sem_status status = SEM_STATUS_NORMAL;
4531   sh2e_scache* abuf = sem;
4532   unsigned long long written = 0;
4533   PCADDR pc = abuf->addr;
4534   PCADDR npc = pc + 2;
4535
4536 {
4537   DI tmp_addr;
4538   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
4539   {
4540     SI opval = current_cpu->hardware.h_fpscr;
4541     if (UNLIKELY(current_cpu->trace_result_p))
4542       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
4543     current_cpu->SETMEMSI (pc, tmp_addr, opval);
4544   }
4545   {
4546     SI opval = tmp_addr;
4547     if (UNLIKELY(current_cpu->trace_result_p))
4548       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4549     current_cpu->h_grc_set (FLD (f_rn), opval);
4550   }
4551 }
4552
4553   current_cpu->done_insn (npc, status);
4554 #undef FLD
4555 }
4556
4557 // ********** sts-fpul-compact: sts fpul, $rn
4558
4559 void
4560 sh2e_sem_sts_fpul_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4561         sh2e::write_stacks &buf)
4562 {
4563 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4564   sem_status status = SEM_STATUS_NORMAL;
4565   sh2e_scache* abuf = sem;
4566   unsigned long long written = 0;
4567   PCADDR pc = abuf->addr;
4568   PCADDR npc = pc + 2;
4569
4570   {
4571     SI opval = SUBWORDSFSI (current_cpu->hardware.h_fr[((UINT) 32)]);
4572     if (UNLIKELY(current_cpu->trace_result_p))
4573       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4574     current_cpu->h_grc_set (FLD (f_rn), opval);
4575   }
4576
4577   current_cpu->done_insn (npc, status);
4578 #undef FLD
4579 }
4580
4581 // ********** stsl-fpul-compact: sts.l fpul, @-$rn
4582
4583 void
4584 sh2e_sem_stsl_fpul_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4585         sh2e::write_stacks &buf)
4586 {
4587 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4588   sem_status status = SEM_STATUS_NORMAL;
4589   sh2e_scache* abuf = sem;
4590   unsigned long long written = 0;
4591   PCADDR pc = abuf->addr;
4592   PCADDR npc = pc + 2;
4593
4594 {
4595   DI tmp_addr;
4596   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
4597   {
4598     SF opval = current_cpu->hardware.h_fr[((UINT) 32)];
4599     if (UNLIKELY(current_cpu->trace_result_p))
4600       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
4601     current_cpu->SETMEMSF (pc, tmp_addr, opval);
4602   }
4603   {
4604     SI opval = tmp_addr;
4605     if (UNLIKELY(current_cpu->trace_result_p))
4606       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4607     current_cpu->h_grc_set (FLD (f_rn), opval);
4608   }
4609 }
4610
4611   current_cpu->done_insn (npc, status);
4612 #undef FLD
4613 }
4614
4615 // ********** sts-mach-compact: sts mach, $rn
4616
4617 void
4618 sh2e_sem_sts_mach_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4619         sh2e::write_stacks &buf)
4620 {
4621 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
4622   sem_status status = SEM_STATUS_NORMAL;
4623   sh2e_scache* abuf = sem;
4624   unsigned long long written = 0;
4625   PCADDR pc = abuf->addr;
4626   PCADDR npc = pc + 2;
4627
4628   {
4629     SI opval = current_cpu->h_mach_get ();
4630     if (UNLIKELY(current_cpu->trace_result_p))
4631       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4632     current_cpu->h_grc_set (FLD (f_rn), opval);
4633   }
4634
4635   current_cpu->done_insn (npc, status);
4636 #undef FLD
4637 }
4638
4639 // ********** stsl-mach-compact: sts.l mach, @-$rn
4640
4641 void
4642 sh2e_sem_stsl_mach_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4643         sh2e::write_stacks &buf)
4644 {
4645 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4646   sem_status status = SEM_STATUS_NORMAL;
4647   sh2e_scache* abuf = sem;
4648   unsigned long long written = 0;
4649   PCADDR pc = abuf->addr;
4650   PCADDR npc = pc + 2;
4651
4652 {
4653   DI tmp_addr;
4654   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
4655   {
4656     SI opval = current_cpu->h_mach_get ();
4657     if (UNLIKELY(current_cpu->trace_result_p))
4658       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
4659     current_cpu->SETMEMSI (pc, tmp_addr, opval);
4660   }
4661   {
4662     SI opval = tmp_addr;
4663     if (UNLIKELY(current_cpu->trace_result_p))
4664       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4665     current_cpu->h_grc_set (FLD (f_rn), opval);
4666   }
4667 }
4668
4669   current_cpu->done_insn (npc, status);
4670 #undef FLD
4671 }
4672
4673 // ********** sts-macl-compact: sts macl, $rn
4674
4675 void
4676 sh2e_sem_sts_macl_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4677         sh2e::write_stacks &buf)
4678 {
4679 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
4680   sem_status status = SEM_STATUS_NORMAL;
4681   sh2e_scache* abuf = sem;
4682   unsigned long long written = 0;
4683   PCADDR pc = abuf->addr;
4684   PCADDR npc = pc + 2;
4685
4686   {
4687     SI opval = current_cpu->h_macl_get ();
4688     if (UNLIKELY(current_cpu->trace_result_p))
4689       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4690     current_cpu->h_grc_set (FLD (f_rn), opval);
4691   }
4692
4693   current_cpu->done_insn (npc, status);
4694 #undef FLD
4695 }
4696
4697 // ********** stsl-macl-compact: sts.l macl, @-$rn
4698
4699 void
4700 sh2e_sem_stsl_macl_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4701         sh2e::write_stacks &buf)
4702 {
4703 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4704   sem_status status = SEM_STATUS_NORMAL;
4705   sh2e_scache* abuf = sem;
4706   unsigned long long written = 0;
4707   PCADDR pc = abuf->addr;
4708   PCADDR npc = pc + 2;
4709
4710 {
4711   DI tmp_addr;
4712   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
4713   {
4714     SI opval = current_cpu->h_macl_get ();
4715     if (UNLIKELY(current_cpu->trace_result_p))
4716       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
4717     current_cpu->SETMEMSI (pc, tmp_addr, opval);
4718   }
4719   {
4720     SI opval = tmp_addr;
4721     if (UNLIKELY(current_cpu->trace_result_p))
4722       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4723     current_cpu->h_grc_set (FLD (f_rn), opval);
4724   }
4725 }
4726
4727   current_cpu->done_insn (npc, status);
4728 #undef FLD
4729 }
4730
4731 // ********** sts-pr-compact: sts pr, $rn
4732
4733 void
4734 sh2e_sem_sts_pr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4735         sh2e::write_stacks &buf)
4736 {
4737 #define FLD(f) abuf->fields.sfmt_movw10_compact.f
4738   sem_status status = SEM_STATUS_NORMAL;
4739   sh2e_scache* abuf = sem;
4740   unsigned long long written = 0;
4741   PCADDR pc = abuf->addr;
4742   PCADDR npc = pc + 2;
4743
4744   {
4745     SI opval = current_cpu->h_pr_get ();
4746     if (UNLIKELY(current_cpu->trace_result_p))
4747       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4748     current_cpu->h_grc_set (FLD (f_rn), opval);
4749   }
4750
4751   current_cpu->done_insn (npc, status);
4752 #undef FLD
4753 }
4754
4755 // ********** stsl-pr-compact: sts.l pr, @-$rn
4756
4757 void
4758 sh2e_sem_stsl_pr_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4759         sh2e::write_stacks &buf)
4760 {
4761 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4762   sem_status status = SEM_STATUS_NORMAL;
4763   sh2e_scache* abuf = sem;
4764   unsigned long long written = 0;
4765   PCADDR pc = abuf->addr;
4766   PCADDR npc = pc + 2;
4767
4768 {
4769   DI tmp_addr;
4770   tmp_addr = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), 4);
4771   {
4772     SI opval = current_cpu->h_pr_get ();
4773     if (UNLIKELY(current_cpu->trace_result_p))
4774       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
4775     current_cpu->SETMEMSI (pc, tmp_addr, opval);
4776   }
4777   {
4778     SI opval = tmp_addr;
4779     if (UNLIKELY(current_cpu->trace_result_p))
4780       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4781     current_cpu->h_grc_set (FLD (f_rn), opval);
4782   }
4783 }
4784
4785   current_cpu->done_insn (npc, status);
4786 #undef FLD
4787 }
4788
4789 // ********** sub-compact: sub $rm, $rn
4790
4791 void
4792 sh2e_sem_sub_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4793         sh2e::write_stacks &buf)
4794 {
4795 #define FLD(f) abuf->fields.sfmt_macl_compact.f
4796   sem_status status = SEM_STATUS_NORMAL;
4797   sh2e_scache* abuf = sem;
4798   unsigned long long written = 0;
4799   PCADDR pc = abuf->addr;
4800   PCADDR npc = pc + 2;
4801
4802   {
4803     SI opval = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
4804     if (UNLIKELY(current_cpu->trace_result_p))
4805       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4806     current_cpu->h_grc_set (FLD (f_rn), opval);
4807   }
4808
4809   current_cpu->done_insn (npc, status);
4810 #undef FLD
4811 }
4812
4813 // ********** subc-compact: subc $rm, $rn
4814
4815 void
4816 sh2e_sem_subc_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4817         sh2e::write_stacks &buf)
4818 {
4819 #define FLD(f) abuf->fields.sfmt_macl_compact.f
4820   sem_status status = SEM_STATUS_NORMAL;
4821   sh2e_scache* abuf = sem;
4822   unsigned long long written = 0;
4823   PCADDR pc = abuf->addr;
4824   PCADDR npc = pc + 2;
4825
4826 {
4827   BI tmp_flag;
4828   tmp_flag = SUBCFSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
4829   {
4830     SI opval = SUBCSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_tbit_get ());
4831     if (UNLIKELY(current_cpu->trace_result_p))
4832       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4833     current_cpu->h_grc_set (FLD (f_rn), opval);
4834   }
4835   {
4836     BI opval = tmp_flag;
4837     if (UNLIKELY(current_cpu->trace_result_p))
4838       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4839     current_cpu->h_tbit_set (opval);
4840   }
4841 }
4842
4843   current_cpu->done_insn (npc, status);
4844 #undef FLD
4845 }
4846
4847 // ********** subv-compact: subv $rm, $rn
4848
4849 void
4850 sh2e_sem_subv_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4851         sh2e::write_stacks &buf)
4852 {
4853 #define FLD(f) abuf->fields.sfmt_macl_compact.f
4854   sem_status status = SEM_STATUS_NORMAL;
4855   sh2e_scache* abuf = sem;
4856   unsigned long long written = 0;
4857   PCADDR pc = abuf->addr;
4858   PCADDR npc = pc + 2;
4859
4860 {
4861   BI tmp_t;
4862   tmp_t = SUBOFSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)), 0);
4863   {
4864     SI opval = SUBSI (current_cpu->h_grc_get (FLD (f_rn)), current_cpu->h_grc_get (FLD (f_rm)));
4865     if (UNLIKELY(current_cpu->trace_result_p))
4866       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4867     current_cpu->h_grc_set (FLD (f_rn), opval);
4868   }
4869   {
4870     BI opval = ((tmp_t) ? (1) : (0));
4871     if (UNLIKELY(current_cpu->trace_result_p))
4872       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4873     current_cpu->h_tbit_set (opval);
4874   }
4875 }
4876
4877   current_cpu->done_insn (npc, status);
4878 #undef FLD
4879 }
4880
4881 // ********** swapb-compact: swap.b $rm, $rn
4882
4883 void
4884 sh2e_sem_swapb_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4885         sh2e::write_stacks &buf)
4886 {
4887 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
4888   sem_status status = SEM_STATUS_NORMAL;
4889   sh2e_scache* abuf = sem;
4890   unsigned long long written = 0;
4891   PCADDR pc = abuf->addr;
4892   PCADDR npc = pc + 2;
4893
4894 {
4895   UHI tmp_top_half;
4896   UQI tmp_byte1;
4897   UQI tmp_byte0;
4898   tmp_top_half = SUBWORDSIHI (current_cpu->h_grc_get (FLD (f_rm)), 0);
4899   tmp_byte1 = SUBWORDSIQI (current_cpu->h_grc_get (FLD (f_rm)), 2);
4900   tmp_byte0 = SUBWORDSIQI (current_cpu->h_grc_get (FLD (f_rm)), 3);
4901   {
4902     SI opval = ORSI (SLLSI (tmp_top_half, 16), ORSI (SLLSI (tmp_byte0, 8), tmp_byte1));
4903     if (UNLIKELY(current_cpu->trace_result_p))
4904       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4905     current_cpu->h_grc_set (FLD (f_rn), opval);
4906   }
4907 }
4908
4909   current_cpu->done_insn (npc, status);
4910 #undef FLD
4911 }
4912
4913 // ********** swapw-compact: swap.w $rm, $rn
4914
4915 void
4916 sh2e_sem_swapw_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4917         sh2e::write_stacks &buf)
4918 {
4919 #define FLD(f) abuf->fields.sfmt_movl11_compact.f
4920   sem_status status = SEM_STATUS_NORMAL;
4921   sh2e_scache* abuf = sem;
4922   unsigned long long written = 0;
4923   PCADDR pc = abuf->addr;
4924   PCADDR npc = pc + 2;
4925
4926   {
4927     SI opval = ORSI (SRLSI (current_cpu->h_grc_get (FLD (f_rm)), 16), SLLSI (current_cpu->h_grc_get (FLD (f_rm)), 16));
4928     if (UNLIKELY(current_cpu->trace_result_p))
4929       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
4930     current_cpu->h_grc_set (FLD (f_rn), opval);
4931   }
4932
4933   current_cpu->done_insn (npc, status);
4934 #undef FLD
4935 }
4936
4937 // ********** tasb-compact: tas.b @$rn
4938
4939 void
4940 sh2e_sem_tasb_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4941         sh2e::write_stacks &buf)
4942 {
4943 #define FLD(f) abuf->fields.sfmt_stsl_fpul_compact.f
4944   sem_status status = SEM_STATUS_NORMAL;
4945   sh2e_scache* abuf = sem;
4946   unsigned long long written = 0;
4947   PCADDR pc = abuf->addr;
4948   PCADDR npc = pc + 2;
4949
4950 {
4951   UQI tmp_byte;
4952   tmp_byte = current_cpu->GETMEMUQI (pc, current_cpu->h_grc_get (FLD (f_rn)));
4953   {
4954     BI opval = ((EQQI (tmp_byte, 0)) ? (1) : (0));
4955     if (UNLIKELY(current_cpu->trace_result_p))
4956       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
4957     current_cpu->h_tbit_set (opval);
4958   }
4959   tmp_byte = ORQI (tmp_byte, 128);
4960   {
4961     UQI opval = tmp_byte;
4962     if (UNLIKELY(current_cpu->trace_result_p))
4963       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_grc_get (FLD (f_rn)) << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
4964     current_cpu->SETMEMUQI (pc, current_cpu->h_grc_get (FLD (f_rn)), opval);
4965   }
4966 }
4967
4968   current_cpu->done_insn (npc, status);
4969 #undef FLD
4970 }
4971
4972 // ********** trapa-compact: trapa #$uimm8
4973
4974 void
4975 sh2e_sem_trapa_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4976         sh2e::write_stacks &buf)
4977 {
4978 #define FLD(f) abuf->fields.sfmt_andi_compact.f
4979   sem_status status = SEM_STATUS_NORMAL;
4980   sh2e_scache* abuf = sem;
4981   unsigned long long written = 0;
4982   PCADDR pc = abuf->addr;
4983   PCADDR npc = pc + 2;
4984
4985 current_cpu->sh64_compact_trapa (FLD (f_imm8), pc);
4986
4987   current_cpu->done_insn (npc, status);
4988 #undef FLD
4989 }
4990
4991 // ********** tst-compact: tst $rm, $rn
4992
4993 void
4994 sh2e_sem_tst_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
4995         sh2e::write_stacks &buf)
4996 {
4997 #define FLD(f) abuf->fields.sfmt_movl5_compact.f
4998   sem_status status = SEM_STATUS_NORMAL;
4999   sh2e_scache* abuf = sem;
5000   unsigned long long written = 0;
5001   PCADDR pc = abuf->addr;
5002   PCADDR npc = pc + 2;
5003
5004   {
5005     BI opval = ((EQSI (ANDSI (current_cpu->h_grc_get (FLD (f_rm)), current_cpu->h_grc_get (FLD (f_rn))), 0)) ? (1) : (0));
5006     if (UNLIKELY(current_cpu->trace_result_p))
5007       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
5008     current_cpu->h_tbit_set (opval);
5009   }
5010
5011   current_cpu->done_insn (npc, status);
5012 #undef FLD
5013 }
5014
5015 // ********** tsti-compact: tst #$uimm8, r0
5016
5017 void
5018 sh2e_sem_tsti_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
5019         sh2e::write_stacks &buf)
5020 {
5021 #define FLD(f) abuf->fields.sfmt_andi_compact.f
5022   sem_status status = SEM_STATUS_NORMAL;
5023   sh2e_scache* abuf = sem;
5024   unsigned long long written = 0;
5025   PCADDR pc = abuf->addr;
5026   PCADDR npc = pc + 2;
5027
5028   {
5029     BI opval = ((EQSI (ANDSI (current_cpu->h_grc_get (((UINT) 0)), ZEXTSISI (FLD (f_imm8))), 0)) ? (1) : (0));
5030     if (UNLIKELY(current_cpu->trace_result_p))
5031       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
5032     current_cpu->h_tbit_set (opval);
5033   }
5034
5035   current_cpu->done_insn (npc, status);
5036 #undef FLD
5037 }
5038
5039 // ********** tstb-compact: tst.b #$imm8, @(r0, gbr)
5040
5041 void
5042 sh2e_sem_tstb_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
5043         sh2e::write_stacks &buf)
5044 {
5045 #define FLD(f) abuf->fields.sfmt_andi_compact.f
5046   sem_status status = SEM_STATUS_NORMAL;
5047   sh2e_scache* abuf = sem;
5048   unsigned long long written = 0;
5049   PCADDR pc = abuf->addr;
5050   PCADDR npc = pc + 2;
5051
5052 {
5053   DI tmp_addr;
5054   tmp_addr = ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_gbr_get ());
5055   {
5056     BI opval = ((EQQI (ANDQI (current_cpu->GETMEMUQI (pc, tmp_addr), FLD (f_imm8)), 0)) ? (1) : (0));
5057     if (UNLIKELY(current_cpu->trace_result_p))
5058       current_cpu->trace_stream << "tbit" << ":=0x" << hex << opval << dec << "  ";
5059     current_cpu->h_tbit_set (opval);
5060   }
5061 }
5062
5063   current_cpu->done_insn (npc, status);
5064 #undef FLD
5065 }
5066
5067 // ********** xor-compact: xor $rm64, $rn64
5068
5069 void
5070 sh2e_sem_xor_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
5071         sh2e::write_stacks &buf)
5072 {
5073 #define FLD(f) abuf->fields.sfmt_and_compact.f
5074   sem_status status = SEM_STATUS_NORMAL;
5075   sh2e_scache* abuf = sem;
5076   unsigned long long written = 0;
5077   PCADDR pc = abuf->addr;
5078   PCADDR npc = pc + 2;
5079
5080   {
5081     DI opval = XORDI (current_cpu->h_gr_get (FLD (f_rn)), current_cpu->h_gr_get (FLD (f_rm)));
5082     if (UNLIKELY(current_cpu->trace_result_p))
5083       current_cpu->trace_stream << "gr" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
5084     current_cpu->h_gr_set (FLD (f_rn), opval);
5085   }
5086
5087   current_cpu->done_insn (npc, status);
5088 #undef FLD
5089 }
5090
5091 // ********** xori-compact: xor #$uimm8, r0
5092
5093 void
5094 sh2e_sem_xori_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
5095         sh2e::write_stacks &buf)
5096 {
5097 #define FLD(f) abuf->fields.sfmt_andi_compact.f
5098   sem_status status = SEM_STATUS_NORMAL;
5099   sh2e_scache* abuf = sem;
5100   unsigned long long written = 0;
5101   PCADDR pc = abuf->addr;
5102   PCADDR npc = pc + 2;
5103
5104   {
5105     SI opval = XORSI (current_cpu->h_grc_get (((UINT) 0)), ZEXTSIDI (FLD (f_imm8)));
5106     if (UNLIKELY(current_cpu->trace_result_p))
5107       current_cpu->trace_stream << "grc" << '[' << ((UINT) 0) << ']' << ":=0x" << hex << opval << dec << "  ";
5108     current_cpu->h_grc_set (((UINT) 0), opval);
5109   }
5110
5111   current_cpu->done_insn (npc, status);
5112 #undef FLD
5113 }
5114
5115 // ********** xorb-compact: xor.b #$imm8, @(r0, gbr)
5116
5117 void
5118 sh2e_sem_xorb_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
5119         sh2e::write_stacks &buf)
5120 {
5121 #define FLD(f) abuf->fields.sfmt_andi_compact.f
5122   sem_status status = SEM_STATUS_NORMAL;
5123   sh2e_scache* abuf = sem;
5124   unsigned long long written = 0;
5125   PCADDR pc = abuf->addr;
5126   PCADDR npc = pc + 2;
5127
5128 {
5129   DI tmp_addr;
5130   UQI tmp_data;
5131   tmp_addr = ADDSI (current_cpu->h_grc_get (((UINT) 0)), current_cpu->h_gbr_get ());
5132   tmp_data = XORQI (current_cpu->GETMEMUQI (pc, tmp_addr), FLD (f_imm8));
5133   {
5134     UQI opval = tmp_data;
5135     if (UNLIKELY(current_cpu->trace_result_p))
5136       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
5137     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
5138   }
5139 }
5140
5141   current_cpu->done_insn (npc, status);
5142 #undef FLD
5143 }
5144
5145 // ********** xtrct-compact: xtrct $rm, $rn
5146
5147 void
5148 sh2e_sem_xtrct_compact (sh2e_cpu* current_cpu, sh2e_scache* sem, const int tick, 
5149         sh2e::write_stacks &buf)
5150 {
5151 #define FLD(f) abuf->fields.sfmt_macl_compact.f
5152   sem_status status = SEM_STATUS_NORMAL;
5153   sh2e_scache* abuf = sem;
5154   unsigned long long written = 0;
5155   PCADDR pc = abuf->addr;
5156   PCADDR npc = pc + 2;
5157
5158   {
5159     SI opval = ORSI (SLLSI (current_cpu->h_grc_get (FLD (f_rm)), 16), SRLSI (current_cpu->h_grc_get (FLD (f_rn)), 16));
5160     if (UNLIKELY(current_cpu->trace_result_p))
5161       current_cpu->trace_stream << "grc" << '[' << FLD (f_rn) << ']' << ":=0x" << hex << opval << dec << "  ";
5162     current_cpu->h_grc_set (FLD (f_rn), opval);
5163   }
5164
5165   current_cpu->done_insn (npc, status);
5166 #undef FLD
5167 }
5168