OSDN Git Service

c5e8a9b2ef55e6717b2af0647141f3ab0a7a0c57
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / cgen-cpu / sh / sh5-media-sem.cxx
1 /* Simulator instruction semantics for sh5_media.
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 "sh5.h"
17
18 using namespace sh5; // FIXME: namespace organization still wip
19 using namespace sh5_media; // FIXME: namespace organization still wip
20 #define GET_ATTR(name) GET_ATTR_##name ()
21
22
23 // ********** x-invalid: --invalid--
24
25 void
26 sh5_media_sem_x_invalid (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
27         sh5_media::write_stacks &buf)
28 {
29 #define FLD(f) abuf->fields.fmt_empty.f
30   sem_status status = SEM_STATUS_NORMAL;
31   sh5_media_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: add $rm, $rn, $rd
47
48 void
49 sh5_media_sem_add (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
50         sh5_media::write_stacks &buf)
51 {
52 #define FLD(f) abuf->fields.sfmt_mcmv.f
53   sem_status status = SEM_STATUS_NORMAL;
54   sh5_media_scache* abuf = sem;
55   unsigned long long written = 0;
56   PCADDR pc = abuf->addr;
57   PCADDR npc = pc + 4;
58
59   {
60     DI opval = ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)));
61     if (UNLIKELY(current_cpu->trace_result_p))
62       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
63     current_cpu->h_gr_set (FLD (f_dest), opval);
64   }
65
66   current_cpu->done_insn (npc, status);
67 #undef FLD
68 }
69
70 // ********** addl: add.l $rm, $rn, $rd
71
72 void
73 sh5_media_sem_addl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
74         sh5_media::write_stacks &buf)
75 {
76 #define FLD(f) abuf->fields.sfmt_mcmv.f
77   sem_status status = SEM_STATUS_NORMAL;
78   sh5_media_scache* abuf = sem;
79   unsigned long long written = 0;
80   PCADDR pc = abuf->addr;
81   PCADDR npc = pc + 4;
82
83   {
84     DI opval = ADDSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1));
85     if (UNLIKELY(current_cpu->trace_result_p))
86       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
87     current_cpu->h_gr_set (FLD (f_dest), opval);
88   }
89
90   current_cpu->done_insn (npc, status);
91 #undef FLD
92 }
93
94 // ********** addi: addi $rm, $disp10, $rd
95
96 void
97 sh5_media_sem_addi (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
98         sh5_media::write_stacks &buf)
99 {
100 #define FLD(f) abuf->fields.sfmt_addi.f
101   sem_status status = SEM_STATUS_NORMAL;
102   sh5_media_scache* abuf = sem;
103   unsigned long long written = 0;
104   PCADDR pc = abuf->addr;
105   PCADDR npc = pc + 4;
106
107   {
108     DI opval = ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10)));
109     if (UNLIKELY(current_cpu->trace_result_p))
110       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
111     current_cpu->h_gr_set (FLD (f_dest), opval);
112   }
113
114   current_cpu->done_insn (npc, status);
115 #undef FLD
116 }
117
118 // ********** addil: addi.l $rm, $disp10, $rd
119
120 void
121 sh5_media_sem_addil (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
122         sh5_media::write_stacks &buf)
123 {
124 #define FLD(f) abuf->fields.sfmt_addi.f
125   sem_status status = SEM_STATUS_NORMAL;
126   sh5_media_scache* abuf = sem;
127   unsigned long long written = 0;
128   PCADDR pc = abuf->addr;
129   PCADDR npc = pc + 4;
130
131   {
132     DI opval = EXTSIDI (ADDSI (EXTSISI (FLD (f_disp10)), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1)));
133     if (UNLIKELY(current_cpu->trace_result_p))
134       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
135     current_cpu->h_gr_set (FLD (f_dest), opval);
136   }
137
138   current_cpu->done_insn (npc, status);
139 #undef FLD
140 }
141
142 // ********** addzl: addz.l $rm, $rn, $rd
143
144 void
145 sh5_media_sem_addzl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
146         sh5_media::write_stacks &buf)
147 {
148 #define FLD(f) abuf->fields.sfmt_mcmv.f
149   sem_status status = SEM_STATUS_NORMAL;
150   sh5_media_scache* abuf = sem;
151   unsigned long long written = 0;
152   PCADDR pc = abuf->addr;
153   PCADDR npc = pc + 4;
154
155   {
156     DI opval = ZEXTSIDI (ADDSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1)));
157     if (UNLIKELY(current_cpu->trace_result_p))
158       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
159     current_cpu->h_gr_set (FLD (f_dest), opval);
160   }
161
162   current_cpu->done_insn (npc, status);
163 #undef FLD
164 }
165
166 // ********** alloco: alloco $rm, $disp6x32
167
168 void
169 sh5_media_sem_alloco (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
170         sh5_media::write_stacks &buf)
171 {
172 #define FLD(f) abuf->fields.sfmt_alloco.f
173   sem_status status = SEM_STATUS_NORMAL;
174   sh5_media_scache* abuf = sem;
175   unsigned long long written = 0;
176   PCADDR pc = abuf->addr;
177   PCADDR npc = pc + 4;
178
179 {
180   {
181     DI opval = current_cpu->h_gr_get (FLD (f_left));
182     if (UNLIKELY(current_cpu->trace_result_p))
183       current_cpu->trace_stream << "gr" << '[' << FLD (f_left) << ']' << ":=0x" << hex << opval << dec << "  ";
184     current_cpu->h_gr_set (FLD (f_left), opval);
185   }
186 ((void) 0); /*nop*/
187 }
188
189   current_cpu->done_insn (npc, status);
190 #undef FLD
191 }
192
193 // ********** and: and $rm, $rn, $rd
194
195 void
196 sh5_media_sem_and (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
197         sh5_media::write_stacks &buf)
198 {
199 #define FLD(f) abuf->fields.sfmt_mcmv.f
200   sem_status status = SEM_STATUS_NORMAL;
201   sh5_media_scache* abuf = sem;
202   unsigned long long written = 0;
203   PCADDR pc = abuf->addr;
204   PCADDR npc = pc + 4;
205
206   {
207     DI opval = ANDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)));
208     if (UNLIKELY(current_cpu->trace_result_p))
209       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
210     current_cpu->h_gr_set (FLD (f_dest), opval);
211   }
212
213   current_cpu->done_insn (npc, status);
214 #undef FLD
215 }
216
217 // ********** andc: andc $rm, $rn, $rd
218
219 void
220 sh5_media_sem_andc (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
221         sh5_media::write_stacks &buf)
222 {
223 #define FLD(f) abuf->fields.sfmt_mcmv.f
224   sem_status status = SEM_STATUS_NORMAL;
225   sh5_media_scache* abuf = sem;
226   unsigned long long written = 0;
227   PCADDR pc = abuf->addr;
228   PCADDR npc = pc + 4;
229
230   {
231     DI opval = ANDDI (current_cpu->h_gr_get (FLD (f_left)), INVDI (current_cpu->h_gr_get (FLD (f_right))));
232     if (UNLIKELY(current_cpu->trace_result_p))
233       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
234     current_cpu->h_gr_set (FLD (f_dest), opval);
235   }
236
237   current_cpu->done_insn (npc, status);
238 #undef FLD
239 }
240
241 // ********** andi: andi $rm, $disp10, $rd
242
243 void
244 sh5_media_sem_andi (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
245         sh5_media::write_stacks &buf)
246 {
247 #define FLD(f) abuf->fields.sfmt_addi.f
248   sem_status status = SEM_STATUS_NORMAL;
249   sh5_media_scache* abuf = sem;
250   unsigned long long written = 0;
251   PCADDR pc = abuf->addr;
252   PCADDR npc = pc + 4;
253
254   {
255     DI opval = ANDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10)));
256     if (UNLIKELY(current_cpu->trace_result_p))
257       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
258     current_cpu->h_gr_set (FLD (f_dest), opval);
259   }
260
261   current_cpu->done_insn (npc, status);
262 #undef FLD
263 }
264
265 // ********** beq: beq$likely $rm, $rn, $tra
266
267 void
268 sh5_media_sem_beq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
269         sh5_media::write_stacks &buf)
270 {
271 #define FLD(f) abuf->fields.sfmt_beq.f
272   sem_status status = SEM_STATUS_NORMAL;
273   sh5_media_scache* abuf = sem;
274   unsigned long long written = 0;
275   PCADDR pc = abuf->addr;
276   PCADDR npc = pc + 4;
277
278 {
279 current_cpu->save_branch_optimization (FLD (f_likely));
280 if (EQDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))) {
281   {
282     UDI opval = current_cpu->hardware.h_tr[FLD (f_tra)];
283     written |= (1ULL << 4);
284     if (UNLIKELY(current_cpu->trace_result_p))
285       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
286     current_cpu->branch (opval, npc, status);
287   }
288 }
289 }
290
291   abuf->written = written;
292   current_cpu->done_cti_insn (npc, status);
293 #undef FLD
294 }
295
296 // ********** beqi: beqi$likely $rm, $imm6, $tra
297
298 void
299 sh5_media_sem_beqi (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
300         sh5_media::write_stacks &buf)
301 {
302 #define FLD(f) abuf->fields.sfmt_beqi.f
303   sem_status status = SEM_STATUS_NORMAL;
304   sh5_media_scache* abuf = sem;
305   unsigned long long written = 0;
306   PCADDR pc = abuf->addr;
307   PCADDR npc = pc + 4;
308
309 {
310 current_cpu->save_branch_optimization (FLD (f_likely));
311 if (EQDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_imm6)))) {
312   {
313     UDI opval = current_cpu->hardware.h_tr[FLD (f_tra)];
314     written |= (1ULL << 4);
315     if (UNLIKELY(current_cpu->trace_result_p))
316       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
317     current_cpu->branch (opval, npc, status);
318   }
319 }
320 }
321
322   abuf->written = written;
323   current_cpu->done_cti_insn (npc, status);
324 #undef FLD
325 }
326
327 // ********** bge: bge$likely $rm, $rn, $tra
328
329 void
330 sh5_media_sem_bge (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
331         sh5_media::write_stacks &buf)
332 {
333 #define FLD(f) abuf->fields.sfmt_beq.f
334   sem_status status = SEM_STATUS_NORMAL;
335   sh5_media_scache* abuf = sem;
336   unsigned long long written = 0;
337   PCADDR pc = abuf->addr;
338   PCADDR npc = pc + 4;
339
340 {
341 current_cpu->save_branch_optimization (FLD (f_likely));
342 if (GEDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))) {
343   {
344     UDI opval = current_cpu->hardware.h_tr[FLD (f_tra)];
345     written |= (1ULL << 4);
346     if (UNLIKELY(current_cpu->trace_result_p))
347       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
348     current_cpu->branch (opval, npc, status);
349   }
350 }
351 }
352
353   abuf->written = written;
354   current_cpu->done_cti_insn (npc, status);
355 #undef FLD
356 }
357
358 // ********** bgeu: bgeu$likely $rm, $rn, $tra
359
360 void
361 sh5_media_sem_bgeu (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
362         sh5_media::write_stacks &buf)
363 {
364 #define FLD(f) abuf->fields.sfmt_beq.f
365   sem_status status = SEM_STATUS_NORMAL;
366   sh5_media_scache* abuf = sem;
367   unsigned long long written = 0;
368   PCADDR pc = abuf->addr;
369   PCADDR npc = pc + 4;
370
371 {
372 current_cpu->save_branch_optimization (FLD (f_likely));
373 if (GEUDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))) {
374   {
375     UDI opval = current_cpu->hardware.h_tr[FLD (f_tra)];
376     written |= (1ULL << 4);
377     if (UNLIKELY(current_cpu->trace_result_p))
378       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
379     current_cpu->branch (opval, npc, status);
380   }
381 }
382 }
383
384   abuf->written = written;
385   current_cpu->done_cti_insn (npc, status);
386 #undef FLD
387 }
388
389 // ********** bgt: bgt$likely $rm, $rn, $tra
390
391 void
392 sh5_media_sem_bgt (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
393         sh5_media::write_stacks &buf)
394 {
395 #define FLD(f) abuf->fields.sfmt_beq.f
396   sem_status status = SEM_STATUS_NORMAL;
397   sh5_media_scache* abuf = sem;
398   unsigned long long written = 0;
399   PCADDR pc = abuf->addr;
400   PCADDR npc = pc + 4;
401
402 {
403 current_cpu->save_branch_optimization (FLD (f_likely));
404 if (GTDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))) {
405   {
406     UDI opval = current_cpu->hardware.h_tr[FLD (f_tra)];
407     written |= (1ULL << 4);
408     if (UNLIKELY(current_cpu->trace_result_p))
409       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
410     current_cpu->branch (opval, npc, status);
411   }
412 }
413 }
414
415   abuf->written = written;
416   current_cpu->done_cti_insn (npc, status);
417 #undef FLD
418 }
419
420 // ********** bgtu: bgtu$likely $rm, $rn, $tra
421
422 void
423 sh5_media_sem_bgtu (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
424         sh5_media::write_stacks &buf)
425 {
426 #define FLD(f) abuf->fields.sfmt_beq.f
427   sem_status status = SEM_STATUS_NORMAL;
428   sh5_media_scache* abuf = sem;
429   unsigned long long written = 0;
430   PCADDR pc = abuf->addr;
431   PCADDR npc = pc + 4;
432
433 {
434 current_cpu->save_branch_optimization (FLD (f_likely));
435 if (GTUDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))) {
436   {
437     UDI opval = current_cpu->hardware.h_tr[FLD (f_tra)];
438     written |= (1ULL << 4);
439     if (UNLIKELY(current_cpu->trace_result_p))
440       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
441     current_cpu->branch (opval, npc, status);
442   }
443 }
444 }
445
446   abuf->written = written;
447   current_cpu->done_cti_insn (npc, status);
448 #undef FLD
449 }
450
451 // ********** blink: blink $trb, $rd
452
453 void
454 sh5_media_sem_blink (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
455         sh5_media::write_stacks &buf)
456 {
457 #define FLD(f) abuf->fields.sfmt_blink.f
458   sem_status status = SEM_STATUS_NORMAL;
459   sh5_media_scache* abuf = sem;
460   unsigned long long written = 0;
461   PCADDR pc = abuf->addr;
462   PCADDR npc = pc + 4;
463
464 {
465   {
466     DI opval = ORDI (ADDDI (pc, 4), 1);
467     if (UNLIKELY(current_cpu->trace_result_p))
468       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
469     current_cpu->h_gr_set (FLD (f_dest), opval);
470   }
471   {
472     UDI opval = current_cpu->hardware.h_tr[FLD (f_trb)];
473     if (UNLIKELY(current_cpu->trace_result_p))
474       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
475     current_cpu->branch (opval, npc, status);
476   }
477 if (EQSI (FLD (f_dest), 63)) {
478 current_cpu->cg_profile_jump (pc, current_cpu->hardware.h_tr[FLD (f_trb)]);
479 } else {
480 current_cpu->cg_profile (pc, current_cpu->hardware.h_tr[FLD (f_trb)]);
481 }
482 }
483
484   current_cpu->done_cti_insn (npc, status);
485 #undef FLD
486 }
487
488 // ********** bne: bne$likely $rm, $rn, $tra
489
490 void
491 sh5_media_sem_bne (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
492         sh5_media::write_stacks &buf)
493 {
494 #define FLD(f) abuf->fields.sfmt_beq.f
495   sem_status status = SEM_STATUS_NORMAL;
496   sh5_media_scache* abuf = sem;
497   unsigned long long written = 0;
498   PCADDR pc = abuf->addr;
499   PCADDR npc = pc + 4;
500
501 {
502 current_cpu->save_branch_optimization (FLD (f_likely));
503 if (NEDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))) {
504   {
505     UDI opval = current_cpu->hardware.h_tr[FLD (f_tra)];
506     written |= (1ULL << 4);
507     if (UNLIKELY(current_cpu->trace_result_p))
508       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
509     current_cpu->branch (opval, npc, status);
510   }
511 }
512 }
513
514   abuf->written = written;
515   current_cpu->done_cti_insn (npc, status);
516 #undef FLD
517 }
518
519 // ********** bnei: bnei$likely $rm, $imm6, $tra
520
521 void
522 sh5_media_sem_bnei (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
523         sh5_media::write_stacks &buf)
524 {
525 #define FLD(f) abuf->fields.sfmt_beqi.f
526   sem_status status = SEM_STATUS_NORMAL;
527   sh5_media_scache* abuf = sem;
528   unsigned long long written = 0;
529   PCADDR pc = abuf->addr;
530   PCADDR npc = pc + 4;
531
532 {
533 current_cpu->save_branch_optimization (FLD (f_likely));
534 if (NEDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_imm6)))) {
535   {
536     UDI opval = current_cpu->hardware.h_tr[FLD (f_tra)];
537     written |= (1ULL << 4);
538     if (UNLIKELY(current_cpu->trace_result_p))
539       current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
540     current_cpu->branch (opval, npc, status);
541   }
542 }
543 }
544
545   abuf->written = written;
546   current_cpu->done_cti_insn (npc, status);
547 #undef FLD
548 }
549
550 // ********** brk: brk
551
552 void
553 sh5_media_sem_brk (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
554         sh5_media::write_stacks &buf)
555 {
556 #define FLD(f) abuf->fields.fmt_empty.f
557   sem_status status = SEM_STATUS_NORMAL;
558   sh5_media_scache* abuf = sem;
559   unsigned long long written = 0;
560   PCADDR pc = abuf->addr;
561   PCADDR npc = pc + 4;
562
563 current_cpu->sh64_break (pc);
564
565   current_cpu->done_insn (npc, status);
566 #undef FLD
567 }
568
569 // ********** byterev: byterev $rm, $rd
570
571 void
572 sh5_media_sem_byterev (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
573         sh5_media::write_stacks &buf)
574 {
575 #define FLD(f) abuf->fields.sfmt_xori.f
576   sem_status status = SEM_STATUS_NORMAL;
577   sh5_media_scache* abuf = sem;
578   unsigned long long written = 0;
579   PCADDR pc = abuf->addr;
580   PCADDR npc = pc + 4;
581
582 {
583   DI tmp_source;
584   DI tmp_result;
585   tmp_source = current_cpu->h_gr_get (FLD (f_left));
586   tmp_result = 0;
587 {
588   tmp_result = ORDI (SLLDI (tmp_result, 8), ANDDI (tmp_source, 255));
589   tmp_source = SRLDI (tmp_source, 8);
590 }
591 {
592   tmp_result = ORDI (SLLDI (tmp_result, 8), ANDDI (tmp_source, 255));
593   tmp_source = SRLDI (tmp_source, 8);
594 }
595 {
596   tmp_result = ORDI (SLLDI (tmp_result, 8), ANDDI (tmp_source, 255));
597   tmp_source = SRLDI (tmp_source, 8);
598 }
599 {
600   tmp_result = ORDI (SLLDI (tmp_result, 8), ANDDI (tmp_source, 255));
601   tmp_source = SRLDI (tmp_source, 8);
602 }
603 {
604   tmp_result = ORDI (SLLDI (tmp_result, 8), ANDDI (tmp_source, 255));
605   tmp_source = SRLDI (tmp_source, 8);
606 }
607 {
608   tmp_result = ORDI (SLLDI (tmp_result, 8), ANDDI (tmp_source, 255));
609   tmp_source = SRLDI (tmp_source, 8);
610 }
611 {
612   tmp_result = ORDI (SLLDI (tmp_result, 8), ANDDI (tmp_source, 255));
613   tmp_source = SRLDI (tmp_source, 8);
614 }
615 {
616   tmp_result = ORDI (SLLDI (tmp_result, 8), ANDDI (tmp_source, 255));
617   tmp_source = SRLDI (tmp_source, 8);
618 }
619   {
620     DI opval = tmp_result;
621     if (UNLIKELY(current_cpu->trace_result_p))
622       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
623     current_cpu->h_gr_set (FLD (f_dest), opval);
624   }
625 }
626
627   current_cpu->done_insn (npc, status);
628 #undef FLD
629 }
630
631 // ********** cmpeq: cmpeq $rm, $rn, $rd
632
633 void
634 sh5_media_sem_cmpeq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
635         sh5_media::write_stacks &buf)
636 {
637 #define FLD(f) abuf->fields.sfmt_mcmv.f
638   sem_status status = SEM_STATUS_NORMAL;
639   sh5_media_scache* abuf = sem;
640   unsigned long long written = 0;
641   PCADDR pc = abuf->addr;
642   PCADDR npc = pc + 4;
643
644   {
645     DI opval = ((EQDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))) ? (1) : (0));
646     if (UNLIKELY(current_cpu->trace_result_p))
647       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
648     current_cpu->h_gr_set (FLD (f_dest), opval);
649   }
650
651   current_cpu->done_insn (npc, status);
652 #undef FLD
653 }
654
655 // ********** cmpgt: cmpgt $rm, $rn, $rd
656
657 void
658 sh5_media_sem_cmpgt (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
659         sh5_media::write_stacks &buf)
660 {
661 #define FLD(f) abuf->fields.sfmt_mcmv.f
662   sem_status status = SEM_STATUS_NORMAL;
663   sh5_media_scache* abuf = sem;
664   unsigned long long written = 0;
665   PCADDR pc = abuf->addr;
666   PCADDR npc = pc + 4;
667
668   {
669     DI opval = ((GTDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))) ? (1) : (0));
670     if (UNLIKELY(current_cpu->trace_result_p))
671       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
672     current_cpu->h_gr_set (FLD (f_dest), opval);
673   }
674
675   current_cpu->done_insn (npc, status);
676 #undef FLD
677 }
678
679 // ********** cmpgtu: cmpgtu $rm,$rn, $rd
680
681 void
682 sh5_media_sem_cmpgtu (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
683         sh5_media::write_stacks &buf)
684 {
685 #define FLD(f) abuf->fields.sfmt_mcmv.f
686   sem_status status = SEM_STATUS_NORMAL;
687   sh5_media_scache* abuf = sem;
688   unsigned long long written = 0;
689   PCADDR pc = abuf->addr;
690   PCADDR npc = pc + 4;
691
692   {
693     DI opval = ((GTUDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))) ? (1) : (0));
694     if (UNLIKELY(current_cpu->trace_result_p))
695       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
696     current_cpu->h_gr_set (FLD (f_dest), opval);
697   }
698
699   current_cpu->done_insn (npc, status);
700 #undef FLD
701 }
702
703 // ********** cmveq: cmveq $rm, $rn, $rd
704
705 void
706 sh5_media_sem_cmveq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
707         sh5_media::write_stacks &buf)
708 {
709 #define FLD(f) abuf->fields.sfmt_mcmv.f
710   sem_status status = SEM_STATUS_NORMAL;
711   sh5_media_scache* abuf = sem;
712   unsigned long long written = 0;
713   PCADDR pc = abuf->addr;
714   PCADDR npc = pc + 4;
715
716 if (EQDI (current_cpu->h_gr_get (FLD (f_left)), 0)) {
717   {
718     DI opval = current_cpu->h_gr_get (FLD (f_right));
719     written |= (1ULL << 2);
720     if (UNLIKELY(current_cpu->trace_result_p))
721       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
722     current_cpu->h_gr_set (FLD (f_dest), opval);
723   }
724 }
725
726   abuf->written = written;
727   current_cpu->done_insn (npc, status);
728 #undef FLD
729 }
730
731 // ********** cmvne: cmvne $rm, $rn, $rd
732
733 void
734 sh5_media_sem_cmvne (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
735         sh5_media::write_stacks &buf)
736 {
737 #define FLD(f) abuf->fields.sfmt_mcmv.f
738   sem_status status = SEM_STATUS_NORMAL;
739   sh5_media_scache* abuf = sem;
740   unsigned long long written = 0;
741   PCADDR pc = abuf->addr;
742   PCADDR npc = pc + 4;
743
744 if (NEDI (current_cpu->h_gr_get (FLD (f_left)), 0)) {
745   {
746     DI opval = current_cpu->h_gr_get (FLD (f_right));
747     written |= (1ULL << 2);
748     if (UNLIKELY(current_cpu->trace_result_p))
749       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
750     current_cpu->h_gr_set (FLD (f_dest), opval);
751   }
752 }
753
754   abuf->written = written;
755   current_cpu->done_insn (npc, status);
756 #undef FLD
757 }
758
759 // ********** fabsd: fabs.d $drgh, $drf
760
761 void
762 sh5_media_sem_fabsd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
763         sh5_media::write_stacks &buf)
764 {
765 #define FLD(f) abuf->fields.sfmt_fabsd.f
766   sem_status status = SEM_STATUS_NORMAL;
767   sh5_media_scache* abuf = sem;
768   unsigned long long written = 0;
769   PCADDR pc = abuf->addr;
770   PCADDR npc = pc + 4;
771
772   {
773     DF opval = current_cpu->sh64_fabsd (current_cpu->h_dr_get (FLD (f_left_right)));
774     if (UNLIKELY(current_cpu->trace_result_p))
775       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
776     current_cpu->h_dr_set (FLD (f_dest), opval);
777   }
778
779   current_cpu->done_insn (npc, status);
780 #undef FLD
781 }
782
783 // ********** fabss: fabs.s $frgh, $frf
784
785 void
786 sh5_media_sem_fabss (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
787         sh5_media::write_stacks &buf)
788 {
789 #define FLD(f) abuf->fields.sfmt_fabss.f
790   sem_status status = SEM_STATUS_NORMAL;
791   sh5_media_scache* abuf = sem;
792   unsigned long long written = 0;
793   PCADDR pc = abuf->addr;
794   PCADDR npc = pc + 4;
795
796   {
797     SF opval = current_cpu->sh64_fabss (current_cpu->hardware.h_fr[FLD (f_left_right)]);
798     if (UNLIKELY(current_cpu->trace_result_p))
799       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
800     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
801   }
802
803   current_cpu->done_insn (npc, status);
804 #undef FLD
805 }
806
807 // ********** faddd: fadd.d $drg, $drh, $drf
808
809 void
810 sh5_media_sem_faddd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
811         sh5_media::write_stacks &buf)
812 {
813 #define FLD(f) abuf->fields.sfmt_faddd.f
814   sem_status status = SEM_STATUS_NORMAL;
815   sh5_media_scache* abuf = sem;
816   unsigned long long written = 0;
817   PCADDR pc = abuf->addr;
818   PCADDR npc = pc + 4;
819
820   {
821     DF opval = current_cpu->sh64_faddd (current_cpu->h_dr_get (FLD (f_left)), current_cpu->h_dr_get (FLD (f_right)));
822     if (UNLIKELY(current_cpu->trace_result_p))
823       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
824     current_cpu->h_dr_set (FLD (f_dest), opval);
825   }
826
827   current_cpu->done_insn (npc, status);
828 #undef FLD
829 }
830
831 // ********** fadds: fadd.s $frg, $frh, $frf
832
833 void
834 sh5_media_sem_fadds (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
835         sh5_media::write_stacks &buf)
836 {
837 #define FLD(f) abuf->fields.sfmt_fmacs.f
838   sem_status status = SEM_STATUS_NORMAL;
839   sh5_media_scache* abuf = sem;
840   unsigned long long written = 0;
841   PCADDR pc = abuf->addr;
842   PCADDR npc = pc + 4;
843
844   {
845     SF opval = current_cpu->sh64_fadds (current_cpu->hardware.h_fr[FLD (f_left)], current_cpu->hardware.h_fr[FLD (f_right)]);
846     if (UNLIKELY(current_cpu->trace_result_p))
847       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
848     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
849   }
850
851   current_cpu->done_insn (npc, status);
852 #undef FLD
853 }
854
855 // ********** fcmpeqd: fcmpeq.d $drg, $drh, $rd
856
857 void
858 sh5_media_sem_fcmpeqd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
859         sh5_media::write_stacks &buf)
860 {
861 #define FLD(f) abuf->fields.sfmt_fcmpeqd.f
862   sem_status status = SEM_STATUS_NORMAL;
863   sh5_media_scache* abuf = sem;
864   unsigned long long written = 0;
865   PCADDR pc = abuf->addr;
866   PCADDR npc = pc + 4;
867
868   {
869     DI opval = ZEXTBIDI (current_cpu->sh64_fcmpeqd (current_cpu->h_dr_get (FLD (f_left)), current_cpu->h_dr_get (FLD (f_right))));
870     if (UNLIKELY(current_cpu->trace_result_p))
871       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
872     current_cpu->h_gr_set (FLD (f_dest), opval);
873   }
874
875   current_cpu->done_insn (npc, status);
876 #undef FLD
877 }
878
879 // ********** fcmpeqs: fcmpeq.s $frg, $frh, $rd
880
881 void
882 sh5_media_sem_fcmpeqs (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
883         sh5_media::write_stacks &buf)
884 {
885 #define FLD(f) abuf->fields.sfmt_fcmpeqs.f
886   sem_status status = SEM_STATUS_NORMAL;
887   sh5_media_scache* abuf = sem;
888   unsigned long long written = 0;
889   PCADDR pc = abuf->addr;
890   PCADDR npc = pc + 4;
891
892   {
893     DI opval = ZEXTBIDI (current_cpu->sh64_fcmpeqs (current_cpu->hardware.h_fr[FLD (f_left)], current_cpu->hardware.h_fr[FLD (f_right)]));
894     if (UNLIKELY(current_cpu->trace_result_p))
895       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
896     current_cpu->h_gr_set (FLD (f_dest), opval);
897   }
898
899   current_cpu->done_insn (npc, status);
900 #undef FLD
901 }
902
903 // ********** fcmpged: fcmpge.d $drg, $drh, $rd
904
905 void
906 sh5_media_sem_fcmpged (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
907         sh5_media::write_stacks &buf)
908 {
909 #define FLD(f) abuf->fields.sfmt_fcmpeqd.f
910   sem_status status = SEM_STATUS_NORMAL;
911   sh5_media_scache* abuf = sem;
912   unsigned long long written = 0;
913   PCADDR pc = abuf->addr;
914   PCADDR npc = pc + 4;
915
916   {
917     DI opval = ZEXTBIDI (current_cpu->sh64_fcmpged (current_cpu->h_dr_get (FLD (f_left)), current_cpu->h_dr_get (FLD (f_right))));
918     if (UNLIKELY(current_cpu->trace_result_p))
919       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
920     current_cpu->h_gr_set (FLD (f_dest), opval);
921   }
922
923   current_cpu->done_insn (npc, status);
924 #undef FLD
925 }
926
927 // ********** fcmpges: fcmpge.s $frg, $frh, $rd
928
929 void
930 sh5_media_sem_fcmpges (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
931         sh5_media::write_stacks &buf)
932 {
933 #define FLD(f) abuf->fields.sfmt_fcmpeqs.f
934   sem_status status = SEM_STATUS_NORMAL;
935   sh5_media_scache* abuf = sem;
936   unsigned long long written = 0;
937   PCADDR pc = abuf->addr;
938   PCADDR npc = pc + 4;
939
940   {
941     DI opval = ZEXTBIDI (current_cpu->sh64_fcmpges (current_cpu->hardware.h_fr[FLD (f_left)], current_cpu->hardware.h_fr[FLD (f_right)]));
942     if (UNLIKELY(current_cpu->trace_result_p))
943       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
944     current_cpu->h_gr_set (FLD (f_dest), opval);
945   }
946
947   current_cpu->done_insn (npc, status);
948 #undef FLD
949 }
950
951 // ********** fcmpgtd: fcmpgt.d $drg, $drh, $rd
952
953 void
954 sh5_media_sem_fcmpgtd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
955         sh5_media::write_stacks &buf)
956 {
957 #define FLD(f) abuf->fields.sfmt_fcmpeqd.f
958   sem_status status = SEM_STATUS_NORMAL;
959   sh5_media_scache* abuf = sem;
960   unsigned long long written = 0;
961   PCADDR pc = abuf->addr;
962   PCADDR npc = pc + 4;
963
964   {
965     DI opval = ZEXTBIDI (current_cpu->sh64_fcmpgtd (current_cpu->h_dr_get (FLD (f_left)), current_cpu->h_dr_get (FLD (f_right))));
966     if (UNLIKELY(current_cpu->trace_result_p))
967       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
968     current_cpu->h_gr_set (FLD (f_dest), opval);
969   }
970
971   current_cpu->done_insn (npc, status);
972 #undef FLD
973 }
974
975 // ********** fcmpgts: fcmpgt.s $frg, $frh, $rd
976
977 void
978 sh5_media_sem_fcmpgts (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
979         sh5_media::write_stacks &buf)
980 {
981 #define FLD(f) abuf->fields.sfmt_fcmpeqs.f
982   sem_status status = SEM_STATUS_NORMAL;
983   sh5_media_scache* abuf = sem;
984   unsigned long long written = 0;
985   PCADDR pc = abuf->addr;
986   PCADDR npc = pc + 4;
987
988   {
989     DI opval = ZEXTBIDI (current_cpu->sh64_fcmpgts (current_cpu->hardware.h_fr[FLD (f_left)], current_cpu->hardware.h_fr[FLD (f_right)]));
990     if (UNLIKELY(current_cpu->trace_result_p))
991       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
992     current_cpu->h_gr_set (FLD (f_dest), opval);
993   }
994
995   current_cpu->done_insn (npc, status);
996 #undef FLD
997 }
998
999 // ********** fcmpund: fcmpun.d $drg, $drh, $rd
1000
1001 void
1002 sh5_media_sem_fcmpund (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1003         sh5_media::write_stacks &buf)
1004 {
1005 #define FLD(f) abuf->fields.sfmt_fcmpeqd.f
1006   sem_status status = SEM_STATUS_NORMAL;
1007   sh5_media_scache* abuf = sem;
1008   unsigned long long written = 0;
1009   PCADDR pc = abuf->addr;
1010   PCADDR npc = pc + 4;
1011
1012   {
1013     DI opval = ZEXTBIDI (current_cpu->sh64_fcmpund (current_cpu->h_dr_get (FLD (f_left)), current_cpu->h_dr_get (FLD (f_right))));
1014     if (UNLIKELY(current_cpu->trace_result_p))
1015       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1016     current_cpu->h_gr_set (FLD (f_dest), opval);
1017   }
1018
1019   current_cpu->done_insn (npc, status);
1020 #undef FLD
1021 }
1022
1023 // ********** fcmpuns: fcmpun.s $frg, $frh, $rd
1024
1025 void
1026 sh5_media_sem_fcmpuns (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1027         sh5_media::write_stacks &buf)
1028 {
1029 #define FLD(f) abuf->fields.sfmt_fcmpeqs.f
1030   sem_status status = SEM_STATUS_NORMAL;
1031   sh5_media_scache* abuf = sem;
1032   unsigned long long written = 0;
1033   PCADDR pc = abuf->addr;
1034   PCADDR npc = pc + 4;
1035
1036   {
1037     DI opval = ZEXTBIDI (current_cpu->sh64_fcmpuns (current_cpu->hardware.h_fr[FLD (f_left)], current_cpu->hardware.h_fr[FLD (f_right)]));
1038     if (UNLIKELY(current_cpu->trace_result_p))
1039       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1040     current_cpu->h_gr_set (FLD (f_dest), opval);
1041   }
1042
1043   current_cpu->done_insn (npc, status);
1044 #undef FLD
1045 }
1046
1047 // ********** fcnvds: fcnv.ds $drgh, $frf
1048
1049 void
1050 sh5_media_sem_fcnvds (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1051         sh5_media::write_stacks &buf)
1052 {
1053 #define FLD(f) abuf->fields.sfmt_fcnvds.f
1054   sem_status status = SEM_STATUS_NORMAL;
1055   sh5_media_scache* abuf = sem;
1056   unsigned long long written = 0;
1057   PCADDR pc = abuf->addr;
1058   PCADDR npc = pc + 4;
1059
1060   {
1061     SF opval = current_cpu->sh64_fcnvds (current_cpu->h_dr_get (FLD (f_left_right)));
1062     if (UNLIKELY(current_cpu->trace_result_p))
1063       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1064     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1065   }
1066
1067   current_cpu->done_insn (npc, status);
1068 #undef FLD
1069 }
1070
1071 // ********** fcnvsd: fcnv.sd $frgh, $drf
1072
1073 void
1074 sh5_media_sem_fcnvsd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1075         sh5_media::write_stacks &buf)
1076 {
1077 #define FLD(f) abuf->fields.sfmt_fcnvsd.f
1078   sem_status status = SEM_STATUS_NORMAL;
1079   sh5_media_scache* abuf = sem;
1080   unsigned long long written = 0;
1081   PCADDR pc = abuf->addr;
1082   PCADDR npc = pc + 4;
1083
1084   {
1085     DF opval = current_cpu->sh64_fcnvsd (current_cpu->hardware.h_fr[FLD (f_left_right)]);
1086     if (UNLIKELY(current_cpu->trace_result_p))
1087       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1088     current_cpu->h_dr_set (FLD (f_dest), opval);
1089   }
1090
1091   current_cpu->done_insn (npc, status);
1092 #undef FLD
1093 }
1094
1095 // ********** fdivd: fdiv.d $drg, $drh, $drf
1096
1097 void
1098 sh5_media_sem_fdivd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1099         sh5_media::write_stacks &buf)
1100 {
1101 #define FLD(f) abuf->fields.sfmt_faddd.f
1102   sem_status status = SEM_STATUS_NORMAL;
1103   sh5_media_scache* abuf = sem;
1104   unsigned long long written = 0;
1105   PCADDR pc = abuf->addr;
1106   PCADDR npc = pc + 4;
1107
1108   {
1109     DF opval = current_cpu->sh64_fdivd (current_cpu->h_dr_get (FLD (f_left)), current_cpu->h_dr_get (FLD (f_right)));
1110     if (UNLIKELY(current_cpu->trace_result_p))
1111       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1112     current_cpu->h_dr_set (FLD (f_dest), opval);
1113   }
1114
1115   current_cpu->done_insn (npc, status);
1116 #undef FLD
1117 }
1118
1119 // ********** fdivs: fdiv.s $frg, $frh, $frf
1120
1121 void
1122 sh5_media_sem_fdivs (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1123         sh5_media::write_stacks &buf)
1124 {
1125 #define FLD(f) abuf->fields.sfmt_fmacs.f
1126   sem_status status = SEM_STATUS_NORMAL;
1127   sh5_media_scache* abuf = sem;
1128   unsigned long long written = 0;
1129   PCADDR pc = abuf->addr;
1130   PCADDR npc = pc + 4;
1131
1132   {
1133     SF opval = current_cpu->sh64_fdivs (current_cpu->hardware.h_fr[FLD (f_left)], current_cpu->hardware.h_fr[FLD (f_right)]);
1134     if (UNLIKELY(current_cpu->trace_result_p))
1135       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1136     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1137   }
1138
1139   current_cpu->done_insn (npc, status);
1140 #undef FLD
1141 }
1142
1143 // ********** fgetscr: fgetscr $frf
1144
1145 void
1146 sh5_media_sem_fgetscr (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1147         sh5_media::write_stacks &buf)
1148 {
1149 #define FLD(f) abuf->fields.sfmt_fcnvds.f
1150   sem_status status = SEM_STATUS_NORMAL;
1151   sh5_media_scache* abuf = sem;
1152   unsigned long long written = 0;
1153   PCADDR pc = abuf->addr;
1154   PCADDR npc = pc + 4;
1155
1156   {
1157     SF opval = SUBWORDSISF (current_cpu->hardware.h_fpscr);
1158     if (UNLIKELY(current_cpu->trace_result_p))
1159       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1160     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1161   }
1162
1163   current_cpu->done_insn (npc, status);
1164 #undef FLD
1165 }
1166
1167 // ********** fiprs: fipr.s $fvg, $fvh, $frf
1168
1169 void
1170 sh5_media_sem_fiprs (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1171         sh5_media::write_stacks &buf)
1172 {
1173 #define FLD(f) abuf->fields.sfmt_fiprs.f
1174   sem_status status = SEM_STATUS_NORMAL;
1175   sh5_media_scache* abuf = sem;
1176   unsigned long long written = 0;
1177   PCADDR pc = abuf->addr;
1178   PCADDR npc = pc + 4;
1179
1180 {
1181   {
1182     SF opval = current_cpu->h_fv_get (FLD (f_left));
1183     if (UNLIKELY(current_cpu->trace_result_p))
1184       current_cpu->trace_stream << "fv" << '[' << FLD (f_left) << ']' << ":=0x" << hex << opval << dec << "  ";
1185     current_cpu->h_fv_set (FLD (f_left), opval);
1186   }
1187   {
1188     SF opval = current_cpu->h_fv_get (FLD (f_right));
1189     if (UNLIKELY(current_cpu->trace_result_p))
1190       current_cpu->trace_stream << "fv" << '[' << FLD (f_right) << ']' << ":=0x" << hex << opval << dec << "  ";
1191     current_cpu->h_fv_set (FLD (f_right), opval);
1192   }
1193   {
1194     SF opval = current_cpu->sh64_fiprs (FLD (f_left), FLD (f_right));
1195     if (UNLIKELY(current_cpu->trace_result_p))
1196       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1197     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1198   }
1199 }
1200
1201   current_cpu->done_insn (npc, status);
1202 #undef FLD
1203 }
1204
1205 // ********** fldd: fld.d $rm, $disp10x8, $drf
1206
1207 void
1208 sh5_media_sem_fldd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1209         sh5_media::write_stacks &buf)
1210 {
1211 #define FLD(f) abuf->fields.sfmt_fldd.f
1212   sem_status status = SEM_STATUS_NORMAL;
1213   sh5_media_scache* abuf = sem;
1214   unsigned long long written = 0;
1215   PCADDR pc = abuf->addr;
1216   PCADDR npc = pc + 4;
1217
1218   {
1219     DF opval = current_cpu->GETMEMDF (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp10x8)));
1220     if (UNLIKELY(current_cpu->trace_result_p))
1221       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1222     current_cpu->h_dr_set (FLD (f_dest), opval);
1223   }
1224
1225   current_cpu->done_insn (npc, status);
1226 #undef FLD
1227 }
1228
1229 // ********** fldp: fld.p $rm, $disp10x8, $fpf
1230
1231 void
1232 sh5_media_sem_fldp (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1233         sh5_media::write_stacks &buf)
1234 {
1235 #define FLD(f) abuf->fields.sfmt_fldp.f
1236   sem_status status = SEM_STATUS_NORMAL;
1237   sh5_media_scache* abuf = sem;
1238   unsigned long long written = 0;
1239   PCADDR pc = abuf->addr;
1240   PCADDR npc = pc + 4;
1241
1242 {
1243   {
1244     SF opval = current_cpu->h_fp_get (FLD (f_dest));
1245     if (UNLIKELY(current_cpu->trace_result_p))
1246       current_cpu->trace_stream << "fp" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1247     current_cpu->h_fp_set (FLD (f_dest), opval);
1248   }
1249 current_cpu->sh64_fldp (pc, current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp10x8), FLD (f_dest));
1250 }
1251
1252   current_cpu->done_insn (npc, status);
1253 #undef FLD
1254 }
1255
1256 // ********** flds: fld.s $rm, $disp10x4, $frf
1257
1258 void
1259 sh5_media_sem_flds (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1260         sh5_media::write_stacks &buf)
1261 {
1262 #define FLD(f) abuf->fields.sfmt_flds.f
1263   sem_status status = SEM_STATUS_NORMAL;
1264   sh5_media_scache* abuf = sem;
1265   unsigned long long written = 0;
1266   PCADDR pc = abuf->addr;
1267   PCADDR npc = pc + 4;
1268
1269   {
1270     SF opval = current_cpu->GETMEMSF (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp10x4)));
1271     if (UNLIKELY(current_cpu->trace_result_p))
1272       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1273     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1274   }
1275
1276   current_cpu->done_insn (npc, status);
1277 #undef FLD
1278 }
1279
1280 // ********** fldxd: fldx.d $rm, $rn, $drf
1281
1282 void
1283 sh5_media_sem_fldxd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1284         sh5_media::write_stacks &buf)
1285 {
1286 #define FLD(f) abuf->fields.sfmt_fldxd.f
1287   sem_status status = SEM_STATUS_NORMAL;
1288   sh5_media_scache* abuf = sem;
1289   unsigned long long written = 0;
1290   PCADDR pc = abuf->addr;
1291   PCADDR npc = pc + 4;
1292
1293   {
1294     DF opval = current_cpu->GETMEMDF (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))));
1295     if (UNLIKELY(current_cpu->trace_result_p))
1296       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1297     current_cpu->h_dr_set (FLD (f_dest), opval);
1298   }
1299
1300   current_cpu->done_insn (npc, status);
1301 #undef FLD
1302 }
1303
1304 // ********** fldxp: fldx.p $rm, $rn, $fpf
1305
1306 void
1307 sh5_media_sem_fldxp (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1308         sh5_media::write_stacks &buf)
1309 {
1310 #define FLD(f) abuf->fields.sfmt_fldxp.f
1311   sem_status status = SEM_STATUS_NORMAL;
1312   sh5_media_scache* abuf = sem;
1313   unsigned long long written = 0;
1314   PCADDR pc = abuf->addr;
1315   PCADDR npc = pc + 4;
1316
1317 {
1318   {
1319     SF opval = current_cpu->h_fp_get (FLD (f_dest));
1320     if (UNLIKELY(current_cpu->trace_result_p))
1321       current_cpu->trace_stream << "fp" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1322     current_cpu->h_fp_set (FLD (f_dest), opval);
1323   }
1324 current_cpu->sh64_fldp (pc, current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)), FLD (f_dest));
1325 }
1326
1327   current_cpu->done_insn (npc, status);
1328 #undef FLD
1329 }
1330
1331 // ********** fldxs: fldx.s $rm, $rn, $frf
1332
1333 void
1334 sh5_media_sem_fldxs (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1335         sh5_media::write_stacks &buf)
1336 {
1337 #define FLD(f) abuf->fields.sfmt_fldxs.f
1338   sem_status status = SEM_STATUS_NORMAL;
1339   sh5_media_scache* abuf = sem;
1340   unsigned long long written = 0;
1341   PCADDR pc = abuf->addr;
1342   PCADDR npc = pc + 4;
1343
1344   {
1345     SF opval = current_cpu->GETMEMSF (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))));
1346     if (UNLIKELY(current_cpu->trace_result_p))
1347       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1348     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1349   }
1350
1351   current_cpu->done_insn (npc, status);
1352 #undef FLD
1353 }
1354
1355 // ********** floatld: float.ld $frgh, $drf
1356
1357 void
1358 sh5_media_sem_floatld (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1359         sh5_media::write_stacks &buf)
1360 {
1361 #define FLD(f) abuf->fields.sfmt_fcnvsd.f
1362   sem_status status = SEM_STATUS_NORMAL;
1363   sh5_media_scache* abuf = sem;
1364   unsigned long long written = 0;
1365   PCADDR pc = abuf->addr;
1366   PCADDR npc = pc + 4;
1367
1368   {
1369     DF opval = current_cpu->sh64_floatld (current_cpu->hardware.h_fr[FLD (f_left_right)]);
1370     if (UNLIKELY(current_cpu->trace_result_p))
1371       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1372     current_cpu->h_dr_set (FLD (f_dest), opval);
1373   }
1374
1375   current_cpu->done_insn (npc, status);
1376 #undef FLD
1377 }
1378
1379 // ********** floatls: float.ls $frgh, $frf
1380
1381 void
1382 sh5_media_sem_floatls (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1383         sh5_media::write_stacks &buf)
1384 {
1385 #define FLD(f) abuf->fields.sfmt_fabss.f
1386   sem_status status = SEM_STATUS_NORMAL;
1387   sh5_media_scache* abuf = sem;
1388   unsigned long long written = 0;
1389   PCADDR pc = abuf->addr;
1390   PCADDR npc = pc + 4;
1391
1392   {
1393     SF opval = current_cpu->sh64_floatls (current_cpu->hardware.h_fr[FLD (f_left_right)]);
1394     if (UNLIKELY(current_cpu->trace_result_p))
1395       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1396     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1397   }
1398
1399   current_cpu->done_insn (npc, status);
1400 #undef FLD
1401 }
1402
1403 // ********** floatqd: float.qd $drgh, $drf
1404
1405 void
1406 sh5_media_sem_floatqd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1407         sh5_media::write_stacks &buf)
1408 {
1409 #define FLD(f) abuf->fields.sfmt_fabsd.f
1410   sem_status status = SEM_STATUS_NORMAL;
1411   sh5_media_scache* abuf = sem;
1412   unsigned long long written = 0;
1413   PCADDR pc = abuf->addr;
1414   PCADDR npc = pc + 4;
1415
1416   {
1417     DF opval = current_cpu->sh64_floatqd (current_cpu->h_dr_get (FLD (f_left_right)));
1418     if (UNLIKELY(current_cpu->trace_result_p))
1419       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1420     current_cpu->h_dr_set (FLD (f_dest), opval);
1421   }
1422
1423   current_cpu->done_insn (npc, status);
1424 #undef FLD
1425 }
1426
1427 // ********** floatqs: float.qs $drgh, $frf
1428
1429 void
1430 sh5_media_sem_floatqs (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1431         sh5_media::write_stacks &buf)
1432 {
1433 #define FLD(f) abuf->fields.sfmt_fcnvds.f
1434   sem_status status = SEM_STATUS_NORMAL;
1435   sh5_media_scache* abuf = sem;
1436   unsigned long long written = 0;
1437   PCADDR pc = abuf->addr;
1438   PCADDR npc = pc + 4;
1439
1440   {
1441     SF opval = current_cpu->sh64_floatqs (current_cpu->h_dr_get (FLD (f_left_right)));
1442     if (UNLIKELY(current_cpu->trace_result_p))
1443       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1444     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1445   }
1446
1447   current_cpu->done_insn (npc, status);
1448 #undef FLD
1449 }
1450
1451 // ********** fmacs: fmac.s $frg, $frh, $frf
1452
1453 void
1454 sh5_media_sem_fmacs (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1455         sh5_media::write_stacks &buf)
1456 {
1457 #define FLD(f) abuf->fields.sfmt_fmacs.f
1458   sem_status status = SEM_STATUS_NORMAL;
1459   sh5_media_scache* abuf = sem;
1460   unsigned long long written = 0;
1461   PCADDR pc = abuf->addr;
1462   PCADDR npc = pc + 4;
1463
1464   {
1465     SF opval = current_cpu->sh64_fadds (current_cpu->hardware.h_fr[FLD (f_dest)], current_cpu->sh64_fmuls (current_cpu->hardware.h_fr[FLD (f_left)], current_cpu->hardware.h_fr[FLD (f_right)]));
1466     if (UNLIKELY(current_cpu->trace_result_p))
1467       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1468     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1469   }
1470
1471   current_cpu->done_insn (npc, status);
1472 #undef FLD
1473 }
1474
1475 // ********** fmovd: fmov.d $drgh, $drf
1476
1477 void
1478 sh5_media_sem_fmovd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1479         sh5_media::write_stacks &buf)
1480 {
1481 #define FLD(f) abuf->fields.sfmt_fabsd.f
1482   sem_status status = SEM_STATUS_NORMAL;
1483   sh5_media_scache* abuf = sem;
1484   unsigned long long written = 0;
1485   PCADDR pc = abuf->addr;
1486   PCADDR npc = pc + 4;
1487
1488   {
1489     DF opval = current_cpu->h_dr_get (FLD (f_left_right));
1490     if (UNLIKELY(current_cpu->trace_result_p))
1491       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1492     current_cpu->h_dr_set (FLD (f_dest), opval);
1493   }
1494
1495   current_cpu->done_insn (npc, status);
1496 #undef FLD
1497 }
1498
1499 // ********** fmovdq: fmov.dq $drgh, $rd
1500
1501 void
1502 sh5_media_sem_fmovdq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1503         sh5_media::write_stacks &buf)
1504 {
1505 #define FLD(f) abuf->fields.sfmt_fmovdq.f
1506   sem_status status = SEM_STATUS_NORMAL;
1507   sh5_media_scache* abuf = sem;
1508   unsigned long long written = 0;
1509   PCADDR pc = abuf->addr;
1510   PCADDR npc = pc + 4;
1511
1512   {
1513     DI opval = SUBWORDDFDI (current_cpu->h_dr_get (FLD (f_left_right)));
1514     if (UNLIKELY(current_cpu->trace_result_p))
1515       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1516     current_cpu->h_gr_set (FLD (f_dest), opval);
1517   }
1518
1519   current_cpu->done_insn (npc, status);
1520 #undef FLD
1521 }
1522
1523 // ********** fmovls: fmov.ls $rm, $frf
1524
1525 void
1526 sh5_media_sem_fmovls (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1527         sh5_media::write_stacks &buf)
1528 {
1529 #define FLD(f) abuf->fields.sfmt_flds.f
1530   sem_status status = SEM_STATUS_NORMAL;
1531   sh5_media_scache* abuf = sem;
1532   unsigned long long written = 0;
1533   PCADDR pc = abuf->addr;
1534   PCADDR npc = pc + 4;
1535
1536   {
1537     SF opval = SUBWORDSISF (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1));
1538     if (UNLIKELY(current_cpu->trace_result_p))
1539       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1540     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1541   }
1542
1543   current_cpu->done_insn (npc, status);
1544 #undef FLD
1545 }
1546
1547 // ********** fmovqd: fmov.qd $rm, $drf
1548
1549 void
1550 sh5_media_sem_fmovqd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1551         sh5_media::write_stacks &buf)
1552 {
1553 #define FLD(f) abuf->fields.sfmt_fldd.f
1554   sem_status status = SEM_STATUS_NORMAL;
1555   sh5_media_scache* abuf = sem;
1556   unsigned long long written = 0;
1557   PCADDR pc = abuf->addr;
1558   PCADDR npc = pc + 4;
1559
1560   {
1561     DF opval = SUBWORDDIDF (current_cpu->h_gr_get (FLD (f_left)));
1562     if (UNLIKELY(current_cpu->trace_result_p))
1563       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1564     current_cpu->h_dr_set (FLD (f_dest), opval);
1565   }
1566
1567   current_cpu->done_insn (npc, status);
1568 #undef FLD
1569 }
1570
1571 // ********** fmovs: fmov.s $frgh, $frf
1572
1573 void
1574 sh5_media_sem_fmovs (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1575         sh5_media::write_stacks &buf)
1576 {
1577 #define FLD(f) abuf->fields.sfmt_fabss.f
1578   sem_status status = SEM_STATUS_NORMAL;
1579   sh5_media_scache* abuf = sem;
1580   unsigned long long written = 0;
1581   PCADDR pc = abuf->addr;
1582   PCADDR npc = pc + 4;
1583
1584   {
1585     SF opval = current_cpu->hardware.h_fr[FLD (f_left_right)];
1586     if (UNLIKELY(current_cpu->trace_result_p))
1587       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1588     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1589   }
1590
1591   current_cpu->done_insn (npc, status);
1592 #undef FLD
1593 }
1594
1595 // ********** fmovsl: fmov.sl $frgh, $rd
1596
1597 void
1598 sh5_media_sem_fmovsl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1599         sh5_media::write_stacks &buf)
1600 {
1601 #define FLD(f) abuf->fields.sfmt_fmovsl.f
1602   sem_status status = SEM_STATUS_NORMAL;
1603   sh5_media_scache* abuf = sem;
1604   unsigned long long written = 0;
1605   PCADDR pc = abuf->addr;
1606   PCADDR npc = pc + 4;
1607
1608   {
1609     DI opval = EXTSIDI (SUBWORDSFSI (current_cpu->hardware.h_fr[FLD (f_left_right)]));
1610     if (UNLIKELY(current_cpu->trace_result_p))
1611       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1612     current_cpu->h_gr_set (FLD (f_dest), opval);
1613   }
1614
1615   current_cpu->done_insn (npc, status);
1616 #undef FLD
1617 }
1618
1619 // ********** fmuld: fmul.d $drg, $drh, $drf
1620
1621 void
1622 sh5_media_sem_fmuld (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1623         sh5_media::write_stacks &buf)
1624 {
1625 #define FLD(f) abuf->fields.sfmt_faddd.f
1626   sem_status status = SEM_STATUS_NORMAL;
1627   sh5_media_scache* abuf = sem;
1628   unsigned long long written = 0;
1629   PCADDR pc = abuf->addr;
1630   PCADDR npc = pc + 4;
1631
1632   {
1633     DF opval = current_cpu->sh64_fmuld (current_cpu->h_dr_get (FLD (f_left)), current_cpu->h_dr_get (FLD (f_right)));
1634     if (UNLIKELY(current_cpu->trace_result_p))
1635       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1636     current_cpu->h_dr_set (FLD (f_dest), opval);
1637   }
1638
1639   current_cpu->done_insn (npc, status);
1640 #undef FLD
1641 }
1642
1643 // ********** fmuls: fmul.s $frg, $frh, $frf
1644
1645 void
1646 sh5_media_sem_fmuls (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1647         sh5_media::write_stacks &buf)
1648 {
1649 #define FLD(f) abuf->fields.sfmt_fmacs.f
1650   sem_status status = SEM_STATUS_NORMAL;
1651   sh5_media_scache* abuf = sem;
1652   unsigned long long written = 0;
1653   PCADDR pc = abuf->addr;
1654   PCADDR npc = pc + 4;
1655
1656   {
1657     SF opval = current_cpu->sh64_fmuls (current_cpu->hardware.h_fr[FLD (f_left)], current_cpu->hardware.h_fr[FLD (f_right)]);
1658     if (UNLIKELY(current_cpu->trace_result_p))
1659       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1660     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1661   }
1662
1663   current_cpu->done_insn (npc, status);
1664 #undef FLD
1665 }
1666
1667 // ********** fnegd: fneg.d $drgh, $drf
1668
1669 void
1670 sh5_media_sem_fnegd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1671         sh5_media::write_stacks &buf)
1672 {
1673 #define FLD(f) abuf->fields.sfmt_fabsd.f
1674   sem_status status = SEM_STATUS_NORMAL;
1675   sh5_media_scache* abuf = sem;
1676   unsigned long long written = 0;
1677   PCADDR pc = abuf->addr;
1678   PCADDR npc = pc + 4;
1679
1680   {
1681     DF opval = current_cpu->sh64_fnegd (current_cpu->h_dr_get (FLD (f_left_right)));
1682     if (UNLIKELY(current_cpu->trace_result_p))
1683       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1684     current_cpu->h_dr_set (FLD (f_dest), opval);
1685   }
1686
1687   current_cpu->done_insn (npc, status);
1688 #undef FLD
1689 }
1690
1691 // ********** fnegs: fneg.s $frgh, $frf
1692
1693 void
1694 sh5_media_sem_fnegs (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1695         sh5_media::write_stacks &buf)
1696 {
1697 #define FLD(f) abuf->fields.sfmt_fabss.f
1698   sem_status status = SEM_STATUS_NORMAL;
1699   sh5_media_scache* abuf = sem;
1700   unsigned long long written = 0;
1701   PCADDR pc = abuf->addr;
1702   PCADDR npc = pc + 4;
1703
1704   {
1705     SF opval = current_cpu->sh64_fnegs (current_cpu->hardware.h_fr[FLD (f_left_right)]);
1706     if (UNLIKELY(current_cpu->trace_result_p))
1707       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1708     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1709   }
1710
1711   current_cpu->done_insn (npc, status);
1712 #undef FLD
1713 }
1714
1715 // ********** fputscr: fputscr $frgh
1716
1717 void
1718 sh5_media_sem_fputscr (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1719         sh5_media::write_stacks &buf)
1720 {
1721 #define FLD(f) abuf->fields.sfmt_fmovsl.f
1722   sem_status status = SEM_STATUS_NORMAL;
1723   sh5_media_scache* abuf = sem;
1724   unsigned long long written = 0;
1725   PCADDR pc = abuf->addr;
1726   PCADDR npc = pc + 4;
1727
1728   {
1729     SI opval = SUBWORDSFSI (current_cpu->hardware.h_fr[FLD (f_left_right)]);
1730     if (UNLIKELY(current_cpu->trace_result_p))
1731       current_cpu->trace_stream << "fpscr" << ":=0x" << hex << opval << dec << "  ";
1732     current_cpu->hardware.h_fpscr = opval;
1733   }
1734
1735   current_cpu->done_insn (npc, status);
1736 #undef FLD
1737 }
1738
1739 // ********** fsqrtd: fsqrt.d $drgh, $drf
1740
1741 void
1742 sh5_media_sem_fsqrtd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1743         sh5_media::write_stacks &buf)
1744 {
1745 #define FLD(f) abuf->fields.sfmt_fabsd.f
1746   sem_status status = SEM_STATUS_NORMAL;
1747   sh5_media_scache* abuf = sem;
1748   unsigned long long written = 0;
1749   PCADDR pc = abuf->addr;
1750   PCADDR npc = pc + 4;
1751
1752   {
1753     DF opval = current_cpu->sh64_fsqrtd (current_cpu->h_dr_get (FLD (f_left_right)));
1754     if (UNLIKELY(current_cpu->trace_result_p))
1755       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1756     current_cpu->h_dr_set (FLD (f_dest), opval);
1757   }
1758
1759   current_cpu->done_insn (npc, status);
1760 #undef FLD
1761 }
1762
1763 // ********** fsqrts: fsqrt.s $frgh, $frf
1764
1765 void
1766 sh5_media_sem_fsqrts (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1767         sh5_media::write_stacks &buf)
1768 {
1769 #define FLD(f) abuf->fields.sfmt_fabss.f
1770   sem_status status = SEM_STATUS_NORMAL;
1771   sh5_media_scache* abuf = sem;
1772   unsigned long long written = 0;
1773   PCADDR pc = abuf->addr;
1774   PCADDR npc = pc + 4;
1775
1776   {
1777     SF opval = current_cpu->sh64_fsqrts (current_cpu->hardware.h_fr[FLD (f_left_right)]);
1778     if (UNLIKELY(current_cpu->trace_result_p))
1779       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1780     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1781   }
1782
1783   current_cpu->done_insn (npc, status);
1784 #undef FLD
1785 }
1786
1787 // ********** fstd: fst.d $rm, $disp10x8, $drf
1788
1789 void
1790 sh5_media_sem_fstd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1791         sh5_media::write_stacks &buf)
1792 {
1793 #define FLD(f) abuf->fields.sfmt_fstd.f
1794   sem_status status = SEM_STATUS_NORMAL;
1795   sh5_media_scache* abuf = sem;
1796   unsigned long long written = 0;
1797   PCADDR pc = abuf->addr;
1798   PCADDR npc = pc + 4;
1799
1800   {
1801     DF opval = current_cpu->h_dr_get (FLD (f_dest));
1802     if (UNLIKELY(current_cpu->trace_result_p))
1803       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp10x8)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
1804     current_cpu->SETMEMDF (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp10x8)), opval);
1805   }
1806
1807   current_cpu->done_insn (npc, status);
1808 #undef FLD
1809 }
1810
1811 // ********** fstp: fst.p $rm, $disp10x8, $fpf
1812
1813 void
1814 sh5_media_sem_fstp (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1815         sh5_media::write_stacks &buf)
1816 {
1817 #define FLD(f) abuf->fields.sfmt_fldp.f
1818   sem_status status = SEM_STATUS_NORMAL;
1819   sh5_media_scache* abuf = sem;
1820   unsigned long long written = 0;
1821   PCADDR pc = abuf->addr;
1822   PCADDR npc = pc + 4;
1823
1824 {
1825   {
1826     SF opval = current_cpu->h_fp_get (FLD (f_dest));
1827     if (UNLIKELY(current_cpu->trace_result_p))
1828       current_cpu->trace_stream << "fp" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1829     current_cpu->h_fp_set (FLD (f_dest), opval);
1830   }
1831 current_cpu->sh64_fstp (pc, current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp10x8), FLD (f_dest));
1832 }
1833
1834   current_cpu->done_insn (npc, status);
1835 #undef FLD
1836 }
1837
1838 // ********** fsts: fst.s $rm, $disp10x4, $frf
1839
1840 void
1841 sh5_media_sem_fsts (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1842         sh5_media::write_stacks &buf)
1843 {
1844 #define FLD(f) abuf->fields.sfmt_fsts.f
1845   sem_status status = SEM_STATUS_NORMAL;
1846   sh5_media_scache* abuf = sem;
1847   unsigned long long written = 0;
1848   PCADDR pc = abuf->addr;
1849   PCADDR npc = pc + 4;
1850
1851   {
1852     SF opval = current_cpu->hardware.h_fr[FLD (f_dest)];
1853     if (UNLIKELY(current_cpu->trace_result_p))
1854       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp10x4)) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
1855     current_cpu->SETMEMSF (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp10x4)), opval);
1856   }
1857
1858   current_cpu->done_insn (npc, status);
1859 #undef FLD
1860 }
1861
1862 // ********** fstxd: fstx.d $rm, $rn, $drf
1863
1864 void
1865 sh5_media_sem_fstxd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1866         sh5_media::write_stacks &buf)
1867 {
1868 #define FLD(f) abuf->fields.sfmt_fstxd.f
1869   sem_status status = SEM_STATUS_NORMAL;
1870   sh5_media_scache* abuf = sem;
1871   unsigned long long written = 0;
1872   PCADDR pc = abuf->addr;
1873   PCADDR npc = pc + 4;
1874
1875   {
1876     DF opval = current_cpu->h_dr_get (FLD (f_dest));
1877     if (UNLIKELY(current_cpu->trace_result_p))
1878       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
1879     current_cpu->SETMEMDF (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))), opval);
1880   }
1881
1882   current_cpu->done_insn (npc, status);
1883 #undef FLD
1884 }
1885
1886 // ********** fstxp: fstx.p $rm, $rn, $fpf
1887
1888 void
1889 sh5_media_sem_fstxp (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1890         sh5_media::write_stacks &buf)
1891 {
1892 #define FLD(f) abuf->fields.sfmt_fldxp.f
1893   sem_status status = SEM_STATUS_NORMAL;
1894   sh5_media_scache* abuf = sem;
1895   unsigned long long written = 0;
1896   PCADDR pc = abuf->addr;
1897   PCADDR npc = pc + 4;
1898
1899 {
1900   {
1901     SF opval = current_cpu->h_fp_get (FLD (f_dest));
1902     if (UNLIKELY(current_cpu->trace_result_p))
1903       current_cpu->trace_stream << "fp" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1904     current_cpu->h_fp_set (FLD (f_dest), opval);
1905   }
1906 current_cpu->sh64_fstp (pc, current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)), FLD (f_dest));
1907 }
1908
1909   current_cpu->done_insn (npc, status);
1910 #undef FLD
1911 }
1912
1913 // ********** fstxs: fstx.s $rm, $rn, $frf
1914
1915 void
1916 sh5_media_sem_fstxs (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1917         sh5_media::write_stacks &buf)
1918 {
1919 #define FLD(f) abuf->fields.sfmt_fstxs.f
1920   sem_status status = SEM_STATUS_NORMAL;
1921   sh5_media_scache* abuf = sem;
1922   unsigned long long written = 0;
1923   PCADDR pc = abuf->addr;
1924   PCADDR npc = pc + 4;
1925
1926   {
1927     SF opval = current_cpu->hardware.h_fr[FLD (f_dest)];
1928     if (UNLIKELY(current_cpu->trace_result_p))
1929       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
1930     current_cpu->SETMEMSF (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))), opval);
1931   }
1932
1933   current_cpu->done_insn (npc, status);
1934 #undef FLD
1935 }
1936
1937 // ********** fsubd: fsub.d $drg, $drh, $drf
1938
1939 void
1940 sh5_media_sem_fsubd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1941         sh5_media::write_stacks &buf)
1942 {
1943 #define FLD(f) abuf->fields.sfmt_faddd.f
1944   sem_status status = SEM_STATUS_NORMAL;
1945   sh5_media_scache* abuf = sem;
1946   unsigned long long written = 0;
1947   PCADDR pc = abuf->addr;
1948   PCADDR npc = pc + 4;
1949
1950   {
1951     DF opval = current_cpu->sh64_fsubd (current_cpu->h_dr_get (FLD (f_left)), current_cpu->h_dr_get (FLD (f_right)));
1952     if (UNLIKELY(current_cpu->trace_result_p))
1953       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1954     current_cpu->h_dr_set (FLD (f_dest), opval);
1955   }
1956
1957   current_cpu->done_insn (npc, status);
1958 #undef FLD
1959 }
1960
1961 // ********** fsubs: fsub.s $frg, $frh, $frf
1962
1963 void
1964 sh5_media_sem_fsubs (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1965         sh5_media::write_stacks &buf)
1966 {
1967 #define FLD(f) abuf->fields.sfmt_fmacs.f
1968   sem_status status = SEM_STATUS_NORMAL;
1969   sh5_media_scache* abuf = sem;
1970   unsigned long long written = 0;
1971   PCADDR pc = abuf->addr;
1972   PCADDR npc = pc + 4;
1973
1974   {
1975     SF opval = current_cpu->sh64_fsubs (current_cpu->hardware.h_fr[FLD (f_left)], current_cpu->hardware.h_fr[FLD (f_right)]);
1976     if (UNLIKELY(current_cpu->trace_result_p))
1977       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
1978     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
1979   }
1980
1981   current_cpu->done_insn (npc, status);
1982 #undef FLD
1983 }
1984
1985 // ********** ftrcdl: ftrc.dl $drgh, $frf
1986
1987 void
1988 sh5_media_sem_ftrcdl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
1989         sh5_media::write_stacks &buf)
1990 {
1991 #define FLD(f) abuf->fields.sfmt_fcnvds.f
1992   sem_status status = SEM_STATUS_NORMAL;
1993   sh5_media_scache* abuf = sem;
1994   unsigned long long written = 0;
1995   PCADDR pc = abuf->addr;
1996   PCADDR npc = pc + 4;
1997
1998   {
1999     SF opval = current_cpu->sh64_ftrcdl (current_cpu->h_dr_get (FLD (f_left_right)));
2000     if (UNLIKELY(current_cpu->trace_result_p))
2001       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2002     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
2003   }
2004
2005   current_cpu->done_insn (npc, status);
2006 #undef FLD
2007 }
2008
2009 // ********** ftrcsl: ftrc.sl $frgh, $frf
2010
2011 void
2012 sh5_media_sem_ftrcsl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2013         sh5_media::write_stacks &buf)
2014 {
2015 #define FLD(f) abuf->fields.sfmt_fabss.f
2016   sem_status status = SEM_STATUS_NORMAL;
2017   sh5_media_scache* abuf = sem;
2018   unsigned long long written = 0;
2019   PCADDR pc = abuf->addr;
2020   PCADDR npc = pc + 4;
2021
2022   {
2023     SF opval = current_cpu->sh64_ftrcsl (current_cpu->hardware.h_fr[FLD (f_left_right)]);
2024     if (UNLIKELY(current_cpu->trace_result_p))
2025       current_cpu->trace_stream << "fr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2026     current_cpu->hardware.h_fr[FLD (f_dest)] = opval;
2027   }
2028
2029   current_cpu->done_insn (npc, status);
2030 #undef FLD
2031 }
2032
2033 // ********** ftrcdq: ftrc.dq $drgh, $drf
2034
2035 void
2036 sh5_media_sem_ftrcdq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2037         sh5_media::write_stacks &buf)
2038 {
2039 #define FLD(f) abuf->fields.sfmt_fabsd.f
2040   sem_status status = SEM_STATUS_NORMAL;
2041   sh5_media_scache* abuf = sem;
2042   unsigned long long written = 0;
2043   PCADDR pc = abuf->addr;
2044   PCADDR npc = pc + 4;
2045
2046   {
2047     DF opval = current_cpu->sh64_ftrcdq (current_cpu->h_dr_get (FLD (f_left_right)));
2048     if (UNLIKELY(current_cpu->trace_result_p))
2049       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2050     current_cpu->h_dr_set (FLD (f_dest), opval);
2051   }
2052
2053   current_cpu->done_insn (npc, status);
2054 #undef FLD
2055 }
2056
2057 // ********** ftrcsq: ftrc.sq $frgh, $drf
2058
2059 void
2060 sh5_media_sem_ftrcsq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2061         sh5_media::write_stacks &buf)
2062 {
2063 #define FLD(f) abuf->fields.sfmt_fcnvsd.f
2064   sem_status status = SEM_STATUS_NORMAL;
2065   sh5_media_scache* abuf = sem;
2066   unsigned long long written = 0;
2067   PCADDR pc = abuf->addr;
2068   PCADDR npc = pc + 4;
2069
2070   {
2071     DF opval = current_cpu->sh64_ftrcsq (current_cpu->hardware.h_fr[FLD (f_left_right)]);
2072     if (UNLIKELY(current_cpu->trace_result_p))
2073       current_cpu->trace_stream << "dr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2074     current_cpu->h_dr_set (FLD (f_dest), opval);
2075   }
2076
2077   current_cpu->done_insn (npc, status);
2078 #undef FLD
2079 }
2080
2081 // ********** ftrvs: ftrv.s $mtrxg, $fvh, $fvf
2082
2083 void
2084 sh5_media_sem_ftrvs (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2085         sh5_media::write_stacks &buf)
2086 {
2087 #define FLD(f) abuf->fields.sfmt_ftrvs.f
2088   sem_status status = SEM_STATUS_NORMAL;
2089   sh5_media_scache* abuf = sem;
2090   unsigned long long written = 0;
2091   PCADDR pc = abuf->addr;
2092   PCADDR npc = pc + 4;
2093
2094 {
2095   {
2096     SF opval = current_cpu->h_fmtx_get (FLD (f_left));
2097     if (UNLIKELY(current_cpu->trace_result_p))
2098       current_cpu->trace_stream << "fmtx" << '[' << FLD (f_left) << ']' << ":=0x" << hex << opval << dec << "  ";
2099     current_cpu->h_fmtx_set (FLD (f_left), opval);
2100   }
2101   {
2102     SF opval = current_cpu->h_fv_get (FLD (f_right));
2103     if (UNLIKELY(current_cpu->trace_result_p))
2104       current_cpu->trace_stream << "fv" << '[' << FLD (f_right) << ']' << ":=0x" << hex << opval << dec << "  ";
2105     current_cpu->h_fv_set (FLD (f_right), opval);
2106   }
2107   {
2108     SF opval = current_cpu->h_fv_get (FLD (f_dest));
2109     if (UNLIKELY(current_cpu->trace_result_p))
2110       current_cpu->trace_stream << "fv" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2111     current_cpu->h_fv_set (FLD (f_dest), opval);
2112   }
2113 current_cpu->sh64_ftrvs (FLD (f_left), FLD (f_right), FLD (f_dest));
2114 }
2115
2116   current_cpu->done_insn (npc, status);
2117 #undef FLD
2118 }
2119
2120 // ********** getcfg: getcfg $rm, $disp6, $rd
2121
2122 void
2123 sh5_media_sem_getcfg (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2124         sh5_media::write_stacks &buf)
2125 {
2126 #define FLD(f) abuf->fields.sfmt_getcfg.f
2127   sem_status status = SEM_STATUS_NORMAL;
2128   sh5_media_scache* abuf = sem;
2129   unsigned long long written = 0;
2130   PCADDR pc = abuf->addr;
2131   PCADDR npc = pc + 4;
2132
2133 {
2134   SI tmp_address;
2135   tmp_address = ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp6));
2136 current_cpu->sh64_save_cfg_address (tmp_address);
2137   {
2138     DI opval = current_cpu->GETMEMSI (pc, tmp_address);
2139     if (UNLIKELY(current_cpu->trace_result_p))
2140       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2141     current_cpu->h_gr_set (FLD (f_dest), opval);
2142   }
2143 }
2144
2145   current_cpu->done_insn (npc, status);
2146 #undef FLD
2147 }
2148
2149 // ********** getcon: getcon $crk, $rd
2150
2151 void
2152 sh5_media_sem_getcon (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2153         sh5_media::write_stacks &buf)
2154 {
2155 #define FLD(f) abuf->fields.sfmt_xori.f
2156   sem_status status = SEM_STATUS_NORMAL;
2157   sh5_media_scache* abuf = sem;
2158   unsigned long long written = 0;
2159   PCADDR pc = abuf->addr;
2160   PCADDR npc = pc + 4;
2161
2162   {
2163     DI opval = current_cpu->h_cr_get (FLD (f_left));
2164     if (UNLIKELY(current_cpu->trace_result_p))
2165       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2166     current_cpu->h_gr_set (FLD (f_dest), opval);
2167   }
2168
2169   current_cpu->done_insn (npc, status);
2170 #undef FLD
2171 }
2172
2173 // ********** gettr: gettr $trb, $rd
2174
2175 void
2176 sh5_media_sem_gettr (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2177         sh5_media::write_stacks &buf)
2178 {
2179 #define FLD(f) abuf->fields.sfmt_blink.f
2180   sem_status status = SEM_STATUS_NORMAL;
2181   sh5_media_scache* abuf = sem;
2182   unsigned long long written = 0;
2183   PCADDR pc = abuf->addr;
2184   PCADDR npc = pc + 4;
2185
2186   {
2187     DI opval = current_cpu->hardware.h_tr[FLD (f_trb)];
2188     if (UNLIKELY(current_cpu->trace_result_p))
2189       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2190     current_cpu->h_gr_set (FLD (f_dest), opval);
2191   }
2192
2193   current_cpu->done_insn (npc, status);
2194 #undef FLD
2195 }
2196
2197 // ********** icbi: icbi $rm, $disp6x32
2198
2199 void
2200 sh5_media_sem_icbi (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2201         sh5_media::write_stacks &buf)
2202 {
2203 #define FLD(f) abuf->fields.sfmt_alloco.f
2204   sem_status status = SEM_STATUS_NORMAL;
2205   sh5_media_scache* abuf = sem;
2206   unsigned long long written = 0;
2207   PCADDR pc = abuf->addr;
2208   PCADDR npc = pc + 4;
2209
2210 {
2211   {
2212     DI opval = current_cpu->h_gr_get (FLD (f_left));
2213     if (UNLIKELY(current_cpu->trace_result_p))
2214       current_cpu->trace_stream << "gr" << '[' << FLD (f_left) << ']' << ":=0x" << hex << opval << dec << "  ";
2215     current_cpu->h_gr_set (FLD (f_left), opval);
2216   }
2217 ((void) 0); /*nop*/
2218 }
2219
2220   current_cpu->done_insn (npc, status);
2221 #undef FLD
2222 }
2223
2224 // ********** ldb: ld.b $rm, $disp10, $rd
2225
2226 void
2227 sh5_media_sem_ldb (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2228         sh5_media::write_stacks &buf)
2229 {
2230 #define FLD(f) abuf->fields.sfmt_addi.f
2231   sem_status status = SEM_STATUS_NORMAL;
2232   sh5_media_scache* abuf = sem;
2233   unsigned long long written = 0;
2234   PCADDR pc = abuf->addr;
2235   PCADDR npc = pc + 4;
2236
2237   {
2238     DI opval = EXTQIDI (current_cpu->GETMEMQI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10)))));
2239     if (UNLIKELY(current_cpu->trace_result_p))
2240       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2241     current_cpu->h_gr_set (FLD (f_dest), opval);
2242   }
2243
2244   current_cpu->done_insn (npc, status);
2245 #undef FLD
2246 }
2247
2248 // ********** ldl: ld.l $rm, $disp10x4, $rd
2249
2250 void
2251 sh5_media_sem_ldl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2252         sh5_media::write_stacks &buf)
2253 {
2254 #define FLD(f) abuf->fields.sfmt_ldl.f
2255   sem_status status = SEM_STATUS_NORMAL;
2256   sh5_media_scache* abuf = sem;
2257   unsigned long long written = 0;
2258   PCADDR pc = abuf->addr;
2259   PCADDR npc = pc + 4;
2260
2261   {
2262     DI opval = EXTSIDI (current_cpu->GETMEMSI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10x4)))));
2263     if (UNLIKELY(current_cpu->trace_result_p))
2264       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2265     current_cpu->h_gr_set (FLD (f_dest), opval);
2266   }
2267
2268   current_cpu->done_insn (npc, status);
2269 #undef FLD
2270 }
2271
2272 // ********** ldq: ld.q $rm, $disp10x8, $rd
2273
2274 void
2275 sh5_media_sem_ldq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2276         sh5_media::write_stacks &buf)
2277 {
2278 #define FLD(f) abuf->fields.sfmt_ldq.f
2279   sem_status status = SEM_STATUS_NORMAL;
2280   sh5_media_scache* abuf = sem;
2281   unsigned long long written = 0;
2282   PCADDR pc = abuf->addr;
2283   PCADDR npc = pc + 4;
2284
2285   {
2286     DI opval = current_cpu->GETMEMDI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10x8))));
2287     if (UNLIKELY(current_cpu->trace_result_p))
2288       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2289     current_cpu->h_gr_set (FLD (f_dest), opval);
2290   }
2291
2292   current_cpu->done_insn (npc, status);
2293 #undef FLD
2294 }
2295
2296 // ********** ldub: ld.ub $rm, $disp10, $rd
2297
2298 void
2299 sh5_media_sem_ldub (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2300         sh5_media::write_stacks &buf)
2301 {
2302 #define FLD(f) abuf->fields.sfmt_addi.f
2303   sem_status status = SEM_STATUS_NORMAL;
2304   sh5_media_scache* abuf = sem;
2305   unsigned long long written = 0;
2306   PCADDR pc = abuf->addr;
2307   PCADDR npc = pc + 4;
2308
2309   {
2310     DI opval = ZEXTQIDI (current_cpu->GETMEMQI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10)))));
2311     if (UNLIKELY(current_cpu->trace_result_p))
2312       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2313     current_cpu->h_gr_set (FLD (f_dest), opval);
2314   }
2315
2316   current_cpu->done_insn (npc, status);
2317 #undef FLD
2318 }
2319
2320 // ********** lduw: ld.uw $rm, $disp10x2, $rd
2321
2322 void
2323 sh5_media_sem_lduw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2324         sh5_media::write_stacks &buf)
2325 {
2326 #define FLD(f) abuf->fields.sfmt_lduw.f
2327   sem_status status = SEM_STATUS_NORMAL;
2328   sh5_media_scache* abuf = sem;
2329   unsigned long long written = 0;
2330   PCADDR pc = abuf->addr;
2331   PCADDR npc = pc + 4;
2332
2333   {
2334     DI opval = ZEXTHIDI (current_cpu->GETMEMHI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10x2)))));
2335     if (UNLIKELY(current_cpu->trace_result_p))
2336       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2337     current_cpu->h_gr_set (FLD (f_dest), opval);
2338   }
2339
2340   current_cpu->done_insn (npc, status);
2341 #undef FLD
2342 }
2343
2344 // ********** ldw: ld.w $rm, $disp10x2, $rd
2345
2346 void
2347 sh5_media_sem_ldw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2348         sh5_media::write_stacks &buf)
2349 {
2350 #define FLD(f) abuf->fields.sfmt_lduw.f
2351   sem_status status = SEM_STATUS_NORMAL;
2352   sh5_media_scache* abuf = sem;
2353   unsigned long long written = 0;
2354   PCADDR pc = abuf->addr;
2355   PCADDR npc = pc + 4;
2356
2357   {
2358     DI opval = EXTHIDI (current_cpu->GETMEMHI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10x2)))));
2359     if (UNLIKELY(current_cpu->trace_result_p))
2360       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2361     current_cpu->h_gr_set (FLD (f_dest), opval);
2362   }
2363
2364   current_cpu->done_insn (npc, status);
2365 #undef FLD
2366 }
2367
2368 // ********** ldhil: ldhi.l $rm, $disp6, $rd
2369
2370 void
2371 sh5_media_sem_ldhil (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2372         sh5_media::write_stacks &buf)
2373 {
2374 #define FLD(f) abuf->fields.sfmt_getcfg.f
2375   sem_status status = SEM_STATUS_NORMAL;
2376   sh5_media_scache* abuf = sem;
2377   unsigned long long written = 0;
2378   PCADDR pc = abuf->addr;
2379   PCADDR npc = pc + 4;
2380
2381 {
2382   DI tmp_addr;
2383   QI tmp_bytecount;
2384   SI tmp_val;
2385   tmp_addr = ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp6));
2386   tmp_bytecount = ADDDI (ANDDI (tmp_addr, 3), 1);
2387   tmp_val = 0;
2388 if (ANDQI (tmp_bytecount, 4)) {
2389   {
2390     DI opval = EXTSIDI (current_cpu->GETMEMSI (pc, ANDDI (tmp_addr, -4)));
2391     written |= (1ULL << 6);
2392     if (UNLIKELY(current_cpu->trace_result_p))
2393       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2394     current_cpu->h_gr_set (FLD (f_dest), opval);
2395   }
2396 } else {
2397 if (current_cpu->h_endian_get ()) {
2398 {
2399 if (ANDQI (tmp_bytecount, 2)) {
2400   tmp_val = ADDSI (SLLSI (tmp_val, 16), ZEXTHIDI (current_cpu->GETMEMHI (pc, ANDDI (tmp_addr, -4))));
2401 }
2402 if (ANDQI (tmp_bytecount, 1)) {
2403   tmp_val = ADDSI (SLLSI (tmp_val, 8), ZEXTQIDI (current_cpu->GETMEMQI (pc, tmp_addr)));
2404 }
2405   {
2406     DI opval = EXTSIDI (tmp_val);
2407     written |= (1ULL << 6);
2408     if (UNLIKELY(current_cpu->trace_result_p))
2409       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2410     current_cpu->h_gr_set (FLD (f_dest), opval);
2411   }
2412 }
2413 } else {
2414 {
2415 if (ANDQI (tmp_bytecount, 1)) {
2416   tmp_val = ADDSI (SLLSI (tmp_val, 8), ZEXTQIDI (current_cpu->GETMEMQI (pc, tmp_addr)));
2417 }
2418 if (ANDQI (tmp_bytecount, 2)) {
2419   tmp_val = ADDSI (SLLSI (tmp_val, 16), ZEXTHIDI (current_cpu->GETMEMHI (pc, ANDDI (tmp_addr, -4))));
2420 }
2421   {
2422     DI opval = EXTSIDI (SLLSI (tmp_val, SUBSI (32, MULSI (8, tmp_bytecount))));
2423     written |= (1ULL << 6);
2424     if (UNLIKELY(current_cpu->trace_result_p))
2425       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2426     current_cpu->h_gr_set (FLD (f_dest), opval);
2427   }
2428 }
2429 }
2430 }
2431 }
2432
2433   abuf->written = written;
2434   current_cpu->done_insn (npc, status);
2435 #undef FLD
2436 }
2437
2438 // ********** ldhiq: ldhi.q $rm, $disp6, $rd
2439
2440 void
2441 sh5_media_sem_ldhiq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2442         sh5_media::write_stacks &buf)
2443 {
2444 #define FLD(f) abuf->fields.sfmt_getcfg.f
2445   sem_status status = SEM_STATUS_NORMAL;
2446   sh5_media_scache* abuf = sem;
2447   unsigned long long written = 0;
2448   PCADDR pc = abuf->addr;
2449   PCADDR npc = pc + 4;
2450
2451 {
2452   DI tmp_addr;
2453   QI tmp_bytecount;
2454   DI tmp_val;
2455   tmp_addr = ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp6));
2456   tmp_bytecount = ADDDI (ANDDI (tmp_addr, 7), 1);
2457   tmp_val = 0;
2458 if (ANDQI (tmp_bytecount, 8)) {
2459   {
2460     DI opval = current_cpu->GETMEMDI (pc, ANDDI (tmp_addr, -8));
2461     written |= (1ULL << 7);
2462     if (UNLIKELY(current_cpu->trace_result_p))
2463       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2464     current_cpu->h_gr_set (FLD (f_dest), opval);
2465   }
2466 } else {
2467 if (current_cpu->h_endian_get ()) {
2468 {
2469 if (ANDQI (tmp_bytecount, 4)) {
2470   tmp_val = ADDDI (SLLDI (tmp_val, 32), ZEXTSIDI (current_cpu->GETMEMSI (pc, ANDDI (tmp_addr, -8))));
2471 }
2472 if (ANDQI (tmp_bytecount, 2)) {
2473   tmp_val = ADDDI (SLLDI (tmp_val, 16), ZEXTHIDI (current_cpu->GETMEMHI (pc, ANDDI (tmp_addr, -4))));
2474 }
2475 if (ANDQI (tmp_bytecount, 1)) {
2476   tmp_val = ADDDI (SLLDI (tmp_val, 8), ZEXTQIDI (current_cpu->GETMEMQI (pc, tmp_addr)));
2477 }
2478   {
2479     DI opval = tmp_val;
2480     written |= (1ULL << 7);
2481     if (UNLIKELY(current_cpu->trace_result_p))
2482       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2483     current_cpu->h_gr_set (FLD (f_dest), opval);
2484   }
2485 }
2486 } else {
2487 {
2488 if (ANDQI (tmp_bytecount, 1)) {
2489   tmp_val = ADDDI (SLLDI (tmp_val, 8), ZEXTQIDI (current_cpu->GETMEMQI (pc, tmp_addr)));
2490 }
2491 if (ANDQI (tmp_bytecount, 2)) {
2492   tmp_val = ADDDI (SLLDI (tmp_val, 16), ZEXTHIDI (current_cpu->GETMEMHI (pc, ANDDI (tmp_addr, -4))));
2493 }
2494 if (ANDQI (tmp_bytecount, 4)) {
2495   tmp_val = ADDDI (SLLDI (tmp_val, 32), ZEXTSIDI (current_cpu->GETMEMSI (pc, ANDDI (tmp_addr, -8))));
2496 }
2497   {
2498     DI opval = SLLDI (tmp_val, SUBSI (64, MULSI (8, tmp_bytecount)));
2499     written |= (1ULL << 7);
2500     if (UNLIKELY(current_cpu->trace_result_p))
2501       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2502     current_cpu->h_gr_set (FLD (f_dest), opval);
2503   }
2504 }
2505 }
2506 }
2507 }
2508
2509   abuf->written = written;
2510   current_cpu->done_insn (npc, status);
2511 #undef FLD
2512 }
2513
2514 // ********** ldlol: ldlo.l $rm, $disp6, $rd
2515
2516 void
2517 sh5_media_sem_ldlol (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2518         sh5_media::write_stacks &buf)
2519 {
2520 #define FLD(f) abuf->fields.sfmt_getcfg.f
2521   sem_status status = SEM_STATUS_NORMAL;
2522   sh5_media_scache* abuf = sem;
2523   unsigned long long written = 0;
2524   PCADDR pc = abuf->addr;
2525   PCADDR npc = pc + 4;
2526
2527 {
2528   DI tmp_addr;
2529   QI tmp_bytecount;
2530   SI tmp_val;
2531   tmp_addr = ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp6));
2532   tmp_bytecount = SUBSI (4, ANDDI (tmp_addr, 3));
2533   tmp_val = 0;
2534 if (ANDQI (tmp_bytecount, 4)) {
2535   {
2536     DI opval = EXTSIDI (current_cpu->GETMEMSI (pc, tmp_addr));
2537     written |= (1ULL << 6);
2538     if (UNLIKELY(current_cpu->trace_result_p))
2539       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2540     current_cpu->h_gr_set (FLD (f_dest), opval);
2541   }
2542 } else {
2543 if (current_cpu->h_endian_get ()) {
2544 {
2545 if (ANDQI (tmp_bytecount, 1)) {
2546   tmp_val = ADDSI (SLLSI (tmp_val, 8), ZEXTQIDI (current_cpu->GETMEMQI (pc, tmp_addr)));
2547 }
2548 if (ANDQI (tmp_bytecount, 2)) {
2549   tmp_val = ADDSI (SLLSI (tmp_val, 16), ZEXTHIDI (current_cpu->GETMEMHI (pc, ANDDI (ADDDI (tmp_addr, 1), -2))));
2550 }
2551   {
2552     DI opval = EXTSIDI (SLLSI (tmp_val, SUBSI (32, MULSI (8, tmp_bytecount))));
2553     written |= (1ULL << 6);
2554     if (UNLIKELY(current_cpu->trace_result_p))
2555       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2556     current_cpu->h_gr_set (FLD (f_dest), opval);
2557   }
2558 }
2559 } else {
2560 {
2561 if (ANDQI (tmp_bytecount, 2)) {
2562   tmp_val = ADDSI (SLLSI (tmp_val, 16), ZEXTHIDI (current_cpu->GETMEMHI (pc, ANDDI (ADDDI (tmp_addr, 1), -2))));
2563 }
2564 if (ANDQI (tmp_bytecount, 1)) {
2565   tmp_val = ADDSI (SLLSI (tmp_val, 8), ZEXTQIDI (current_cpu->GETMEMQI (pc, tmp_addr)));
2566 }
2567   {
2568     DI opval = EXTSIDI (tmp_val);
2569     written |= (1ULL << 6);
2570     if (UNLIKELY(current_cpu->trace_result_p))
2571       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2572     current_cpu->h_gr_set (FLD (f_dest), opval);
2573   }
2574 }
2575 }
2576 }
2577 }
2578
2579   abuf->written = written;
2580   current_cpu->done_insn (npc, status);
2581 #undef FLD
2582 }
2583
2584 // ********** ldloq: ldlo.q $rm, $disp6, $rd
2585
2586 void
2587 sh5_media_sem_ldloq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2588         sh5_media::write_stacks &buf)
2589 {
2590 #define FLD(f) abuf->fields.sfmt_getcfg.f
2591   sem_status status = SEM_STATUS_NORMAL;
2592   sh5_media_scache* abuf = sem;
2593   unsigned long long written = 0;
2594   PCADDR pc = abuf->addr;
2595   PCADDR npc = pc + 4;
2596
2597 {
2598   DI tmp_addr;
2599   QI tmp_bytecount;
2600   DI tmp_val;
2601   tmp_addr = ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp6));
2602   tmp_bytecount = SUBSI (8, ANDDI (tmp_addr, 7));
2603   tmp_val = 0;
2604 if (ANDQI (tmp_bytecount, 8)) {
2605   {
2606     DI opval = current_cpu->GETMEMDI (pc, tmp_addr);
2607     written |= (1ULL << 7);
2608     if (UNLIKELY(current_cpu->trace_result_p))
2609       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2610     current_cpu->h_gr_set (FLD (f_dest), opval);
2611   }
2612 } else {
2613 if (current_cpu->h_endian_get ()) {
2614 {
2615 if (ANDQI (tmp_bytecount, 1)) {
2616   tmp_val = ADDDI (SLLDI (tmp_val, 8), ZEXTQIDI (current_cpu->GETMEMQI (pc, tmp_addr)));
2617 }
2618 if (ANDQI (tmp_bytecount, 2)) {
2619   tmp_val = ADDDI (SLLDI (tmp_val, 16), ZEXTHIDI (current_cpu->GETMEMHI (pc, ANDDI (ADDDI (tmp_addr, 1), -2))));
2620 }
2621 if (ANDQI (tmp_bytecount, 4)) {
2622   tmp_val = ADDDI (SLLDI (tmp_val, 32), ZEXTSIDI (current_cpu->GETMEMSI (pc, ANDDI (ADDDI (tmp_addr, 3), -4))));
2623 }
2624   {
2625     DI opval = SLLDI (tmp_val, SUBSI (64, MULSI (8, tmp_bytecount)));
2626     written |= (1ULL << 7);
2627     if (UNLIKELY(current_cpu->trace_result_p))
2628       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2629     current_cpu->h_gr_set (FLD (f_dest), opval);
2630   }
2631 }
2632 } else {
2633 {
2634 if (ANDQI (tmp_bytecount, 4)) {
2635   tmp_val = ADDDI (SLLDI (tmp_val, 32), ZEXTSIDI (current_cpu->GETMEMSI (pc, ANDDI (ADDDI (tmp_addr, 3), -4))));
2636 }
2637 if (ANDQI (tmp_bytecount, 2)) {
2638   tmp_val = ADDDI (SLLDI (tmp_val, 16), ZEXTHIDI (current_cpu->GETMEMHI (pc, ANDDI (ADDDI (tmp_addr, 1), -2))));
2639 }
2640 if (ANDQI (tmp_bytecount, 1)) {
2641   tmp_val = ADDDI (SLLDI (tmp_val, 8), ZEXTQIDI (current_cpu->GETMEMQI (pc, tmp_addr)));
2642 }
2643   {
2644     DI opval = tmp_val;
2645     written |= (1ULL << 7);
2646     if (UNLIKELY(current_cpu->trace_result_p))
2647       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2648     current_cpu->h_gr_set (FLD (f_dest), opval);
2649   }
2650 }
2651 }
2652 }
2653 }
2654
2655   abuf->written = written;
2656   current_cpu->done_insn (npc, status);
2657 #undef FLD
2658 }
2659
2660 // ********** ldxb: ldx.b $rm, $rn, $rd
2661
2662 void
2663 sh5_media_sem_ldxb (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2664         sh5_media::write_stacks &buf)
2665 {
2666 #define FLD(f) abuf->fields.sfmt_mcmv.f
2667   sem_status status = SEM_STATUS_NORMAL;
2668   sh5_media_scache* abuf = sem;
2669   unsigned long long written = 0;
2670   PCADDR pc = abuf->addr;
2671   PCADDR npc = pc + 4;
2672
2673   {
2674     DI opval = EXTQIDI (current_cpu->GETMEMQI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))));
2675     if (UNLIKELY(current_cpu->trace_result_p))
2676       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2677     current_cpu->h_gr_set (FLD (f_dest), opval);
2678   }
2679
2680   current_cpu->done_insn (npc, status);
2681 #undef FLD
2682 }
2683
2684 // ********** ldxl: ldx.l $rm, $rn, $rd
2685
2686 void
2687 sh5_media_sem_ldxl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2688         sh5_media::write_stacks &buf)
2689 {
2690 #define FLD(f) abuf->fields.sfmt_mcmv.f
2691   sem_status status = SEM_STATUS_NORMAL;
2692   sh5_media_scache* abuf = sem;
2693   unsigned long long written = 0;
2694   PCADDR pc = abuf->addr;
2695   PCADDR npc = pc + 4;
2696
2697   {
2698     DI opval = EXTSIDI (current_cpu->GETMEMSI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))));
2699     if (UNLIKELY(current_cpu->trace_result_p))
2700       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2701     current_cpu->h_gr_set (FLD (f_dest), opval);
2702   }
2703
2704   current_cpu->done_insn (npc, status);
2705 #undef FLD
2706 }
2707
2708 // ********** ldxq: ldx.q $rm, $rn, $rd
2709
2710 void
2711 sh5_media_sem_ldxq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2712         sh5_media::write_stacks &buf)
2713 {
2714 #define FLD(f) abuf->fields.sfmt_mcmv.f
2715   sem_status status = SEM_STATUS_NORMAL;
2716   sh5_media_scache* abuf = sem;
2717   unsigned long long written = 0;
2718   PCADDR pc = abuf->addr;
2719   PCADDR npc = pc + 4;
2720
2721   {
2722     DI opval = current_cpu->GETMEMDI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))));
2723     if (UNLIKELY(current_cpu->trace_result_p))
2724       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2725     current_cpu->h_gr_set (FLD (f_dest), opval);
2726   }
2727
2728   current_cpu->done_insn (npc, status);
2729 #undef FLD
2730 }
2731
2732 // ********** ldxub: ldx.ub $rm, $rn, $rd
2733
2734 void
2735 sh5_media_sem_ldxub (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2736         sh5_media::write_stacks &buf)
2737 {
2738 #define FLD(f) abuf->fields.sfmt_mcmv.f
2739   sem_status status = SEM_STATUS_NORMAL;
2740   sh5_media_scache* abuf = sem;
2741   unsigned long long written = 0;
2742   PCADDR pc = abuf->addr;
2743   PCADDR npc = pc + 4;
2744
2745   {
2746     DI opval = ZEXTQIDI (current_cpu->GETMEMUQI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))));
2747     if (UNLIKELY(current_cpu->trace_result_p))
2748       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2749     current_cpu->h_gr_set (FLD (f_dest), opval);
2750   }
2751
2752   current_cpu->done_insn (npc, status);
2753 #undef FLD
2754 }
2755
2756 // ********** ldxuw: ldx.uw $rm, $rn, $rd
2757
2758 void
2759 sh5_media_sem_ldxuw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2760         sh5_media::write_stacks &buf)
2761 {
2762 #define FLD(f) abuf->fields.sfmt_mcmv.f
2763   sem_status status = SEM_STATUS_NORMAL;
2764   sh5_media_scache* abuf = sem;
2765   unsigned long long written = 0;
2766   PCADDR pc = abuf->addr;
2767   PCADDR npc = pc + 4;
2768
2769   {
2770     DI opval = ZEXTHIDI (current_cpu->GETMEMUHI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))));
2771     if (UNLIKELY(current_cpu->trace_result_p))
2772       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2773     current_cpu->h_gr_set (FLD (f_dest), opval);
2774   }
2775
2776   current_cpu->done_insn (npc, status);
2777 #undef FLD
2778 }
2779
2780 // ********** ldxw: ldx.w $rm, $rn, $rd
2781
2782 void
2783 sh5_media_sem_ldxw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2784         sh5_media::write_stacks &buf)
2785 {
2786 #define FLD(f) abuf->fields.sfmt_mcmv.f
2787   sem_status status = SEM_STATUS_NORMAL;
2788   sh5_media_scache* abuf = sem;
2789   unsigned long long written = 0;
2790   PCADDR pc = abuf->addr;
2791   PCADDR npc = pc + 4;
2792
2793   {
2794     DI opval = EXTHIDI (current_cpu->GETMEMHI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)))));
2795     if (UNLIKELY(current_cpu->trace_result_p))
2796       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2797     current_cpu->h_gr_set (FLD (f_dest), opval);
2798   }
2799
2800   current_cpu->done_insn (npc, status);
2801 #undef FLD
2802 }
2803
2804 // ********** mabsl: mabs.l $rm, $rd
2805
2806 void
2807 sh5_media_sem_mabsl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2808         sh5_media::write_stacks &buf)
2809 {
2810 #define FLD(f) abuf->fields.sfmt_xori.f
2811   sem_status status = SEM_STATUS_NORMAL;
2812   sh5_media_scache* abuf = sem;
2813   unsigned long long written = 0;
2814   PCADDR pc = abuf->addr;
2815   PCADDR npc = pc + 4;
2816
2817 {
2818   SI tmp_result1;
2819   SI tmp_result0;
2820   tmp_result0 = ABSSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1));
2821   tmp_result1 = ABSSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0));
2822   {
2823     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
2824     if (UNLIKELY(current_cpu->trace_result_p))
2825       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2826     current_cpu->h_gr_set (FLD (f_dest), opval);
2827   }
2828 }
2829
2830   current_cpu->done_insn (npc, status);
2831 #undef FLD
2832 }
2833
2834 // ********** mabsw: mabs.w $rm, $rd
2835
2836 void
2837 sh5_media_sem_mabsw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2838         sh5_media::write_stacks &buf)
2839 {
2840 #define FLD(f) abuf->fields.sfmt_xori.f
2841   sem_status status = SEM_STATUS_NORMAL;
2842   sh5_media_scache* abuf = sem;
2843   unsigned long long written = 0;
2844   PCADDR pc = abuf->addr;
2845   PCADDR npc = pc + 4;
2846
2847 {
2848   HI tmp_result3;
2849   HI tmp_result2;
2850   HI tmp_result1;
2851   HI tmp_result0;
2852   tmp_result0 = ABSHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3));
2853   tmp_result1 = ABSHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2));
2854   tmp_result2 = ABSHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1));
2855   tmp_result3 = ABSHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0));
2856   {
2857     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
2858     if (UNLIKELY(current_cpu->trace_result_p))
2859       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2860     current_cpu->h_gr_set (FLD (f_dest), opval);
2861   }
2862 }
2863
2864   current_cpu->done_insn (npc, status);
2865 #undef FLD
2866 }
2867
2868 // ********** maddl: madd.l $rm, $rn, $rd
2869
2870 void
2871 sh5_media_sem_maddl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2872         sh5_media::write_stacks &buf)
2873 {
2874 #define FLD(f) abuf->fields.sfmt_mcmv.f
2875   sem_status status = SEM_STATUS_NORMAL;
2876   sh5_media_scache* abuf = sem;
2877   unsigned long long written = 0;
2878   PCADDR pc = abuf->addr;
2879   PCADDR npc = pc + 4;
2880
2881 {
2882   SI tmp_result1;
2883   SI tmp_result0;
2884   tmp_result0 = ADDSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1));
2885   tmp_result1 = ADDSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0));
2886   {
2887     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
2888     if (UNLIKELY(current_cpu->trace_result_p))
2889       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2890     current_cpu->h_gr_set (FLD (f_dest), opval);
2891   }
2892 }
2893
2894   current_cpu->done_insn (npc, status);
2895 #undef FLD
2896 }
2897
2898 // ********** maddw: madd.w $rm, $rn, $rd
2899
2900 void
2901 sh5_media_sem_maddw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2902         sh5_media::write_stacks &buf)
2903 {
2904 #define FLD(f) abuf->fields.sfmt_mcmv.f
2905   sem_status status = SEM_STATUS_NORMAL;
2906   sh5_media_scache* abuf = sem;
2907   unsigned long long written = 0;
2908   PCADDR pc = abuf->addr;
2909   PCADDR npc = pc + 4;
2910
2911 {
2912   HI tmp_result3;
2913   HI tmp_result2;
2914   HI tmp_result1;
2915   HI tmp_result0;
2916   tmp_result0 = ADDHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3));
2917   tmp_result1 = ADDHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2));
2918   tmp_result2 = ADDHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1));
2919   tmp_result3 = ADDHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0));
2920   {
2921     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
2922     if (UNLIKELY(current_cpu->trace_result_p))
2923       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2924     current_cpu->h_gr_set (FLD (f_dest), opval);
2925   }
2926 }
2927
2928   current_cpu->done_insn (npc, status);
2929 #undef FLD
2930 }
2931
2932 // ********** maddsl: madds.l $rm, $rn, $rd
2933
2934 void
2935 sh5_media_sem_maddsl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2936         sh5_media::write_stacks &buf)
2937 {
2938 #define FLD(f) abuf->fields.sfmt_mcmv.f
2939   sem_status status = SEM_STATUS_NORMAL;
2940   sh5_media_scache* abuf = sem;
2941   unsigned long long written = 0;
2942   PCADDR pc = abuf->addr;
2943   PCADDR npc = pc + 4;
2944
2945 {
2946   SI tmp_result1;
2947   SI tmp_result0;
2948   tmp_result0 = ((LTDI (ADDDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1))), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (ADDDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1))), SLLDI (1, SUBSI (32, 1)))) ? (ADDDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1)))) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
2949   tmp_result1 = ((LTDI (ADDDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0))), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (ADDDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0))), SLLDI (1, SUBSI (32, 1)))) ? (ADDDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0)))) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
2950   {
2951     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
2952     if (UNLIKELY(current_cpu->trace_result_p))
2953       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2954     current_cpu->h_gr_set (FLD (f_dest), opval);
2955   }
2956 }
2957
2958   current_cpu->done_insn (npc, status);
2959 #undef FLD
2960 }
2961
2962 // ********** maddsub: madds.ub $rm, $rn, $rd
2963
2964 void
2965 sh5_media_sem_maddsub (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
2966         sh5_media::write_stacks &buf)
2967 {
2968 #define FLD(f) abuf->fields.sfmt_mcmv.f
2969   sem_status status = SEM_STATUS_NORMAL;
2970   sh5_media_scache* abuf = sem;
2971   unsigned long long written = 0;
2972   PCADDR pc = abuf->addr;
2973   PCADDR npc = pc + 4;
2974
2975 {
2976   QI tmp_result7;
2977   QI tmp_result6;
2978   QI tmp_result5;
2979   QI tmp_result4;
2980   QI tmp_result3;
2981   QI tmp_result2;
2982   QI tmp_result1;
2983   QI tmp_result0;
2984   tmp_result0 = ((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7))), MAKEDI (0, 0))) ? (0) : (((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7))), SLLDI (1, 8))) ? (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7)))) : (SUBQI (SLLQI (1, 8), 1)))));
2985   tmp_result1 = ((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6))), MAKEDI (0, 0))) ? (0) : (((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6))), SLLDI (1, 8))) ? (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6)))) : (SUBQI (SLLQI (1, 8), 1)))));
2986   tmp_result2 = ((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5))), MAKEDI (0, 0))) ? (0) : (((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5))), SLLDI (1, 8))) ? (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5)))) : (SUBQI (SLLQI (1, 8), 1)))));
2987   tmp_result3 = ((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4))), MAKEDI (0, 0))) ? (0) : (((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4))), SLLDI (1, 8))) ? (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4)))) : (SUBQI (SLLQI (1, 8), 1)))));
2988   tmp_result4 = ((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3))), MAKEDI (0, 0))) ? (0) : (((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3))), SLLDI (1, 8))) ? (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3)))) : (SUBQI (SLLQI (1, 8), 1)))));
2989   tmp_result5 = ((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2))), MAKEDI (0, 0))) ? (0) : (((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2))), SLLDI (1, 8))) ? (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2)))) : (SUBQI (SLLQI (1, 8), 1)))));
2990   tmp_result6 = ((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1))), MAKEDI (0, 0))) ? (0) : (((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1))), SLLDI (1, 8))) ? (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1)))) : (SUBQI (SLLQI (1, 8), 1)))));
2991   tmp_result7 = ((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0))), MAKEDI (0, 0))) ? (0) : (((LTDI (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0))), SLLDI (1, 8))) ? (ADDDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0)))) : (SUBQI (SLLQI (1, 8), 1)))));
2992   {
2993     DI opval = ORDI (SLLDI (ZEXTQIDI (tmp_result7), 56), ORDI (SLLDI (ZEXTQIDI (tmp_result6), 48), ORDI (SLLDI (ZEXTQIDI (tmp_result5), 40), ORDI (SLLDI (ZEXTQIDI (tmp_result4), 32), ORDI (SLLDI (ZEXTQIDI (tmp_result3), 24), ORDI (SLLDI (ZEXTQIDI (tmp_result2), 16), ORDI (SLLDI (ZEXTQIDI (tmp_result1), 8), ZEXTQIDI (tmp_result0))))))));
2994     if (UNLIKELY(current_cpu->trace_result_p))
2995       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
2996     current_cpu->h_gr_set (FLD (f_dest), opval);
2997   }
2998 }
2999
3000   current_cpu->done_insn (npc, status);
3001 #undef FLD
3002 }
3003
3004 // ********** maddsw: madds.w $rm, $rn, $rd
3005
3006 void
3007 sh5_media_sem_maddsw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3008         sh5_media::write_stacks &buf)
3009 {
3010 #define FLD(f) abuf->fields.sfmt_mcmv.f
3011   sem_status status = SEM_STATUS_NORMAL;
3012   sh5_media_scache* abuf = sem;
3013   unsigned long long written = 0;
3014   PCADDR pc = abuf->addr;
3015   PCADDR npc = pc + 4;
3016
3017 {
3018   HI tmp_result3;
3019   HI tmp_result2;
3020   HI tmp_result1;
3021   HI tmp_result0;
3022   tmp_result0 = ((LTDI (ADDDI (EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3)), EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3))), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (ADDDI (EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3)), EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3))), SLLDI (1, SUBSI (16, 1)))) ? (ADDDI (EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3)), EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3)))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3023   tmp_result1 = ((LTDI (ADDDI (EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2)), EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2))), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (ADDDI (EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2)), EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2))), SLLDI (1, SUBSI (16, 1)))) ? (ADDDI (EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2)), EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2)))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3024   tmp_result2 = ((LTDI (ADDDI (EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1))), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (ADDDI (EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1))), SLLDI (1, SUBSI (16, 1)))) ? (ADDDI (EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1)))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3025   tmp_result3 = ((LTDI (ADDDI (EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0)), EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0))), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (ADDDI (EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0)), EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0))), SLLDI (1, SUBSI (16, 1)))) ? (ADDDI (EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0)), EXTHIDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0)))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3026   {
3027     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
3028     if (UNLIKELY(current_cpu->trace_result_p))
3029       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3030     current_cpu->h_gr_set (FLD (f_dest), opval);
3031   }
3032 }
3033
3034   current_cpu->done_insn (npc, status);
3035 #undef FLD
3036 }
3037
3038 // ********** mcmpeqb: mcmpeq.b $rm, $rn, $rd
3039
3040 void
3041 sh5_media_sem_mcmpeqb (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3042         sh5_media::write_stacks &buf)
3043 {
3044 #define FLD(f) abuf->fields.sfmt_mcmv.f
3045   sem_status status = SEM_STATUS_NORMAL;
3046   sh5_media_scache* abuf = sem;
3047   unsigned long long written = 0;
3048   PCADDR pc = abuf->addr;
3049   PCADDR npc = pc + 4;
3050
3051 {
3052   QI tmp_result7;
3053   QI tmp_result6;
3054   QI tmp_result5;
3055   QI tmp_result4;
3056   QI tmp_result3;
3057   QI tmp_result2;
3058   QI tmp_result1;
3059   QI tmp_result0;
3060   tmp_result0 = ((EQQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7))) ? (INVQI (0)) : (0));
3061   tmp_result1 = ((EQQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6))) ? (INVQI (0)) : (0));
3062   tmp_result2 = ((EQQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5))) ? (INVQI (0)) : (0));
3063   tmp_result3 = ((EQQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4))) ? (INVQI (0)) : (0));
3064   tmp_result4 = ((EQQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3))) ? (INVQI (0)) : (0));
3065   tmp_result5 = ((EQQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2))) ? (INVQI (0)) : (0));
3066   tmp_result6 = ((EQQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1))) ? (INVQI (0)) : (0));
3067   tmp_result7 = ((EQQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0))) ? (INVQI (0)) : (0));
3068   {
3069     DI opval = ORDI (SLLDI (ZEXTQIDI (tmp_result7), 56), ORDI (SLLDI (ZEXTQIDI (tmp_result6), 48), ORDI (SLLDI (ZEXTQIDI (tmp_result5), 40), ORDI (SLLDI (ZEXTQIDI (tmp_result4), 32), ORDI (SLLDI (ZEXTQIDI (tmp_result3), 24), ORDI (SLLDI (ZEXTQIDI (tmp_result2), 16), ORDI (SLLDI (ZEXTQIDI (tmp_result1), 8), ZEXTQIDI (tmp_result0))))))));
3070     if (UNLIKELY(current_cpu->trace_result_p))
3071       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3072     current_cpu->h_gr_set (FLD (f_dest), opval);
3073   }
3074 }
3075
3076   current_cpu->done_insn (npc, status);
3077 #undef FLD
3078 }
3079
3080 // ********** mcmpeql: mcmpeq.l $rm, $rn, $rd
3081
3082 void
3083 sh5_media_sem_mcmpeql (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3084         sh5_media::write_stacks &buf)
3085 {
3086 #define FLD(f) abuf->fields.sfmt_mcmv.f
3087   sem_status status = SEM_STATUS_NORMAL;
3088   sh5_media_scache* abuf = sem;
3089   unsigned long long written = 0;
3090   PCADDR pc = abuf->addr;
3091   PCADDR npc = pc + 4;
3092
3093 {
3094   SI tmp_result1;
3095   SI tmp_result0;
3096   tmp_result0 = ((EQSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1))) ? (INVSI (0)) : (0));
3097   tmp_result1 = ((EQSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0))) ? (INVSI (0)) : (0));
3098   {
3099     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
3100     if (UNLIKELY(current_cpu->trace_result_p))
3101       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3102     current_cpu->h_gr_set (FLD (f_dest), opval);
3103   }
3104 }
3105
3106   current_cpu->done_insn (npc, status);
3107 #undef FLD
3108 }
3109
3110 // ********** mcmpeqw: mcmpeq.w $rm, $rn, $rd
3111
3112 void
3113 sh5_media_sem_mcmpeqw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3114         sh5_media::write_stacks &buf)
3115 {
3116 #define FLD(f) abuf->fields.sfmt_mcmv.f
3117   sem_status status = SEM_STATUS_NORMAL;
3118   sh5_media_scache* abuf = sem;
3119   unsigned long long written = 0;
3120   PCADDR pc = abuf->addr;
3121   PCADDR npc = pc + 4;
3122
3123 {
3124   HI tmp_result3;
3125   HI tmp_result2;
3126   HI tmp_result1;
3127   HI tmp_result0;
3128   tmp_result0 = ((EQHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3))) ? (INVHI (0)) : (0));
3129   tmp_result1 = ((EQHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2))) ? (INVHI (0)) : (0));
3130   tmp_result2 = ((EQHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1))) ? (INVHI (0)) : (0));
3131   tmp_result3 = ((EQHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0))) ? (INVHI (0)) : (0));
3132   {
3133     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
3134     if (UNLIKELY(current_cpu->trace_result_p))
3135       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3136     current_cpu->h_gr_set (FLD (f_dest), opval);
3137   }
3138 }
3139
3140   current_cpu->done_insn (npc, status);
3141 #undef FLD
3142 }
3143
3144 // ********** mcmpgtl: mcmpgt.l $rm, $rn, $rd
3145
3146 void
3147 sh5_media_sem_mcmpgtl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3148         sh5_media::write_stacks &buf)
3149 {
3150 #define FLD(f) abuf->fields.sfmt_mcmv.f
3151   sem_status status = SEM_STATUS_NORMAL;
3152   sh5_media_scache* abuf = sem;
3153   unsigned long long written = 0;
3154   PCADDR pc = abuf->addr;
3155   PCADDR npc = pc + 4;
3156
3157 {
3158   SI tmp_result1;
3159   SI tmp_result0;
3160   tmp_result0 = ((GTSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1))) ? (INVSI (0)) : (0));
3161   tmp_result1 = ((GTSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0))) ? (INVSI (0)) : (0));
3162   {
3163     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
3164     if (UNLIKELY(current_cpu->trace_result_p))
3165       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3166     current_cpu->h_gr_set (FLD (f_dest), opval);
3167   }
3168 }
3169
3170   current_cpu->done_insn (npc, status);
3171 #undef FLD
3172 }
3173
3174 // ********** mcmpgtub: mcmpgt.ub $rm, $rn, $rd
3175
3176 void
3177 sh5_media_sem_mcmpgtub (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3178         sh5_media::write_stacks &buf)
3179 {
3180 #define FLD(f) abuf->fields.sfmt_mcmv.f
3181   sem_status status = SEM_STATUS_NORMAL;
3182   sh5_media_scache* abuf = sem;
3183   unsigned long long written = 0;
3184   PCADDR pc = abuf->addr;
3185   PCADDR npc = pc + 4;
3186
3187 {
3188   QI tmp_result7;
3189   QI tmp_result6;
3190   QI tmp_result5;
3191   QI tmp_result4;
3192   QI tmp_result3;
3193   QI tmp_result2;
3194   QI tmp_result1;
3195   QI tmp_result0;
3196   tmp_result0 = ((GTUQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7))) ? (INVQI (0)) : (0));
3197   tmp_result1 = ((GTUQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6))) ? (INVQI (0)) : (0));
3198   tmp_result2 = ((GTUQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5))) ? (INVQI (0)) : (0));
3199   tmp_result3 = ((GTUQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4))) ? (INVQI (0)) : (0));
3200   tmp_result4 = ((GTUQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3))) ? (INVQI (0)) : (0));
3201   tmp_result5 = ((GTUQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2))) ? (INVQI (0)) : (0));
3202   tmp_result6 = ((GTUQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1))) ? (INVQI (0)) : (0));
3203   tmp_result7 = ((GTUQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0))) ? (INVQI (0)) : (0));
3204   {
3205     DI opval = ORDI (SLLDI (ZEXTQIDI (tmp_result7), 56), ORDI (SLLDI (ZEXTQIDI (tmp_result6), 48), ORDI (SLLDI (ZEXTQIDI (tmp_result5), 40), ORDI (SLLDI (ZEXTQIDI (tmp_result4), 32), ORDI (SLLDI (ZEXTQIDI (tmp_result3), 24), ORDI (SLLDI (ZEXTQIDI (tmp_result2), 16), ORDI (SLLDI (ZEXTQIDI (tmp_result1), 8), ZEXTQIDI (tmp_result0))))))));
3206     if (UNLIKELY(current_cpu->trace_result_p))
3207       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3208     current_cpu->h_gr_set (FLD (f_dest), opval);
3209   }
3210 }
3211
3212   current_cpu->done_insn (npc, status);
3213 #undef FLD
3214 }
3215
3216 // ********** mcmpgtw: mcmpgt.w $rm, $rn, $rd
3217
3218 void
3219 sh5_media_sem_mcmpgtw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3220         sh5_media::write_stacks &buf)
3221 {
3222 #define FLD(f) abuf->fields.sfmt_mcmv.f
3223   sem_status status = SEM_STATUS_NORMAL;
3224   sh5_media_scache* abuf = sem;
3225   unsigned long long written = 0;
3226   PCADDR pc = abuf->addr;
3227   PCADDR npc = pc + 4;
3228
3229 {
3230   HI tmp_result3;
3231   HI tmp_result2;
3232   HI tmp_result1;
3233   HI tmp_result0;
3234   tmp_result0 = ((GTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3))) ? (INVHI (0)) : (0));
3235   tmp_result1 = ((GTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2))) ? (INVHI (0)) : (0));
3236   tmp_result2 = ((GTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1))) ? (INVHI (0)) : (0));
3237   tmp_result3 = ((GTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0))) ? (INVHI (0)) : (0));
3238   {
3239     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
3240     if (UNLIKELY(current_cpu->trace_result_p))
3241       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3242     current_cpu->h_gr_set (FLD (f_dest), opval);
3243   }
3244 }
3245
3246   current_cpu->done_insn (npc, status);
3247 #undef FLD
3248 }
3249
3250 // ********** mcmv: mcmv $rm, $rn, $rd
3251
3252 void
3253 sh5_media_sem_mcmv (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3254         sh5_media::write_stacks &buf)
3255 {
3256 #define FLD(f) abuf->fields.sfmt_mcmv.f
3257   sem_status status = SEM_STATUS_NORMAL;
3258   sh5_media_scache* abuf = sem;
3259   unsigned long long written = 0;
3260   PCADDR pc = abuf->addr;
3261   PCADDR npc = pc + 4;
3262
3263   {
3264     DI opval = ORDI (ANDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))), ANDDI (current_cpu->h_gr_get (FLD (f_dest)), INVDI (current_cpu->h_gr_get (FLD (f_right)))));
3265     if (UNLIKELY(current_cpu->trace_result_p))
3266       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3267     current_cpu->h_gr_set (FLD (f_dest), opval);
3268   }
3269
3270   current_cpu->done_insn (npc, status);
3271 #undef FLD
3272 }
3273
3274 // ********** mcnvslw: mcnvs.lw $rm, $rn, $rd
3275
3276 void
3277 sh5_media_sem_mcnvslw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3278         sh5_media::write_stacks &buf)
3279 {
3280 #define FLD(f) abuf->fields.sfmt_mcmv.f
3281   sem_status status = SEM_STATUS_NORMAL;
3282   sh5_media_scache* abuf = sem;
3283   unsigned long long written = 0;
3284   PCADDR pc = abuf->addr;
3285   PCADDR npc = pc + 4;
3286
3287 {
3288   HI tmp_result3;
3289   HI tmp_result2;
3290   HI tmp_result1;
3291   HI tmp_result0;
3292   tmp_result0 = ((LTSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), SLLDI (1, SUBSI (16, 1)))) ? (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1)) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3293   tmp_result1 = ((LTSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), SLLDI (1, SUBSI (16, 1)))) ? (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0)) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3294   tmp_result2 = ((LTSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1), SLLDI (1, SUBSI (16, 1)))) ? (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1)) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3295   tmp_result3 = ((LTSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0), SLLDI (1, SUBSI (16, 1)))) ? (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0)) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3296   {
3297     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
3298     if (UNLIKELY(current_cpu->trace_result_p))
3299       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3300     current_cpu->h_gr_set (FLD (f_dest), opval);
3301   }
3302 }
3303
3304   current_cpu->done_insn (npc, status);
3305 #undef FLD
3306 }
3307
3308 // ********** mcnvswb: mcnvs.wb $rm, $rn, $rd
3309
3310 void
3311 sh5_media_sem_mcnvswb (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3312         sh5_media::write_stacks &buf)
3313 {
3314 #define FLD(f) abuf->fields.sfmt_mcmv.f
3315   sem_status status = SEM_STATUS_NORMAL;
3316   sh5_media_scache* abuf = sem;
3317   unsigned long long written = 0;
3318   PCADDR pc = abuf->addr;
3319   PCADDR npc = pc + 4;
3320
3321 {
3322   QI tmp_result7;
3323   QI tmp_result6;
3324   QI tmp_result5;
3325   QI tmp_result4;
3326   QI tmp_result3;
3327   QI tmp_result2;
3328   QI tmp_result1;
3329   QI tmp_result0;
3330   tmp_result0 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), NEGDI (SLLDI (1, SUBSI (8, 1))))) ? (NEGQI (SLLQI (1, SUBSI (8, 1)))) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), SLLDI (1, SUBSI (8, 1)))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3)) : (SUBQI (SLLQI (1, SUBSI (8, 1)), 1)))));
3331   tmp_result1 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), NEGDI (SLLDI (1, SUBSI (8, 1))))) ? (NEGQI (SLLQI (1, SUBSI (8, 1)))) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), SLLDI (1, SUBSI (8, 1)))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2)) : (SUBQI (SLLQI (1, SUBSI (8, 1)), 1)))));
3332   tmp_result2 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), NEGDI (SLLDI (1, SUBSI (8, 1))))) ? (NEGQI (SLLQI (1, SUBSI (8, 1)))) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), SLLDI (1, SUBSI (8, 1)))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1)) : (SUBQI (SLLQI (1, SUBSI (8, 1)), 1)))));
3333   tmp_result3 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), NEGDI (SLLDI (1, SUBSI (8, 1))))) ? (NEGQI (SLLQI (1, SUBSI (8, 1)))) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), SLLDI (1, SUBSI (8, 1)))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0)) : (SUBQI (SLLQI (1, SUBSI (8, 1)), 1)))));
3334   tmp_result4 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3), NEGDI (SLLDI (1, SUBSI (8, 1))))) ? (NEGQI (SLLQI (1, SUBSI (8, 1)))) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3), SLLDI (1, SUBSI (8, 1)))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3)) : (SUBQI (SLLQI (1, SUBSI (8, 1)), 1)))));
3335   tmp_result5 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2), NEGDI (SLLDI (1, SUBSI (8, 1))))) ? (NEGQI (SLLQI (1, SUBSI (8, 1)))) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2), SLLDI (1, SUBSI (8, 1)))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2)) : (SUBQI (SLLQI (1, SUBSI (8, 1)), 1)))));
3336   tmp_result6 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1), NEGDI (SLLDI (1, SUBSI (8, 1))))) ? (NEGQI (SLLQI (1, SUBSI (8, 1)))) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1), SLLDI (1, SUBSI (8, 1)))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1)) : (SUBQI (SLLQI (1, SUBSI (8, 1)), 1)))));
3337   tmp_result7 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0), NEGDI (SLLDI (1, SUBSI (8, 1))))) ? (NEGQI (SLLQI (1, SUBSI (8, 1)))) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0), SLLDI (1, SUBSI (8, 1)))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0)) : (SUBQI (SLLQI (1, SUBSI (8, 1)), 1)))));
3338   {
3339     DI opval = ORDI (SLLDI (ZEXTQIDI (tmp_result7), 56), ORDI (SLLDI (ZEXTQIDI (tmp_result6), 48), ORDI (SLLDI (ZEXTQIDI (tmp_result5), 40), ORDI (SLLDI (ZEXTQIDI (tmp_result4), 32), ORDI (SLLDI (ZEXTQIDI (tmp_result3), 24), ORDI (SLLDI (ZEXTQIDI (tmp_result2), 16), ORDI (SLLDI (ZEXTQIDI (tmp_result1), 8), ZEXTQIDI (tmp_result0))))))));
3340     if (UNLIKELY(current_cpu->trace_result_p))
3341       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3342     current_cpu->h_gr_set (FLD (f_dest), opval);
3343   }
3344 }
3345
3346   current_cpu->done_insn (npc, status);
3347 #undef FLD
3348 }
3349
3350 // ********** mcnvswub: mcnvs.wub $rm, $rn, $rd
3351
3352 void
3353 sh5_media_sem_mcnvswub (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3354         sh5_media::write_stacks &buf)
3355 {
3356 #define FLD(f) abuf->fields.sfmt_mcmv.f
3357   sem_status status = SEM_STATUS_NORMAL;
3358   sh5_media_scache* abuf = sem;
3359   unsigned long long written = 0;
3360   PCADDR pc = abuf->addr;
3361   PCADDR npc = pc + 4;
3362
3363 {
3364   QI tmp_result7;
3365   QI tmp_result6;
3366   QI tmp_result5;
3367   QI tmp_result4;
3368   QI tmp_result3;
3369   QI tmp_result2;
3370   QI tmp_result1;
3371   QI tmp_result0;
3372   tmp_result0 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), MAKEDI (0, 0))) ? (0) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), SLLDI (1, 8))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3)) : (SUBQI (SLLQI (1, 8), 1)))));
3373   tmp_result1 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), MAKEDI (0, 0))) ? (0) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), SLLDI (1, 8))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2)) : (SUBQI (SLLQI (1, 8), 1)))));
3374   tmp_result2 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), MAKEDI (0, 0))) ? (0) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), SLLDI (1, 8))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1)) : (SUBQI (SLLQI (1, 8), 1)))));
3375   tmp_result3 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), MAKEDI (0, 0))) ? (0) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), SLLDI (1, 8))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0)) : (SUBQI (SLLQI (1, 8), 1)))));
3376   tmp_result4 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3), MAKEDI (0, 0))) ? (0) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3), SLLDI (1, 8))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3)) : (SUBQI (SLLQI (1, 8), 1)))));
3377   tmp_result5 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2), MAKEDI (0, 0))) ? (0) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2), SLLDI (1, 8))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2)) : (SUBQI (SLLQI (1, 8), 1)))));
3378   tmp_result6 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1), MAKEDI (0, 0))) ? (0) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1), SLLDI (1, 8))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1)) : (SUBQI (SLLQI (1, 8), 1)))));
3379   tmp_result7 = ((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0), MAKEDI (0, 0))) ? (0) : (((LTHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0), SLLDI (1, 8))) ? (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0)) : (SUBQI (SLLQI (1, 8), 1)))));
3380   {
3381     DI opval = ORDI (SLLDI (ZEXTQIDI (tmp_result7), 56), ORDI (SLLDI (ZEXTQIDI (tmp_result6), 48), ORDI (SLLDI (ZEXTQIDI (tmp_result5), 40), ORDI (SLLDI (ZEXTQIDI (tmp_result4), 32), ORDI (SLLDI (ZEXTQIDI (tmp_result3), 24), ORDI (SLLDI (ZEXTQIDI (tmp_result2), 16), ORDI (SLLDI (ZEXTQIDI (tmp_result1), 8), ZEXTQIDI (tmp_result0))))))));
3382     if (UNLIKELY(current_cpu->trace_result_p))
3383       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3384     current_cpu->h_gr_set (FLD (f_dest), opval);
3385   }
3386 }
3387
3388   current_cpu->done_insn (npc, status);
3389 #undef FLD
3390 }
3391
3392 // ********** mextr1: mextr1 $rm, $rn, $rd
3393
3394 void
3395 sh5_media_sem_mextr1 (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3396         sh5_media::write_stacks &buf)
3397 {
3398 #define FLD(f) abuf->fields.sfmt_mcmv.f
3399   sem_status status = SEM_STATUS_NORMAL;
3400   sh5_media_scache* abuf = sem;
3401   unsigned long long written = 0;
3402   PCADDR pc = abuf->addr;
3403   PCADDR npc = pc + 4;
3404
3405 {
3406   QI tmp_count;
3407   DI tmp_mask;
3408   DI tmp_rhs;
3409   tmp_count = MULQI (8, 1);
3410   tmp_mask = SLLDI (INVSI (0), tmp_count);
3411   tmp_rhs = SRLDI (ANDDI (current_cpu->h_gr_get (FLD (f_left)), tmp_mask), tmp_count);
3412   tmp_count = MULQI (8, SUBQI (8, 1));
3413   tmp_mask = SRLDI (INVSI (0), tmp_count);
3414   {
3415     DI opval = ORDI (tmp_rhs, SLLDI (ANDDI (current_cpu->h_gr_get (FLD (f_right)), tmp_mask), tmp_count));
3416     if (UNLIKELY(current_cpu->trace_result_p))
3417       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3418     current_cpu->h_gr_set (FLD (f_dest), opval);
3419   }
3420 }
3421
3422   current_cpu->done_insn (npc, status);
3423 #undef FLD
3424 }
3425
3426 // ********** mextr2: mextr2 $rm, $rn, $rd
3427
3428 void
3429 sh5_media_sem_mextr2 (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3430         sh5_media::write_stacks &buf)
3431 {
3432 #define FLD(f) abuf->fields.sfmt_mcmv.f
3433   sem_status status = SEM_STATUS_NORMAL;
3434   sh5_media_scache* abuf = sem;
3435   unsigned long long written = 0;
3436   PCADDR pc = abuf->addr;
3437   PCADDR npc = pc + 4;
3438
3439 {
3440   QI tmp_count;
3441   DI tmp_mask;
3442   DI tmp_rhs;
3443   tmp_count = MULQI (8, 2);
3444   tmp_mask = SLLDI (INVSI (0), tmp_count);
3445   tmp_rhs = SRLDI (ANDDI (current_cpu->h_gr_get (FLD (f_left)), tmp_mask), tmp_count);
3446   tmp_count = MULQI (8, SUBQI (8, 2));
3447   tmp_mask = SRLDI (INVSI (0), tmp_count);
3448   {
3449     DI opval = ORDI (tmp_rhs, SLLDI (ANDDI (current_cpu->h_gr_get (FLD (f_right)), tmp_mask), tmp_count));
3450     if (UNLIKELY(current_cpu->trace_result_p))
3451       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3452     current_cpu->h_gr_set (FLD (f_dest), opval);
3453   }
3454 }
3455
3456   current_cpu->done_insn (npc, status);
3457 #undef FLD
3458 }
3459
3460 // ********** mextr3: mextr3 $rm, $rn, $rd
3461
3462 void
3463 sh5_media_sem_mextr3 (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3464         sh5_media::write_stacks &buf)
3465 {
3466 #define FLD(f) abuf->fields.sfmt_mcmv.f
3467   sem_status status = SEM_STATUS_NORMAL;
3468   sh5_media_scache* abuf = sem;
3469   unsigned long long written = 0;
3470   PCADDR pc = abuf->addr;
3471   PCADDR npc = pc + 4;
3472
3473 {
3474   QI tmp_count;
3475   DI tmp_mask;
3476   DI tmp_rhs;
3477   tmp_count = MULQI (8, 3);
3478   tmp_mask = SLLDI (INVSI (0), tmp_count);
3479   tmp_rhs = SRLDI (ANDDI (current_cpu->h_gr_get (FLD (f_left)), tmp_mask), tmp_count);
3480   tmp_count = MULQI (8, SUBQI (8, 3));
3481   tmp_mask = SRLDI (INVSI (0), tmp_count);
3482   {
3483     DI opval = ORDI (tmp_rhs, SLLDI (ANDDI (current_cpu->h_gr_get (FLD (f_right)), tmp_mask), tmp_count));
3484     if (UNLIKELY(current_cpu->trace_result_p))
3485       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3486     current_cpu->h_gr_set (FLD (f_dest), opval);
3487   }
3488 }
3489
3490   current_cpu->done_insn (npc, status);
3491 #undef FLD
3492 }
3493
3494 // ********** mextr4: mextr4 $rm, $rn, $rd
3495
3496 void
3497 sh5_media_sem_mextr4 (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3498         sh5_media::write_stacks &buf)
3499 {
3500 #define FLD(f) abuf->fields.sfmt_mcmv.f
3501   sem_status status = SEM_STATUS_NORMAL;
3502   sh5_media_scache* abuf = sem;
3503   unsigned long long written = 0;
3504   PCADDR pc = abuf->addr;
3505   PCADDR npc = pc + 4;
3506
3507 {
3508   QI tmp_count;
3509   DI tmp_mask;
3510   DI tmp_rhs;
3511   tmp_count = MULQI (8, 4);
3512   tmp_mask = SLLDI (INVSI (0), tmp_count);
3513   tmp_rhs = SRLDI (ANDDI (current_cpu->h_gr_get (FLD (f_left)), tmp_mask), tmp_count);
3514   tmp_count = MULQI (8, SUBQI (8, 4));
3515   tmp_mask = SRLDI (INVSI (0), tmp_count);
3516   {
3517     DI opval = ORDI (tmp_rhs, SLLDI (ANDDI (current_cpu->h_gr_get (FLD (f_right)), tmp_mask), tmp_count));
3518     if (UNLIKELY(current_cpu->trace_result_p))
3519       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3520     current_cpu->h_gr_set (FLD (f_dest), opval);
3521   }
3522 }
3523
3524   current_cpu->done_insn (npc, status);
3525 #undef FLD
3526 }
3527
3528 // ********** mextr5: mextr5 $rm, $rn, $rd
3529
3530 void
3531 sh5_media_sem_mextr5 (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3532         sh5_media::write_stacks &buf)
3533 {
3534 #define FLD(f) abuf->fields.sfmt_mcmv.f
3535   sem_status status = SEM_STATUS_NORMAL;
3536   sh5_media_scache* abuf = sem;
3537   unsigned long long written = 0;
3538   PCADDR pc = abuf->addr;
3539   PCADDR npc = pc + 4;
3540
3541 {
3542   QI tmp_count;
3543   DI tmp_mask;
3544   DI tmp_rhs;
3545   tmp_count = MULQI (8, 5);
3546   tmp_mask = SLLDI (INVSI (0), tmp_count);
3547   tmp_rhs = SRLDI (ANDDI (current_cpu->h_gr_get (FLD (f_left)), tmp_mask), tmp_count);
3548   tmp_count = MULQI (8, SUBQI (8, 5));
3549   tmp_mask = SRLDI (INVSI (0), tmp_count);
3550   {
3551     DI opval = ORDI (tmp_rhs, SLLDI (ANDDI (current_cpu->h_gr_get (FLD (f_right)), tmp_mask), tmp_count));
3552     if (UNLIKELY(current_cpu->trace_result_p))
3553       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3554     current_cpu->h_gr_set (FLD (f_dest), opval);
3555   }
3556 }
3557
3558   current_cpu->done_insn (npc, status);
3559 #undef FLD
3560 }
3561
3562 // ********** mextr6: mextr6 $rm, $rn, $rd
3563
3564 void
3565 sh5_media_sem_mextr6 (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3566         sh5_media::write_stacks &buf)
3567 {
3568 #define FLD(f) abuf->fields.sfmt_mcmv.f
3569   sem_status status = SEM_STATUS_NORMAL;
3570   sh5_media_scache* abuf = sem;
3571   unsigned long long written = 0;
3572   PCADDR pc = abuf->addr;
3573   PCADDR npc = pc + 4;
3574
3575 {
3576   QI tmp_count;
3577   DI tmp_mask;
3578   DI tmp_rhs;
3579   tmp_count = MULQI (8, 6);
3580   tmp_mask = SLLDI (INVSI (0), tmp_count);
3581   tmp_rhs = SRLDI (ANDDI (current_cpu->h_gr_get (FLD (f_left)), tmp_mask), tmp_count);
3582   tmp_count = MULQI (8, SUBQI (8, 6));
3583   tmp_mask = SRLDI (INVSI (0), tmp_count);
3584   {
3585     DI opval = ORDI (tmp_rhs, SLLDI (ANDDI (current_cpu->h_gr_get (FLD (f_right)), tmp_mask), tmp_count));
3586     if (UNLIKELY(current_cpu->trace_result_p))
3587       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3588     current_cpu->h_gr_set (FLD (f_dest), opval);
3589   }
3590 }
3591
3592   current_cpu->done_insn (npc, status);
3593 #undef FLD
3594 }
3595
3596 // ********** mextr7: mextr7 $rm, $rn, $rd
3597
3598 void
3599 sh5_media_sem_mextr7 (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3600         sh5_media::write_stacks &buf)
3601 {
3602 #define FLD(f) abuf->fields.sfmt_mcmv.f
3603   sem_status status = SEM_STATUS_NORMAL;
3604   sh5_media_scache* abuf = sem;
3605   unsigned long long written = 0;
3606   PCADDR pc = abuf->addr;
3607   PCADDR npc = pc + 4;
3608
3609 {
3610   QI tmp_count;
3611   DI tmp_mask;
3612   DI tmp_rhs;
3613   tmp_count = MULQI (8, 7);
3614   tmp_mask = SLLDI (INVSI (0), tmp_count);
3615   tmp_rhs = SRLDI (ANDDI (current_cpu->h_gr_get (FLD (f_left)), tmp_mask), tmp_count);
3616   tmp_count = MULQI (8, SUBQI (8, 7));
3617   tmp_mask = SRLDI (INVSI (0), tmp_count);
3618   {
3619     DI opval = ORDI (tmp_rhs, SLLDI (ANDDI (current_cpu->h_gr_get (FLD (f_right)), tmp_mask), tmp_count));
3620     if (UNLIKELY(current_cpu->trace_result_p))
3621       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3622     current_cpu->h_gr_set (FLD (f_dest), opval);
3623   }
3624 }
3625
3626   current_cpu->done_insn (npc, status);
3627 #undef FLD
3628 }
3629
3630 // ********** mmacfxwl: mmacfx.wl $rm, $rn, $rd
3631
3632 void
3633 sh5_media_sem_mmacfxwl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3634         sh5_media::write_stacks &buf)
3635 {
3636 #define FLD(f) abuf->fields.sfmt_mcmv.f
3637   sem_status status = SEM_STATUS_NORMAL;
3638   sh5_media_scache* abuf = sem;
3639   unsigned long long written = 0;
3640   PCADDR pc = abuf->addr;
3641   PCADDR npc = pc + 4;
3642
3643 {
3644   SI tmp_temp;
3645   SI tmp_result1;
3646   SI tmp_result0;
3647   tmp_result0 = SUBWORDDISI (current_cpu->h_gr_get (FLD (f_dest)), 1);
3648   tmp_result1 = SUBWORDDISI (current_cpu->h_gr_get (FLD (f_dest)), 0);
3649   tmp_temp = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3)));
3650   tmp_temp = ((LTDI (SLLDI (tmp_temp, 1), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (SLLDI (tmp_temp, 1), SLLDI (1, SUBSI (32, 1)))) ? (SLLDI (tmp_temp, 1)) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
3651   tmp_result0 = ((LTDI (ADDDI (EXTSIDI (tmp_result0), EXTSIDI (tmp_temp)), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (ADDDI (EXTSIDI (tmp_result0), EXTSIDI (tmp_temp)), SLLDI (1, SUBSI (32, 1)))) ? (ADDDI (EXTSIDI (tmp_result0), EXTSIDI (tmp_temp))) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
3652   tmp_temp = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2)));
3653   tmp_temp = ((LTDI (SLLDI (tmp_temp, 1), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (SLLDI (tmp_temp, 1), SLLDI (1, SUBSI (32, 1)))) ? (SLLDI (tmp_temp, 1)) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
3654   tmp_result1 = ((LTDI (ADDDI (EXTSIDI (tmp_result1), EXTSIDI (tmp_temp)), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (ADDDI (EXTSIDI (tmp_result1), EXTSIDI (tmp_temp)), SLLDI (1, SUBSI (32, 1)))) ? (ADDDI (EXTSIDI (tmp_result1), EXTSIDI (tmp_temp))) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
3655   {
3656     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
3657     if (UNLIKELY(current_cpu->trace_result_p))
3658       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3659     current_cpu->h_gr_set (FLD (f_dest), opval);
3660   }
3661 }
3662
3663   current_cpu->done_insn (npc, status);
3664 #undef FLD
3665 }
3666
3667 // ********** mmacnfx.wl: mmacnfx.wl $rm, $rn, $rd
3668
3669 void
3670 sh5_media_sem_mmacnfx_wl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3671         sh5_media::write_stacks &buf)
3672 {
3673 #define FLD(f) abuf->fields.sfmt_mcmv.f
3674   sem_status status = SEM_STATUS_NORMAL;
3675   sh5_media_scache* abuf = sem;
3676   unsigned long long written = 0;
3677   PCADDR pc = abuf->addr;
3678   PCADDR npc = pc + 4;
3679
3680 {
3681   SI tmp_temp;
3682   SI tmp_result1;
3683   SI tmp_result0;
3684   tmp_result0 = SUBWORDDISI (current_cpu->h_gr_get (FLD (f_dest)), 1);
3685   tmp_result1 = SUBWORDDISI (current_cpu->h_gr_get (FLD (f_dest)), 0);
3686   tmp_temp = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3)));
3687   tmp_temp = ((LTDI (SLLDI (tmp_temp, 1), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (SLLDI (tmp_temp, 1), SLLDI (1, SUBSI (32, 1)))) ? (SLLDI (tmp_temp, 1)) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
3688   tmp_result0 = ((LTDI (SUBDI (EXTSIDI (tmp_result0), EXTSIDI (tmp_temp)), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (SUBDI (EXTSIDI (tmp_result0), EXTSIDI (tmp_temp)), SLLDI (1, SUBSI (32, 1)))) ? (SUBDI (EXTSIDI (tmp_result0), EXTSIDI (tmp_temp))) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
3689   tmp_temp = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2)));
3690   tmp_temp = ((LTDI (SLLDI (tmp_temp, 1), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (SLLDI (tmp_temp, 1), SLLDI (1, SUBSI (32, 1)))) ? (SLLDI (tmp_temp, 1)) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
3691   tmp_result1 = ((LTDI (SUBDI (EXTSIDI (tmp_result1), EXTSIDI (tmp_temp)), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (SUBDI (EXTSIDI (tmp_result1), EXTSIDI (tmp_temp)), SLLDI (1, SUBSI (32, 1)))) ? (SUBDI (EXTSIDI (tmp_result1), EXTSIDI (tmp_temp))) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
3692   {
3693     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
3694     if (UNLIKELY(current_cpu->trace_result_p))
3695       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3696     current_cpu->h_gr_set (FLD (f_dest), opval);
3697   }
3698 }
3699
3700   current_cpu->done_insn (npc, status);
3701 #undef FLD
3702 }
3703
3704 // ********** mmull: mmul.l $rm, $rn, $rd
3705
3706 void
3707 sh5_media_sem_mmull (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3708         sh5_media::write_stacks &buf)
3709 {
3710 #define FLD(f) abuf->fields.sfmt_mcmv.f
3711   sem_status status = SEM_STATUS_NORMAL;
3712   sh5_media_scache* abuf = sem;
3713   unsigned long long written = 0;
3714   PCADDR pc = abuf->addr;
3715   PCADDR npc = pc + 4;
3716
3717 {
3718   SI tmp_result1;
3719   SI tmp_result0;
3720   tmp_result0 = MULSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1));
3721   tmp_result1 = MULSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0));
3722   {
3723     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
3724     if (UNLIKELY(current_cpu->trace_result_p))
3725       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3726     current_cpu->h_gr_set (FLD (f_dest), opval);
3727   }
3728 }
3729
3730   current_cpu->done_insn (npc, status);
3731 #undef FLD
3732 }
3733
3734 // ********** mmulw: mmul.w $rm, $rn, $rd
3735
3736 void
3737 sh5_media_sem_mmulw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3738         sh5_media::write_stacks &buf)
3739 {
3740 #define FLD(f) abuf->fields.sfmt_mcmv.f
3741   sem_status status = SEM_STATUS_NORMAL;
3742   sh5_media_scache* abuf = sem;
3743   unsigned long long written = 0;
3744   PCADDR pc = abuf->addr;
3745   PCADDR npc = pc + 4;
3746
3747 {
3748   HI tmp_result3;
3749   HI tmp_result2;
3750   HI tmp_result1;
3751   HI tmp_result0;
3752   tmp_result0 = MULHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3));
3753   tmp_result1 = MULHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2));
3754   tmp_result2 = MULHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1));
3755   tmp_result3 = MULHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0));
3756   {
3757     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
3758     if (UNLIKELY(current_cpu->trace_result_p))
3759       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3760     current_cpu->h_gr_set (FLD (f_dest), opval);
3761   }
3762 }
3763
3764   current_cpu->done_insn (npc, status);
3765 #undef FLD
3766 }
3767
3768 // ********** mmulfxl: mmulfx.l $rm, $rn, $rd
3769
3770 void
3771 sh5_media_sem_mmulfxl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3772         sh5_media::write_stacks &buf)
3773 {
3774 #define FLD(f) abuf->fields.sfmt_mcmv.f
3775   sem_status status = SEM_STATUS_NORMAL;
3776   sh5_media_scache* abuf = sem;
3777   unsigned long long written = 0;
3778   PCADDR pc = abuf->addr;
3779   PCADDR npc = pc + 4;
3780
3781 {
3782   DI tmp_temp;
3783   SI tmp_result0;
3784   SI tmp_result1;
3785   tmp_temp = MULDI (ZEXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1)), ZEXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1)));
3786   tmp_result0 = ((LTDI (SRADI (tmp_temp, 31), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (SRADI (tmp_temp, 31), SLLDI (1, SUBSI (32, 1)))) ? (SRADI (tmp_temp, 31)) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
3787   tmp_temp = MULDI (ZEXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0)), ZEXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0)));
3788   tmp_result1 = ((LTDI (SRADI (tmp_temp, 31), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (SRADI (tmp_temp, 31), SLLDI (1, SUBSI (32, 1)))) ? (SRADI (tmp_temp, 31)) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
3789   {
3790     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
3791     if (UNLIKELY(current_cpu->trace_result_p))
3792       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3793     current_cpu->h_gr_set (FLD (f_dest), opval);
3794   }
3795 }
3796
3797   current_cpu->done_insn (npc, status);
3798 #undef FLD
3799 }
3800
3801 // ********** mmulfxw: mmulfx.w $rm, $rn, $rd
3802
3803 void
3804 sh5_media_sem_mmulfxw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3805         sh5_media::write_stacks &buf)
3806 {
3807 #define FLD(f) abuf->fields.sfmt_mcmv.f
3808   sem_status status = SEM_STATUS_NORMAL;
3809   sh5_media_scache* abuf = sem;
3810   unsigned long long written = 0;
3811   PCADDR pc = abuf->addr;
3812   PCADDR npc = pc + 4;
3813
3814 {
3815   SI tmp_temp;
3816   HI tmp_result0;
3817   HI tmp_result1;
3818   HI tmp_result2;
3819   HI tmp_result3;
3820   tmp_temp = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3)));
3821   tmp_result0 = ((LTSI (SRASI (tmp_temp, 15), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTSI (SRASI (tmp_temp, 15), SLLDI (1, SUBSI (16, 1)))) ? (SRASI (tmp_temp, 15)) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3822   tmp_temp = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2)));
3823   tmp_result1 = ((LTSI (SRASI (tmp_temp, 15), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTSI (SRASI (tmp_temp, 15), SLLDI (1, SUBSI (16, 1)))) ? (SRASI (tmp_temp, 15)) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3824   tmp_temp = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1)));
3825   tmp_result2 = ((LTSI (SRASI (tmp_temp, 15), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTSI (SRASI (tmp_temp, 15), SLLDI (1, SUBSI (16, 1)))) ? (SRASI (tmp_temp, 15)) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3826   tmp_temp = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0)));
3827   tmp_result3 = ((LTSI (SRASI (tmp_temp, 15), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTSI (SRASI (tmp_temp, 15), SLLDI (1, SUBSI (16, 1)))) ? (SRASI (tmp_temp, 15)) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3828   {
3829     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
3830     if (UNLIKELY(current_cpu->trace_result_p))
3831       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3832     current_cpu->h_gr_set (FLD (f_dest), opval);
3833   }
3834 }
3835
3836   current_cpu->done_insn (npc, status);
3837 #undef FLD
3838 }
3839
3840 // ********** mmulfxrpw: mmulfxrp.w $rm, $rn, $rd
3841
3842 void
3843 sh5_media_sem_mmulfxrpw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3844         sh5_media::write_stacks &buf)
3845 {
3846 #define FLD(f) abuf->fields.sfmt_mcmv.f
3847   sem_status status = SEM_STATUS_NORMAL;
3848   sh5_media_scache* abuf = sem;
3849   unsigned long long written = 0;
3850   PCADDR pc = abuf->addr;
3851   PCADDR npc = pc + 4;
3852
3853 {
3854   SI tmp_temp;
3855   HI tmp_result0;
3856   HI tmp_result1;
3857   HI tmp_result2;
3858   HI tmp_result3;
3859   HI tmp_c;
3860   tmp_c = SLLSI (1, 14);
3861   tmp_temp = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3)));
3862   tmp_result0 = ((LTSI (SRASI (ADDSI (tmp_temp, tmp_c), 15), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTSI (SRASI (ADDSI (tmp_temp, tmp_c), 15), SLLDI (1, SUBSI (16, 1)))) ? (SRASI (ADDSI (tmp_temp, tmp_c), 15)) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3863   tmp_temp = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2)));
3864   tmp_result1 = ((LTSI (SRASI (ADDSI (tmp_temp, tmp_c), 15), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTSI (SRASI (ADDSI (tmp_temp, tmp_c), 15), SLLDI (1, SUBSI (16, 1)))) ? (SRASI (ADDSI (tmp_temp, tmp_c), 15)) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3865   tmp_temp = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1)));
3866   tmp_result2 = ((LTSI (SRASI (ADDSI (tmp_temp, tmp_c), 15), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTSI (SRASI (ADDSI (tmp_temp, tmp_c), 15), SLLDI (1, SUBSI (16, 1)))) ? (SRASI (ADDSI (tmp_temp, tmp_c), 15)) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3867   tmp_temp = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0)));
3868   tmp_result3 = ((LTSI (SRASI (ADDSI (tmp_temp, tmp_c), 15), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTSI (SRASI (ADDSI (tmp_temp, tmp_c), 15), SLLDI (1, SUBSI (16, 1)))) ? (SRASI (ADDSI (tmp_temp, tmp_c), 15)) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
3869   {
3870     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
3871     if (UNLIKELY(current_cpu->trace_result_p))
3872       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3873     current_cpu->h_gr_set (FLD (f_dest), opval);
3874   }
3875 }
3876
3877   current_cpu->done_insn (npc, status);
3878 #undef FLD
3879 }
3880
3881 // ********** mmulhiwl: mmulhi.wl $rm, $rn, $rd
3882
3883 void
3884 sh5_media_sem_mmulhiwl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3885         sh5_media::write_stacks &buf)
3886 {
3887 #define FLD(f) abuf->fields.sfmt_mcmv.f
3888   sem_status status = SEM_STATUS_NORMAL;
3889   sh5_media_scache* abuf = sem;
3890   unsigned long long written = 0;
3891   PCADDR pc = abuf->addr;
3892   PCADDR npc = pc + 4;
3893
3894 {
3895   SI tmp_result1;
3896   SI tmp_result0;
3897   tmp_result0 = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1)));
3898   tmp_result1 = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0)));
3899   {
3900     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
3901     if (UNLIKELY(current_cpu->trace_result_p))
3902       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3903     current_cpu->h_gr_set (FLD (f_dest), opval);
3904   }
3905 }
3906
3907   current_cpu->done_insn (npc, status);
3908 #undef FLD
3909 }
3910
3911 // ********** mmullowl: mmullo.wl $rm, $rn, $rd
3912
3913 void
3914 sh5_media_sem_mmullowl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3915         sh5_media::write_stacks &buf)
3916 {
3917 #define FLD(f) abuf->fields.sfmt_mcmv.f
3918   sem_status status = SEM_STATUS_NORMAL;
3919   sh5_media_scache* abuf = sem;
3920   unsigned long long written = 0;
3921   PCADDR pc = abuf->addr;
3922   PCADDR npc = pc + 4;
3923
3924 {
3925   SI tmp_result1;
3926   SI tmp_result0;
3927   tmp_result0 = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3)));
3928   tmp_result1 = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2)));
3929   {
3930     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
3931     if (UNLIKELY(current_cpu->trace_result_p))
3932       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3933     current_cpu->h_gr_set (FLD (f_dest), opval);
3934   }
3935 }
3936
3937   current_cpu->done_insn (npc, status);
3938 #undef FLD
3939 }
3940
3941 // ********** mmulsumwq: mmulsum.wq $rm, $rn, $rd
3942
3943 void
3944 sh5_media_sem_mmulsumwq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3945         sh5_media::write_stacks &buf)
3946 {
3947 #define FLD(f) abuf->fields.sfmt_mcmv.f
3948   sem_status status = SEM_STATUS_NORMAL;
3949   sh5_media_scache* abuf = sem;
3950   unsigned long long written = 0;
3951   PCADDR pc = abuf->addr;
3952   PCADDR npc = pc + 4;
3953
3954 {
3955   DI tmp_acc;
3956   tmp_acc = MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0)));
3957   tmp_acc = ADDDI (tmp_acc, MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1))));
3958   tmp_acc = ADDDI (tmp_acc, MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2))));
3959   tmp_acc = ADDDI (tmp_acc, MULSI (ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3)), ZEXTHISI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3))));
3960   {
3961     DI opval = ADDDI (current_cpu->h_gr_get (FLD (f_dest)), tmp_acc);
3962     if (UNLIKELY(current_cpu->trace_result_p))
3963       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3964     current_cpu->h_gr_set (FLD (f_dest), opval);
3965   }
3966 }
3967
3968   current_cpu->done_insn (npc, status);
3969 #undef FLD
3970 }
3971
3972 // ********** movi: movi $imm16, $rd
3973
3974 void
3975 sh5_media_sem_movi (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
3976         sh5_media::write_stacks &buf)
3977 {
3978 #define FLD(f) abuf->fields.sfmt_movi.f
3979   sem_status status = SEM_STATUS_NORMAL;
3980   sh5_media_scache* abuf = sem;
3981   unsigned long long written = 0;
3982   PCADDR pc = abuf->addr;
3983   PCADDR npc = pc + 4;
3984
3985   {
3986     DI opval = EXTSIDI (FLD (f_imm16));
3987     if (UNLIKELY(current_cpu->trace_result_p))
3988       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
3989     current_cpu->h_gr_set (FLD (f_dest), opval);
3990   }
3991
3992   current_cpu->done_insn (npc, status);
3993 #undef FLD
3994 }
3995
3996 // ********** mpermw: mperm.w $rm, $rn, $rd
3997
3998 void
3999 sh5_media_sem_mpermw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4000         sh5_media::write_stacks &buf)
4001 {
4002 #define FLD(f) abuf->fields.sfmt_mcmv.f
4003   sem_status status = SEM_STATUS_NORMAL;
4004   sh5_media_scache* abuf = sem;
4005   unsigned long long written = 0;
4006   PCADDR pc = abuf->addr;
4007   PCADDR npc = pc + 4;
4008
4009 {
4010   QI tmp_control;
4011   HI tmp_result3;
4012   HI tmp_result2;
4013   HI tmp_result1;
4014   HI tmp_result0;
4015   tmp_control = ANDQI (current_cpu->h_gr_get (FLD (f_right)), 255);
4016   tmp_result0 = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), SUBSI (3, ANDQI (tmp_control, 3)));
4017   tmp_result1 = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), SUBSI (3, ANDQI (SRLQI (tmp_control, 2), 3)));
4018   tmp_result2 = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), SUBSI (3, ANDQI (SRLQI (tmp_control, 4), 3)));
4019   tmp_result3 = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), SUBSI (3, ANDQI (SRLQI (tmp_control, 6), 3)));
4020   {
4021     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
4022     if (UNLIKELY(current_cpu->trace_result_p))
4023       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4024     current_cpu->h_gr_set (FLD (f_dest), opval);
4025   }
4026 }
4027
4028   current_cpu->done_insn (npc, status);
4029 #undef FLD
4030 }
4031
4032 // ********** msadubq: msad.ubq $rm, $rn, $rd
4033
4034 void
4035 sh5_media_sem_msadubq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4036         sh5_media::write_stacks &buf)
4037 {
4038 #define FLD(f) abuf->fields.sfmt_mcmv.f
4039   sem_status status = SEM_STATUS_NORMAL;
4040   sh5_media_scache* abuf = sem;
4041   unsigned long long written = 0;
4042   PCADDR pc = abuf->addr;
4043   PCADDR npc = pc + 4;
4044
4045 {
4046   DI tmp_acc;
4047   tmp_acc = ABSDI (SUBQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0)));
4048   tmp_acc = ADDDI (tmp_acc, ABSQI (SUBQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1))));
4049   tmp_acc = ADDDI (tmp_acc, ABSQI (SUBQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2))));
4050   tmp_acc = ADDDI (tmp_acc, ABSQI (SUBQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3))));
4051   tmp_acc = ADDDI (tmp_acc, ABSQI (SUBQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4))));
4052   tmp_acc = ADDDI (tmp_acc, ABSQI (SUBQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5))));
4053   tmp_acc = ADDDI (tmp_acc, ABSQI (SUBQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6))));
4054   tmp_acc = ADDDI (tmp_acc, ABSQI (SUBQI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7), SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7))));
4055   {
4056     DI opval = ADDDI (current_cpu->h_gr_get (FLD (f_dest)), tmp_acc);
4057     if (UNLIKELY(current_cpu->trace_result_p))
4058       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4059     current_cpu->h_gr_set (FLD (f_dest), opval);
4060   }
4061 }
4062
4063   current_cpu->done_insn (npc, status);
4064 #undef FLD
4065 }
4066
4067 // ********** mshaldsl: mshalds.l $rm, $rn, $rd
4068
4069 void
4070 sh5_media_sem_mshaldsl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4071         sh5_media::write_stacks &buf)
4072 {
4073 #define FLD(f) abuf->fields.sfmt_mcmv.f
4074   sem_status status = SEM_STATUS_NORMAL;
4075   sh5_media_scache* abuf = sem;
4076   unsigned long long written = 0;
4077   PCADDR pc = abuf->addr;
4078   PCADDR npc = pc + 4;
4079
4080 {
4081   SI tmp_result1;
4082   SI tmp_result0;
4083   tmp_result0 = ((LTDI (SLLDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 31)), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (SLLDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 31)), SLLDI (1, SUBSI (32, 1)))) ? (SLLDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 31))) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
4084   tmp_result1 = ((LTDI (SLLDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 31)), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (SLLDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 31)), SLLDI (1, SUBSI (32, 1)))) ? (SLLDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 31))) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
4085   {
4086     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
4087     if (UNLIKELY(current_cpu->trace_result_p))
4088       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4089     current_cpu->h_gr_set (FLD (f_dest), opval);
4090   }
4091 }
4092
4093   current_cpu->done_insn (npc, status);
4094 #undef FLD
4095 }
4096
4097 // ********** mshaldsw: mshalds.w $rm, $rn, $rd
4098
4099 void
4100 sh5_media_sem_mshaldsw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4101         sh5_media::write_stacks &buf)
4102 {
4103 #define FLD(f) abuf->fields.sfmt_mcmv.f
4104   sem_status status = SEM_STATUS_NORMAL;
4105   sh5_media_scache* abuf = sem;
4106   unsigned long long written = 0;
4107   PCADDR pc = abuf->addr;
4108   PCADDR npc = pc + 4;
4109
4110 {
4111   HI tmp_result3;
4112   HI tmp_result2;
4113   HI tmp_result1;
4114   HI tmp_result0;
4115   tmp_result0 = ((LTDI (SLLDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15)), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (SLLDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15)), SLLDI (1, SUBSI (16, 1)))) ? (SLLDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
4116   tmp_result1 = ((LTDI (SLLDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15)), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (SLLDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15)), SLLDI (1, SUBSI (16, 1)))) ? (SLLDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
4117   tmp_result2 = ((LTDI (SLLDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15)), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (SLLDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15)), SLLDI (1, SUBSI (16, 1)))) ? (SLLDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
4118   tmp_result3 = ((LTDI (SLLDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15)), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (SLLDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15)), SLLDI (1, SUBSI (16, 1)))) ? (SLLDI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
4119   {
4120     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
4121     if (UNLIKELY(current_cpu->trace_result_p))
4122       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4123     current_cpu->h_gr_set (FLD (f_dest), opval);
4124   }
4125 }
4126
4127   current_cpu->done_insn (npc, status);
4128 #undef FLD
4129 }
4130
4131 // ********** mshardl: mshard.l $rm, $rn, $rd
4132
4133 void
4134 sh5_media_sem_mshardl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4135         sh5_media::write_stacks &buf)
4136 {
4137 #define FLD(f) abuf->fields.sfmt_mcmv.f
4138   sem_status status = SEM_STATUS_NORMAL;
4139   sh5_media_scache* abuf = sem;
4140   unsigned long long written = 0;
4141   PCADDR pc = abuf->addr;
4142   PCADDR npc = pc + 4;
4143
4144 {
4145   SI tmp_result1;
4146   SI tmp_result0;
4147   tmp_result0 = SRASI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 31));
4148   tmp_result1 = SRASI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 31));
4149   {
4150     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
4151     if (UNLIKELY(current_cpu->trace_result_p))
4152       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4153     current_cpu->h_gr_set (FLD (f_dest), opval);
4154   }
4155 }
4156
4157   current_cpu->done_insn (npc, status);
4158 #undef FLD
4159 }
4160
4161 // ********** mshardw: mshard.w $rm, $rn, $rd
4162
4163 void
4164 sh5_media_sem_mshardw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4165         sh5_media::write_stacks &buf)
4166 {
4167 #define FLD(f) abuf->fields.sfmt_mcmv.f
4168   sem_status status = SEM_STATUS_NORMAL;
4169   sh5_media_scache* abuf = sem;
4170   unsigned long long written = 0;
4171   PCADDR pc = abuf->addr;
4172   PCADDR npc = pc + 4;
4173
4174 {
4175   HI tmp_result3;
4176   HI tmp_result2;
4177   HI tmp_result1;
4178   HI tmp_result0;
4179   tmp_result0 = SRAHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15));
4180   tmp_result1 = SRAHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15));
4181   tmp_result2 = SRAHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15));
4182   tmp_result3 = SRAHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15));
4183   {
4184     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
4185     if (UNLIKELY(current_cpu->trace_result_p))
4186       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4187     current_cpu->h_gr_set (FLD (f_dest), opval);
4188   }
4189 }
4190
4191   current_cpu->done_insn (npc, status);
4192 #undef FLD
4193 }
4194
4195 // ********** mshardsq: mshards.q $rm, $rn, $rd
4196
4197 void
4198 sh5_media_sem_mshardsq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4199         sh5_media::write_stacks &buf)
4200 {
4201 #define FLD(f) abuf->fields.sfmt_mcmv.f
4202   sem_status status = SEM_STATUS_NORMAL;
4203   sh5_media_scache* abuf = sem;
4204   unsigned long long written = 0;
4205   PCADDR pc = abuf->addr;
4206   PCADDR npc = pc + 4;
4207
4208   {
4209     DI opval = ((LTDI (SRADI (current_cpu->h_gr_get (FLD (f_left)), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 63)), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGDI (SLLDI (1, SUBSI (16, 1)))) : (((LTDI (SRADI (current_cpu->h_gr_get (FLD (f_left)), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 63)), SLLDI (1, SUBSI (16, 1)))) ? (SRADI (current_cpu->h_gr_get (FLD (f_left)), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 63))) : (SUBDI (SLLDI (1, SUBSI (16, 1)), 1)))));
4210     if (UNLIKELY(current_cpu->trace_result_p))
4211       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4212     current_cpu->h_gr_set (FLD (f_dest), opval);
4213   }
4214
4215   current_cpu->done_insn (npc, status);
4216 #undef FLD
4217 }
4218
4219 // ********** mshfhib: mshfhi.b $rm, $rn, $rd
4220
4221 void
4222 sh5_media_sem_mshfhib (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4223         sh5_media::write_stacks &buf)
4224 {
4225 #define FLD(f) abuf->fields.sfmt_mcmv.f
4226   sem_status status = SEM_STATUS_NORMAL;
4227   sh5_media_scache* abuf = sem;
4228   unsigned long long written = 0;
4229   PCADDR pc = abuf->addr;
4230   PCADDR npc = pc + 4;
4231
4232 {
4233   QI tmp_result7;
4234   QI tmp_result6;
4235   QI tmp_result5;
4236   QI tmp_result4;
4237   QI tmp_result3;
4238   QI tmp_result2;
4239   QI tmp_result1;
4240   QI tmp_result0;
4241   tmp_result0 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3);
4242   tmp_result1 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3);
4243   tmp_result2 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2);
4244   tmp_result3 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2);
4245   tmp_result4 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1);
4246   tmp_result5 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1);
4247   tmp_result6 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0);
4248   tmp_result7 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0);
4249   {
4250     DI opval = ORDI (SLLDI (ZEXTQIDI (tmp_result7), 56), ORDI (SLLDI (ZEXTQIDI (tmp_result6), 48), ORDI (SLLDI (ZEXTQIDI (tmp_result5), 40), ORDI (SLLDI (ZEXTQIDI (tmp_result4), 32), ORDI (SLLDI (ZEXTQIDI (tmp_result3), 24), ORDI (SLLDI (ZEXTQIDI (tmp_result2), 16), ORDI (SLLDI (ZEXTQIDI (tmp_result1), 8), ZEXTQIDI (tmp_result0))))))));
4251     if (UNLIKELY(current_cpu->trace_result_p))
4252       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4253     current_cpu->h_gr_set (FLD (f_dest), opval);
4254   }
4255 }
4256
4257   current_cpu->done_insn (npc, status);
4258 #undef FLD
4259 }
4260
4261 // ********** mshfhil: mshfhi.l $rm, $rn, $rd
4262
4263 void
4264 sh5_media_sem_mshfhil (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4265         sh5_media::write_stacks &buf)
4266 {
4267 #define FLD(f) abuf->fields.sfmt_mcmv.f
4268   sem_status status = SEM_STATUS_NORMAL;
4269   sh5_media_scache* abuf = sem;
4270   unsigned long long written = 0;
4271   PCADDR pc = abuf->addr;
4272   PCADDR npc = pc + 4;
4273
4274 {
4275   SI tmp_result1;
4276   SI tmp_result0;
4277   tmp_result0 = SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0);
4278   tmp_result1 = SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0);
4279   {
4280     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
4281     if (UNLIKELY(current_cpu->trace_result_p))
4282       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4283     current_cpu->h_gr_set (FLD (f_dest), opval);
4284   }
4285 }
4286
4287   current_cpu->done_insn (npc, status);
4288 #undef FLD
4289 }
4290
4291 // ********** mshfhiw: mshfhi.w $rm, $rn, $rd
4292
4293 void
4294 sh5_media_sem_mshfhiw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4295         sh5_media::write_stacks &buf)
4296 {
4297 #define FLD(f) abuf->fields.sfmt_mcmv.f
4298   sem_status status = SEM_STATUS_NORMAL;
4299   sh5_media_scache* abuf = sem;
4300   unsigned long long written = 0;
4301   PCADDR pc = abuf->addr;
4302   PCADDR npc = pc + 4;
4303
4304 {
4305   HI tmp_result3;
4306   HI tmp_result2;
4307   HI tmp_result1;
4308   HI tmp_result0;
4309   tmp_result0 = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1);
4310   tmp_result1 = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1);
4311   tmp_result2 = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0);
4312   tmp_result3 = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0);
4313   {
4314     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
4315     if (UNLIKELY(current_cpu->trace_result_p))
4316       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4317     current_cpu->h_gr_set (FLD (f_dest), opval);
4318   }
4319 }
4320
4321   current_cpu->done_insn (npc, status);
4322 #undef FLD
4323 }
4324
4325 // ********** mshflob: mshflo.b $rm, $rn, $rd
4326
4327 void
4328 sh5_media_sem_mshflob (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4329         sh5_media::write_stacks &buf)
4330 {
4331 #define FLD(f) abuf->fields.sfmt_mcmv.f
4332   sem_status status = SEM_STATUS_NORMAL;
4333   sh5_media_scache* abuf = sem;
4334   unsigned long long written = 0;
4335   PCADDR pc = abuf->addr;
4336   PCADDR npc = pc + 4;
4337
4338 {
4339   QI tmp_result7;
4340   QI tmp_result6;
4341   QI tmp_result5;
4342   QI tmp_result4;
4343   QI tmp_result3;
4344   QI tmp_result2;
4345   QI tmp_result1;
4346   QI tmp_result0;
4347   tmp_result0 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7);
4348   tmp_result1 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7);
4349   tmp_result2 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6);
4350   tmp_result3 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6);
4351   tmp_result4 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5);
4352   tmp_result5 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5);
4353   tmp_result6 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4);
4354   tmp_result7 = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4);
4355   {
4356     DI opval = ORDI (SLLDI (ZEXTQIDI (tmp_result7), 56), ORDI (SLLDI (ZEXTQIDI (tmp_result6), 48), ORDI (SLLDI (ZEXTQIDI (tmp_result5), 40), ORDI (SLLDI (ZEXTQIDI (tmp_result4), 32), ORDI (SLLDI (ZEXTQIDI (tmp_result3), 24), ORDI (SLLDI (ZEXTQIDI (tmp_result2), 16), ORDI (SLLDI (ZEXTQIDI (tmp_result1), 8), ZEXTQIDI (tmp_result0))))))));
4357     if (UNLIKELY(current_cpu->trace_result_p))
4358       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4359     current_cpu->h_gr_set (FLD (f_dest), opval);
4360   }
4361 }
4362
4363   current_cpu->done_insn (npc, status);
4364 #undef FLD
4365 }
4366
4367 // ********** mshflol: mshflo.l $rm, $rn, $rd
4368
4369 void
4370 sh5_media_sem_mshflol (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4371         sh5_media::write_stacks &buf)
4372 {
4373 #define FLD(f) abuf->fields.sfmt_mcmv.f
4374   sem_status status = SEM_STATUS_NORMAL;
4375   sh5_media_scache* abuf = sem;
4376   unsigned long long written = 0;
4377   PCADDR pc = abuf->addr;
4378   PCADDR npc = pc + 4;
4379
4380 {
4381   SI tmp_result1;
4382   SI tmp_result0;
4383   tmp_result0 = SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1);
4384   tmp_result1 = SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1);
4385   {
4386     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
4387     if (UNLIKELY(current_cpu->trace_result_p))
4388       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4389     current_cpu->h_gr_set (FLD (f_dest), opval);
4390   }
4391 }
4392
4393   current_cpu->done_insn (npc, status);
4394 #undef FLD
4395 }
4396
4397 // ********** mshflow: mshflo.w $rm, $rn, $rd
4398
4399 void
4400 sh5_media_sem_mshflow (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4401         sh5_media::write_stacks &buf)
4402 {
4403 #define FLD(f) abuf->fields.sfmt_mcmv.f
4404   sem_status status = SEM_STATUS_NORMAL;
4405   sh5_media_scache* abuf = sem;
4406   unsigned long long written = 0;
4407   PCADDR pc = abuf->addr;
4408   PCADDR npc = pc + 4;
4409
4410 {
4411   HI tmp_result3;
4412   HI tmp_result2;
4413   HI tmp_result1;
4414   HI tmp_result0;
4415   tmp_result0 = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3);
4416   tmp_result1 = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3);
4417   tmp_result2 = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2);
4418   tmp_result3 = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2);
4419   {
4420     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
4421     if (UNLIKELY(current_cpu->trace_result_p))
4422       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4423     current_cpu->h_gr_set (FLD (f_dest), opval);
4424   }
4425 }
4426
4427   current_cpu->done_insn (npc, status);
4428 #undef FLD
4429 }
4430
4431 // ********** mshlldl: mshlld.l $rm, $rn, $rd
4432
4433 void
4434 sh5_media_sem_mshlldl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4435         sh5_media::write_stacks &buf)
4436 {
4437 #define FLD(f) abuf->fields.sfmt_mcmv.f
4438   sem_status status = SEM_STATUS_NORMAL;
4439   sh5_media_scache* abuf = sem;
4440   unsigned long long written = 0;
4441   PCADDR pc = abuf->addr;
4442   PCADDR npc = pc + 4;
4443
4444 {
4445   SI tmp_result1;
4446   SI tmp_result0;
4447   tmp_result0 = SLLSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 31));
4448   tmp_result1 = SLLSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 31));
4449   {
4450     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
4451     if (UNLIKELY(current_cpu->trace_result_p))
4452       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4453     current_cpu->h_gr_set (FLD (f_dest), opval);
4454   }
4455 }
4456
4457   current_cpu->done_insn (npc, status);
4458 #undef FLD
4459 }
4460
4461 // ********** mshlldw: mshlld.w $rm, $rn, $rd
4462
4463 void
4464 sh5_media_sem_mshlldw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4465         sh5_media::write_stacks &buf)
4466 {
4467 #define FLD(f) abuf->fields.sfmt_mcmv.f
4468   sem_status status = SEM_STATUS_NORMAL;
4469   sh5_media_scache* abuf = sem;
4470   unsigned long long written = 0;
4471   PCADDR pc = abuf->addr;
4472   PCADDR npc = pc + 4;
4473
4474 {
4475   HI tmp_result3;
4476   HI tmp_result2;
4477   HI tmp_result1;
4478   HI tmp_result0;
4479   tmp_result0 = SLLHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15));
4480   tmp_result1 = SLLHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15));
4481   tmp_result2 = SLLHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15));
4482   tmp_result3 = SLLHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15));
4483   {
4484     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
4485     if (UNLIKELY(current_cpu->trace_result_p))
4486       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4487     current_cpu->h_gr_set (FLD (f_dest), opval);
4488   }
4489 }
4490
4491   current_cpu->done_insn (npc, status);
4492 #undef FLD
4493 }
4494
4495 // ********** mshlrdl: mshlrd.l $rm, $rn, $rd
4496
4497 void
4498 sh5_media_sem_mshlrdl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4499         sh5_media::write_stacks &buf)
4500 {
4501 #define FLD(f) abuf->fields.sfmt_mcmv.f
4502   sem_status status = SEM_STATUS_NORMAL;
4503   sh5_media_scache* abuf = sem;
4504   unsigned long long written = 0;
4505   PCADDR pc = abuf->addr;
4506   PCADDR npc = pc + 4;
4507
4508 {
4509   SI tmp_result1;
4510   SI tmp_result0;
4511   tmp_result0 = SRLSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 31));
4512   tmp_result1 = SRLSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 31));
4513   {
4514     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
4515     if (UNLIKELY(current_cpu->trace_result_p))
4516       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4517     current_cpu->h_gr_set (FLD (f_dest), opval);
4518   }
4519 }
4520
4521   current_cpu->done_insn (npc, status);
4522 #undef FLD
4523 }
4524
4525 // ********** mshlrdw: mshlrd.w $rm, $rn, $rd
4526
4527 void
4528 sh5_media_sem_mshlrdw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4529         sh5_media::write_stacks &buf)
4530 {
4531 #define FLD(f) abuf->fields.sfmt_mcmv.f
4532   sem_status status = SEM_STATUS_NORMAL;
4533   sh5_media_scache* abuf = sem;
4534   unsigned long long written = 0;
4535   PCADDR pc = abuf->addr;
4536   PCADDR npc = pc + 4;
4537
4538 {
4539   HI tmp_result3;
4540   HI tmp_result2;
4541   HI tmp_result1;
4542   HI tmp_result0;
4543   tmp_result0 = SRLHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15));
4544   tmp_result1 = SRLHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15));
4545   tmp_result2 = SRLHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15));
4546   tmp_result3 = SRLHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 15));
4547   {
4548     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
4549     if (UNLIKELY(current_cpu->trace_result_p))
4550       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4551     current_cpu->h_gr_set (FLD (f_dest), opval);
4552   }
4553 }
4554
4555   current_cpu->done_insn (npc, status);
4556 #undef FLD
4557 }
4558
4559 // ********** msubl: msub.l $rm, $rn, $rd
4560
4561 void
4562 sh5_media_sem_msubl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4563         sh5_media::write_stacks &buf)
4564 {
4565 #define FLD(f) abuf->fields.sfmt_mcmv.f
4566   sem_status status = SEM_STATUS_NORMAL;
4567   sh5_media_scache* abuf = sem;
4568   unsigned long long written = 0;
4569   PCADDR pc = abuf->addr;
4570   PCADDR npc = pc + 4;
4571
4572 {
4573   SI tmp_result1;
4574   SI tmp_result0;
4575   tmp_result0 = SUBSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1));
4576   tmp_result1 = SUBSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0));
4577   {
4578     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
4579     if (UNLIKELY(current_cpu->trace_result_p))
4580       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4581     current_cpu->h_gr_set (FLD (f_dest), opval);
4582   }
4583 }
4584
4585   current_cpu->done_insn (npc, status);
4586 #undef FLD
4587 }
4588
4589 // ********** msubw: msub.w $rm, $rn, $rd
4590
4591 void
4592 sh5_media_sem_msubw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4593         sh5_media::write_stacks &buf)
4594 {
4595 #define FLD(f) abuf->fields.sfmt_mcmv.f
4596   sem_status status = SEM_STATUS_NORMAL;
4597   sh5_media_scache* abuf = sem;
4598   unsigned long long written = 0;
4599   PCADDR pc = abuf->addr;
4600   PCADDR npc = pc + 4;
4601
4602 {
4603   HI tmp_result3;
4604   HI tmp_result2;
4605   HI tmp_result1;
4606   HI tmp_result0;
4607   tmp_result0 = SUBHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 3), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 3));
4608   tmp_result1 = SUBHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 2), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 2));
4609   tmp_result2 = SUBHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 1));
4610   tmp_result3 = SUBHI (SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_left)), 0), SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_right)), 0));
4611   {
4612     DI opval = ORDI (SLLDI (ZEXTHIDI (tmp_result3), 48), ORDI (SLLDI (ZEXTHIDI (tmp_result2), 32), ORDI (SLLDI (ZEXTHIDI (tmp_result1), 16), ZEXTHIDI (tmp_result0))));
4613     if (UNLIKELY(current_cpu->trace_result_p))
4614       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4615     current_cpu->h_gr_set (FLD (f_dest), opval);
4616   }
4617 }
4618
4619   current_cpu->done_insn (npc, status);
4620 #undef FLD
4621 }
4622
4623 // ********** msubsl: msubs.l $rm, $rn, $rd
4624
4625 void
4626 sh5_media_sem_msubsl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4627         sh5_media::write_stacks &buf)
4628 {
4629 #define FLD(f) abuf->fields.sfmt_mcmv.f
4630   sem_status status = SEM_STATUS_NORMAL;
4631   sh5_media_scache* abuf = sem;
4632   unsigned long long written = 0;
4633   PCADDR pc = abuf->addr;
4634   PCADDR npc = pc + 4;
4635
4636 {
4637   SI tmp_result1;
4638   SI tmp_result0;
4639   tmp_result0 = ((LTDI (SUBDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1))), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (SUBDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1))), SLLDI (1, SUBSI (32, 1)))) ? (SUBDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1)))) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
4640   tmp_result1 = ((LTDI (SUBDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0))), NEGDI (SLLDI (1, SUBSI (32, 1))))) ? (NEGSI (SLLSI (1, SUBSI (32, 1)))) : (((LTDI (SUBDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0))), SLLDI (1, SUBSI (32, 1)))) ? (SUBDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 0)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 0)))) : (SUBSI (SLLSI (1, SUBSI (32, 1)), 1)))));
4641   {
4642     DI opval = ORDI (SLLDI (ZEXTSIDI (tmp_result1), 32), ZEXTSIDI (tmp_result0));
4643     if (UNLIKELY(current_cpu->trace_result_p))
4644       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4645     current_cpu->h_gr_set (FLD (f_dest), opval);
4646   }
4647 }
4648
4649   current_cpu->done_insn (npc, status);
4650 #undef FLD
4651 }
4652
4653 // ********** msubsub: msubs.ub $rm, $rn, $rd
4654
4655 void
4656 sh5_media_sem_msubsub (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4657         sh5_media::write_stacks &buf)
4658 {
4659 #define FLD(f) abuf->fields.sfmt_mcmv.f
4660   sem_status status = SEM_STATUS_NORMAL;
4661   sh5_media_scache* abuf = sem;
4662   unsigned long long written = 0;
4663   PCADDR pc = abuf->addr;
4664   PCADDR npc = pc + 4;
4665
4666 {
4667   QI tmp_result7;
4668   QI tmp_result6;
4669   QI tmp_result5;
4670   QI tmp_result4;
4671   QI tmp_result3;
4672   QI tmp_result2;
4673   QI tmp_result1;
4674   QI tmp_result0;
4675   tmp_result0 = ((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7))), MAKEDI (0, 0))) ? (0) : (((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7))), SLLDI (1, 8))) ? (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7)))) : (SUBQI (SLLQI (1, 8), 1)))));
4676   tmp_result1 = ((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6))), MAKEDI (0, 0))) ? (0) : (((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6))), SLLDI (1, 8))) ? (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6)))) : (SUBQI (SLLQI (1, 8), 1)))));
4677   tmp_result2 = ((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5))), MAKEDI (0, 0))) ? (0) : (((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5))), SLLDI (1, 8))) ? (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5)))) : (SUBQI (SLLQI (1, 8), 1)))));
4678   tmp_result3 = ((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4))), MAKEDI (0, 0))) ? (0) : (((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4))), SLLDI (1, 8))) ? (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4)))) : (SUBQI (SLLQI (1, 8), 1)))));
4679   tmp_result4 = ((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3))), MAKEDI (0, 0))) ? (0) : (((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3))), SLLDI (1, 8))) ? (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3)))) : (SUBQI (SLLQI (1, 8), 1)))));
4680   tmp_result5 = ((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2))), MAKEDI (0, 0))) ? (0) : (((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2))), SLLDI (1, 8))) ? (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2)))) : (SUBQI (SLLQI (1, 8), 1)))));
4681   tmp_result6 = ((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1))), MAKEDI (0, 0))) ? (0) : (((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1))), SLLDI (1, 8))) ? (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1)))) : (SUBQI (SLLQI (1, 8), 1)))));
4682   tmp_result7 = ((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0))), MAKEDI (0, 0))) ? (0) : (((LTDI (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0))), SLLDI (1, 8))) ? (SUBDI (ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0)), ZEXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0)))) : (SUBQI (SLLQI (1, 8), 1)))));
4683   {
4684     DI opval = ORDI (SLLDI (ZEXTQIDI (tmp_result7), 56), ORDI (SLLDI (ZEXTQIDI (tmp_result6), 48), ORDI (SLLDI (ZEXTQIDI (tmp_result5), 40), ORDI (SLLDI (ZEXTQIDI (tmp_result4), 32), ORDI (SLLDI (ZEXTQIDI (tmp_result3), 24), ORDI (SLLDI (ZEXTQIDI (tmp_result2), 16), ORDI (SLLDI (ZEXTQIDI (tmp_result1), 8), ZEXTQIDI (tmp_result0))))))));
4685     if (UNLIKELY(current_cpu->trace_result_p))
4686       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4687     current_cpu->h_gr_set (FLD (f_dest), opval);
4688   }
4689 }
4690
4691   current_cpu->done_insn (npc, status);
4692 #undef FLD
4693 }
4694
4695 // ********** msubsw: msubs.w $rm, $rn, $rd
4696
4697 void
4698 sh5_media_sem_msubsw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4699         sh5_media::write_stacks &buf)
4700 {
4701 #define FLD(f) abuf->fields.sfmt_mcmv.f
4702   sem_status status = SEM_STATUS_NORMAL;
4703   sh5_media_scache* abuf = sem;
4704   unsigned long long written = 0;
4705   PCADDR pc = abuf->addr;
4706   PCADDR npc = pc + 4;
4707
4708 {
4709   QI tmp_result7;
4710   QI tmp_result6;
4711   QI tmp_result5;
4712   QI tmp_result4;
4713   QI tmp_result3;
4714   QI tmp_result2;
4715   QI tmp_result1;
4716   QI tmp_result0;
4717   tmp_result0 = ((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7))), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7))), SLLDI (1, SUBSI (16, 1)))) ? (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 7)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 7)))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
4718   tmp_result1 = ((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6))), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6))), SLLDI (1, SUBSI (16, 1)))) ? (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 6)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 6)))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
4719   tmp_result2 = ((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5))), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5))), SLLDI (1, SUBSI (16, 1)))) ? (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 5)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 5)))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
4720   tmp_result3 = ((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4))), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4))), SLLDI (1, SUBSI (16, 1)))) ? (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 4)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 4)))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
4721   tmp_result4 = ((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3))), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3))), SLLDI (1, SUBSI (16, 1)))) ? (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 3)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 3)))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
4722   tmp_result5 = ((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2))), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2))), SLLDI (1, SUBSI (16, 1)))) ? (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 2)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 2)))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
4723   tmp_result6 = ((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1))), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1))), SLLDI (1, SUBSI (16, 1)))) ? (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 1)))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
4724   tmp_result7 = ((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0))), NEGDI (SLLDI (1, SUBSI (16, 1))))) ? (NEGHI (SLLHI (1, SUBSI (16, 1)))) : (((LTDI (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0))), SLLDI (1, SUBSI (16, 1)))) ? (SUBDI (EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_left)), 0)), EXTQIDI (SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_right)), 0)))) : (SUBHI (SLLHI (1, SUBSI (16, 1)), 1)))));
4725   {
4726     DI opval = ORDI (SLLDI (ZEXTQIDI (tmp_result7), 56), ORDI (SLLDI (ZEXTQIDI (tmp_result6), 48), ORDI (SLLDI (ZEXTQIDI (tmp_result5), 40), ORDI (SLLDI (ZEXTQIDI (tmp_result4), 32), ORDI (SLLDI (ZEXTQIDI (tmp_result3), 24), ORDI (SLLDI (ZEXTQIDI (tmp_result2), 16), ORDI (SLLDI (ZEXTQIDI (tmp_result1), 8), ZEXTQIDI (tmp_result0))))))));
4727     if (UNLIKELY(current_cpu->trace_result_p))
4728       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4729     current_cpu->h_gr_set (FLD (f_dest), opval);
4730   }
4731 }
4732
4733   current_cpu->done_insn (npc, status);
4734 #undef FLD
4735 }
4736
4737 // ********** mulsl: muls.l $rm, $rn, $rd
4738
4739 void
4740 sh5_media_sem_mulsl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4741         sh5_media::write_stacks &buf)
4742 {
4743 #define FLD(f) abuf->fields.sfmt_mcmv.f
4744   sem_status status = SEM_STATUS_NORMAL;
4745   sh5_media_scache* abuf = sem;
4746   unsigned long long written = 0;
4747   PCADDR pc = abuf->addr;
4748   PCADDR npc = pc + 4;
4749
4750   {
4751     DI opval = MULDI (EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1)), EXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1)));
4752     if (UNLIKELY(current_cpu->trace_result_p))
4753       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4754     current_cpu->h_gr_set (FLD (f_dest), opval);
4755   }
4756
4757   current_cpu->done_insn (npc, status);
4758 #undef FLD
4759 }
4760
4761 // ********** mulul: mulu.l $rm, $rn, $rd
4762
4763 void
4764 sh5_media_sem_mulul (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4765         sh5_media::write_stacks &buf)
4766 {
4767 #define FLD(f) abuf->fields.sfmt_mcmv.f
4768   sem_status status = SEM_STATUS_NORMAL;
4769   sh5_media_scache* abuf = sem;
4770   unsigned long long written = 0;
4771   PCADDR pc = abuf->addr;
4772   PCADDR npc = pc + 4;
4773
4774   {
4775     DI opval = MULDI (ZEXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1)), ZEXTSIDI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1)));
4776     if (UNLIKELY(current_cpu->trace_result_p))
4777       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4778     current_cpu->h_gr_set (FLD (f_dest), opval);
4779   }
4780
4781   current_cpu->done_insn (npc, status);
4782 #undef FLD
4783 }
4784
4785 // ********** nop: nop
4786
4787 void
4788 sh5_media_sem_nop (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4789         sh5_media::write_stacks &buf)
4790 {
4791 #define FLD(f) abuf->fields.fmt_empty.f
4792   sem_status status = SEM_STATUS_NORMAL;
4793   sh5_media_scache* abuf = sem;
4794   unsigned long long written = 0;
4795   PCADDR pc = abuf->addr;
4796   PCADDR npc = pc + 4;
4797
4798 ((void) 0); /*nop*/
4799
4800   current_cpu->done_insn (npc, status);
4801 #undef FLD
4802 }
4803
4804 // ********** nsb: nsb $rm, $rd
4805
4806 void
4807 sh5_media_sem_nsb (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4808         sh5_media::write_stacks &buf)
4809 {
4810 #define FLD(f) abuf->fields.sfmt_xori.f
4811   sem_status status = SEM_STATUS_NORMAL;
4812   sh5_media_scache* abuf = sem;
4813   unsigned long long written = 0;
4814   PCADDR pc = abuf->addr;
4815   PCADDR npc = pc + 4;
4816
4817   {
4818     DI opval = current_cpu->sh64_nsb (current_cpu->h_gr_get (FLD (f_left)));
4819     if (UNLIKELY(current_cpu->trace_result_p))
4820       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4821     current_cpu->h_gr_set (FLD (f_dest), opval);
4822   }
4823
4824   current_cpu->done_insn (npc, status);
4825 #undef FLD
4826 }
4827
4828 // ********** ocbi: ocbi $rm, $disp6x32
4829
4830 void
4831 sh5_media_sem_ocbi (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4832         sh5_media::write_stacks &buf)
4833 {
4834 #define FLD(f) abuf->fields.sfmt_alloco.f
4835   sem_status status = SEM_STATUS_NORMAL;
4836   sh5_media_scache* abuf = sem;
4837   unsigned long long written = 0;
4838   PCADDR pc = abuf->addr;
4839   PCADDR npc = pc + 4;
4840
4841 {
4842   {
4843     DI opval = current_cpu->h_gr_get (FLD (f_left));
4844     if (UNLIKELY(current_cpu->trace_result_p))
4845       current_cpu->trace_stream << "gr" << '[' << FLD (f_left) << ']' << ":=0x" << hex << opval << dec << "  ";
4846     current_cpu->h_gr_set (FLD (f_left), opval);
4847   }
4848 ((void) 0); /*nop*/
4849 }
4850
4851   current_cpu->done_insn (npc, status);
4852 #undef FLD
4853 }
4854
4855 // ********** ocbp: ocbp $rm, $disp6x32
4856
4857 void
4858 sh5_media_sem_ocbp (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4859         sh5_media::write_stacks &buf)
4860 {
4861 #define FLD(f) abuf->fields.sfmt_alloco.f
4862   sem_status status = SEM_STATUS_NORMAL;
4863   sh5_media_scache* abuf = sem;
4864   unsigned long long written = 0;
4865   PCADDR pc = abuf->addr;
4866   PCADDR npc = pc + 4;
4867
4868 {
4869   {
4870     DI opval = current_cpu->h_gr_get (FLD (f_left));
4871     if (UNLIKELY(current_cpu->trace_result_p))
4872       current_cpu->trace_stream << "gr" << '[' << FLD (f_left) << ']' << ":=0x" << hex << opval << dec << "  ";
4873     current_cpu->h_gr_set (FLD (f_left), opval);
4874   }
4875 ((void) 0); /*nop*/
4876 }
4877
4878   current_cpu->done_insn (npc, status);
4879 #undef FLD
4880 }
4881
4882 // ********** ocbwb: ocbwb $rm, $disp6x32
4883
4884 void
4885 sh5_media_sem_ocbwb (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4886         sh5_media::write_stacks &buf)
4887 {
4888 #define FLD(f) abuf->fields.sfmt_alloco.f
4889   sem_status status = SEM_STATUS_NORMAL;
4890   sh5_media_scache* abuf = sem;
4891   unsigned long long written = 0;
4892   PCADDR pc = abuf->addr;
4893   PCADDR npc = pc + 4;
4894
4895 {
4896   {
4897     DI opval = current_cpu->h_gr_get (FLD (f_left));
4898     if (UNLIKELY(current_cpu->trace_result_p))
4899       current_cpu->trace_stream << "gr" << '[' << FLD (f_left) << ']' << ":=0x" << hex << opval << dec << "  ";
4900     current_cpu->h_gr_set (FLD (f_left), opval);
4901   }
4902 ((void) 0); /*nop*/
4903 }
4904
4905   current_cpu->done_insn (npc, status);
4906 #undef FLD
4907 }
4908
4909 // ********** or: or $rm, $rn, $rd
4910
4911 void
4912 sh5_media_sem_or (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4913         sh5_media::write_stacks &buf)
4914 {
4915 #define FLD(f) abuf->fields.sfmt_mcmv.f
4916   sem_status status = SEM_STATUS_NORMAL;
4917   sh5_media_scache* abuf = sem;
4918   unsigned long long written = 0;
4919   PCADDR pc = abuf->addr;
4920   PCADDR npc = pc + 4;
4921
4922   {
4923     DI opval = ORDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)));
4924     if (UNLIKELY(current_cpu->trace_result_p))
4925       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4926     current_cpu->h_gr_set (FLD (f_dest), opval);
4927   }
4928
4929   current_cpu->done_insn (npc, status);
4930 #undef FLD
4931 }
4932
4933 // ********** ori: ori $rm, $imm10, $rd
4934
4935 void
4936 sh5_media_sem_ori (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4937         sh5_media::write_stacks &buf)
4938 {
4939 #define FLD(f) abuf->fields.sfmt_ori.f
4940   sem_status status = SEM_STATUS_NORMAL;
4941   sh5_media_scache* abuf = sem;
4942   unsigned long long written = 0;
4943   PCADDR pc = abuf->addr;
4944   PCADDR npc = pc + 4;
4945
4946   {
4947     DI opval = ORDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_imm10)));
4948     if (UNLIKELY(current_cpu->trace_result_p))
4949       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
4950     current_cpu->h_gr_set (FLD (f_dest), opval);
4951   }
4952
4953   current_cpu->done_insn (npc, status);
4954 #undef FLD
4955 }
4956
4957 // ********** prefi: prefi $rm, $disp6x32
4958
4959 void
4960 sh5_media_sem_prefi (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4961         sh5_media::write_stacks &buf)
4962 {
4963 #define FLD(f) abuf->fields.sfmt_alloco.f
4964   sem_status status = SEM_STATUS_NORMAL;
4965   sh5_media_scache* abuf = sem;
4966   unsigned long long written = 0;
4967   PCADDR pc = abuf->addr;
4968   PCADDR npc = pc + 4;
4969
4970 {
4971   {
4972     DI opval = current_cpu->h_gr_get (FLD (f_left));
4973     if (UNLIKELY(current_cpu->trace_result_p))
4974       current_cpu->trace_stream << "gr" << '[' << FLD (f_left) << ']' << ":=0x" << hex << opval << dec << "  ";
4975     current_cpu->h_gr_set (FLD (f_left), opval);
4976   }
4977 ((void) 0); /*nop*/
4978 }
4979
4980   current_cpu->done_insn (npc, status);
4981 #undef FLD
4982 }
4983
4984 // ********** pta: pta$likely $disp16, $tra
4985
4986 void
4987 sh5_media_sem_pta (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
4988         sh5_media::write_stacks &buf)
4989 {
4990 #define FLD(f) abuf->fields.sfmt_pta.f
4991   sem_status status = SEM_STATUS_NORMAL;
4992   sh5_media_scache* abuf = sem;
4993   unsigned long long written = 0;
4994   PCADDR pc = abuf->addr;
4995   PCADDR npc = pc + 4;
4996
4997 {
4998 current_cpu->save_branch_prediction (FLD (f_tra), FLD (f_likely));
4999   {
5000     DI opval = ADDSI (FLD (f_disp16), 1);
5001     if (UNLIKELY(current_cpu->trace_result_p))
5002       current_cpu->trace_stream << "tr" << '[' << FLD (f_tra) << ']' << ":=0x" << hex << opval << dec << "  ";
5003     current_cpu->hardware.h_tr[FLD (f_tra)] = opval;
5004   }
5005 }
5006
5007   current_cpu->done_insn (npc, status);
5008 #undef FLD
5009 }
5010
5011 // ********** ptabs: ptabs$likely $rn, $tra
5012
5013 void
5014 sh5_media_sem_ptabs (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5015         sh5_media::write_stacks &buf)
5016 {
5017 #define FLD(f) abuf->fields.sfmt_ptabs.f
5018   sem_status status = SEM_STATUS_NORMAL;
5019   sh5_media_scache* abuf = sem;
5020   unsigned long long written = 0;
5021   PCADDR pc = abuf->addr;
5022   PCADDR npc = pc + 4;
5023
5024 {
5025 current_cpu->save_branch_prediction (FLD (f_tra), FLD (f_likely));
5026   {
5027     DI opval = current_cpu->h_gr_get (FLD (f_right));
5028     if (UNLIKELY(current_cpu->trace_result_p))
5029       current_cpu->trace_stream << "tr" << '[' << FLD (f_tra) << ']' << ":=0x" << hex << opval << dec << "  ";
5030     current_cpu->hardware.h_tr[FLD (f_tra)] = opval;
5031   }
5032 }
5033
5034   current_cpu->done_insn (npc, status);
5035 #undef FLD
5036 }
5037
5038 // ********** ptb: ptb$likely $disp16, $tra
5039
5040 void
5041 sh5_media_sem_ptb (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5042         sh5_media::write_stacks &buf)
5043 {
5044 #define FLD(f) abuf->fields.sfmt_pta.f
5045   sem_status status = SEM_STATUS_NORMAL;
5046   sh5_media_scache* abuf = sem;
5047   unsigned long long written = 0;
5048   PCADDR pc = abuf->addr;
5049   PCADDR npc = pc + 4;
5050
5051 {
5052 current_cpu->save_branch_prediction (FLD (f_tra), FLD (f_likely));
5053   {
5054     DI opval = FLD (f_disp16);
5055     if (UNLIKELY(current_cpu->trace_result_p))
5056       current_cpu->trace_stream << "tr" << '[' << FLD (f_tra) << ']' << ":=0x" << hex << opval << dec << "  ";
5057     current_cpu->hardware.h_tr[FLD (f_tra)] = opval;
5058   }
5059 }
5060
5061   current_cpu->done_insn (npc, status);
5062 #undef FLD
5063 }
5064
5065 // ********** ptrel: ptrel$likely $rn, $tra
5066
5067 void
5068 sh5_media_sem_ptrel (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5069         sh5_media::write_stacks &buf)
5070 {
5071 #define FLD(f) abuf->fields.sfmt_ptabs.f
5072   sem_status status = SEM_STATUS_NORMAL;
5073   sh5_media_scache* abuf = sem;
5074   unsigned long long written = 0;
5075   PCADDR pc = abuf->addr;
5076   PCADDR npc = pc + 4;
5077
5078 {
5079 current_cpu->save_branch_prediction (FLD (f_tra), FLD (f_likely));
5080   {
5081     DI opval = ADDDI (pc, current_cpu->h_gr_get (FLD (f_right)));
5082     if (UNLIKELY(current_cpu->trace_result_p))
5083       current_cpu->trace_stream << "tr" << '[' << FLD (f_tra) << ']' << ":=0x" << hex << opval << dec << "  ";
5084     current_cpu->hardware.h_tr[FLD (f_tra)] = opval;
5085   }
5086 }
5087
5088   current_cpu->done_insn (npc, status);
5089 #undef FLD
5090 }
5091
5092 // ********** putcfg: putcfg $rm, $disp6, $rd
5093
5094 void
5095 sh5_media_sem_putcfg (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5096         sh5_media::write_stacks &buf)
5097 {
5098 #define FLD(f) abuf->fields.sfmt_putcfg.f
5099   sem_status status = SEM_STATUS_NORMAL;
5100   sh5_media_scache* abuf = sem;
5101   unsigned long long written = 0;
5102   PCADDR pc = abuf->addr;
5103   PCADDR npc = pc + 4;
5104
5105 {
5106   SI tmp_address;
5107   tmp_address = ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp6));
5108 current_cpu->sh64_save_cfg_address (tmp_address);
5109   {
5110     SI opval = current_cpu->h_gr_get (FLD (f_dest));
5111     if (UNLIKELY(current_cpu->trace_result_p))
5112       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_address << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5113     current_cpu->SETMEMSI (pc, tmp_address, opval);
5114   }
5115 }
5116
5117   current_cpu->done_insn (npc, status);
5118 #undef FLD
5119 }
5120
5121 // ********** putcon: putcon $rm, $crj
5122
5123 void
5124 sh5_media_sem_putcon (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5125         sh5_media::write_stacks &buf)
5126 {
5127 #define FLD(f) abuf->fields.sfmt_xori.f
5128   sem_status status = SEM_STATUS_NORMAL;
5129   sh5_media_scache* abuf = sem;
5130   unsigned long long written = 0;
5131   PCADDR pc = abuf->addr;
5132   PCADDR npc = pc + 4;
5133
5134   {
5135     DI opval = current_cpu->h_gr_get (FLD (f_left));
5136     if (UNLIKELY(current_cpu->trace_result_p))
5137       current_cpu->trace_stream << "cr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5138     current_cpu->h_cr_set (FLD (f_dest), opval);
5139   }
5140
5141   current_cpu->done_insn (npc, status);
5142 #undef FLD
5143 }
5144
5145 // ********** rte: rte
5146
5147 void
5148 sh5_media_sem_rte (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5149         sh5_media::write_stacks &buf)
5150 {
5151 #define FLD(f) abuf->fields.fmt_empty.f
5152   sem_status status = SEM_STATUS_NORMAL;
5153   sh5_media_scache* abuf = sem;
5154   unsigned long long written = 0;
5155   PCADDR pc = abuf->addr;
5156   PCADDR npc = pc + 4;
5157
5158 ((void) 0); /*nop*/
5159
5160   current_cpu->done_insn (npc, status);
5161 #undef FLD
5162 }
5163
5164 // ********** shard: shard $rm, $rn, $rd
5165
5166 void
5167 sh5_media_sem_shard (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5168         sh5_media::write_stacks &buf)
5169 {
5170 #define FLD(f) abuf->fields.sfmt_mcmv.f
5171   sem_status status = SEM_STATUS_NORMAL;
5172   sh5_media_scache* abuf = sem;
5173   unsigned long long written = 0;
5174   PCADDR pc = abuf->addr;
5175   PCADDR npc = pc + 4;
5176
5177   {
5178     DI opval = SRADI (current_cpu->h_gr_get (FLD (f_left)), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 63));
5179     if (UNLIKELY(current_cpu->trace_result_p))
5180       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5181     current_cpu->h_gr_set (FLD (f_dest), opval);
5182   }
5183
5184   current_cpu->done_insn (npc, status);
5185 #undef FLD
5186 }
5187
5188 // ********** shardl: shard.l $rm, $rn, $rd
5189
5190 void
5191 sh5_media_sem_shardl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5192         sh5_media::write_stacks &buf)
5193 {
5194 #define FLD(f) abuf->fields.sfmt_mcmv.f
5195   sem_status status = SEM_STATUS_NORMAL;
5196   sh5_media_scache* abuf = sem;
5197   unsigned long long written = 0;
5198   PCADDR pc = abuf->addr;
5199   PCADDR npc = pc + 4;
5200
5201   {
5202     DI opval = EXTSIDI (SRASI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 63)));
5203     if (UNLIKELY(current_cpu->trace_result_p))
5204       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5205     current_cpu->h_gr_set (FLD (f_dest), opval);
5206   }
5207
5208   current_cpu->done_insn (npc, status);
5209 #undef FLD
5210 }
5211
5212 // ********** shari: shari $rm, $uimm6, $rd
5213
5214 void
5215 sh5_media_sem_shari (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5216         sh5_media::write_stacks &buf)
5217 {
5218 #define FLD(f) abuf->fields.sfmt_shari.f
5219   sem_status status = SEM_STATUS_NORMAL;
5220   sh5_media_scache* abuf = sem;
5221   unsigned long long written = 0;
5222   PCADDR pc = abuf->addr;
5223   PCADDR npc = pc + 4;
5224
5225   {
5226     DI opval = SRADI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_uimm6));
5227     if (UNLIKELY(current_cpu->trace_result_p))
5228       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5229     current_cpu->h_gr_set (FLD (f_dest), opval);
5230   }
5231
5232   current_cpu->done_insn (npc, status);
5233 #undef FLD
5234 }
5235
5236 // ********** sharil: shari.l $rm, $uimm6, $rd
5237
5238 void
5239 sh5_media_sem_sharil (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5240         sh5_media::write_stacks &buf)
5241 {
5242 #define FLD(f) abuf->fields.sfmt_shari.f
5243   sem_status status = SEM_STATUS_NORMAL;
5244   sh5_media_scache* abuf = sem;
5245   unsigned long long written = 0;
5246   PCADDR pc = abuf->addr;
5247   PCADDR npc = pc + 4;
5248
5249   {
5250     DI opval = EXTSIDI (SRASI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDSI (FLD (f_uimm6), 63)));
5251     if (UNLIKELY(current_cpu->trace_result_p))
5252       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5253     current_cpu->h_gr_set (FLD (f_dest), opval);
5254   }
5255
5256   current_cpu->done_insn (npc, status);
5257 #undef FLD
5258 }
5259
5260 // ********** shlld: shlld $rm, $rn, $rd
5261
5262 void
5263 sh5_media_sem_shlld (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5264         sh5_media::write_stacks &buf)
5265 {
5266 #define FLD(f) abuf->fields.sfmt_mcmv.f
5267   sem_status status = SEM_STATUS_NORMAL;
5268   sh5_media_scache* abuf = sem;
5269   unsigned long long written = 0;
5270   PCADDR pc = abuf->addr;
5271   PCADDR npc = pc + 4;
5272
5273   {
5274     DI opval = SLLDI (current_cpu->h_gr_get (FLD (f_left)), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 63));
5275     if (UNLIKELY(current_cpu->trace_result_p))
5276       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5277     current_cpu->h_gr_set (FLD (f_dest), opval);
5278   }
5279
5280   current_cpu->done_insn (npc, status);
5281 #undef FLD
5282 }
5283
5284 // ********** shlldl: shlld.l $rm, $rn, $rd
5285
5286 void
5287 sh5_media_sem_shlldl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5288         sh5_media::write_stacks &buf)
5289 {
5290 #define FLD(f) abuf->fields.sfmt_mcmv.f
5291   sem_status status = SEM_STATUS_NORMAL;
5292   sh5_media_scache* abuf = sem;
5293   unsigned long long written = 0;
5294   PCADDR pc = abuf->addr;
5295   PCADDR npc = pc + 4;
5296
5297   {
5298     DI opval = EXTSIDI (SLLSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 63)));
5299     if (UNLIKELY(current_cpu->trace_result_p))
5300       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5301     current_cpu->h_gr_set (FLD (f_dest), opval);
5302   }
5303
5304   current_cpu->done_insn (npc, status);
5305 #undef FLD
5306 }
5307
5308 // ********** shlli: shlli $rm, $uimm6, $rd
5309
5310 void
5311 sh5_media_sem_shlli (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5312         sh5_media::write_stacks &buf)
5313 {
5314 #define FLD(f) abuf->fields.sfmt_shari.f
5315   sem_status status = SEM_STATUS_NORMAL;
5316   sh5_media_scache* abuf = sem;
5317   unsigned long long written = 0;
5318   PCADDR pc = abuf->addr;
5319   PCADDR npc = pc + 4;
5320
5321   {
5322     DI opval = SLLDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_uimm6));
5323     if (UNLIKELY(current_cpu->trace_result_p))
5324       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5325     current_cpu->h_gr_set (FLD (f_dest), opval);
5326   }
5327
5328   current_cpu->done_insn (npc, status);
5329 #undef FLD
5330 }
5331
5332 // ********** shllil: shlli.l $rm, $uimm6, $rd
5333
5334 void
5335 sh5_media_sem_shllil (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5336         sh5_media::write_stacks &buf)
5337 {
5338 #define FLD(f) abuf->fields.sfmt_shari.f
5339   sem_status status = SEM_STATUS_NORMAL;
5340   sh5_media_scache* abuf = sem;
5341   unsigned long long written = 0;
5342   PCADDR pc = abuf->addr;
5343   PCADDR npc = pc + 4;
5344
5345   {
5346     DI opval = EXTSIDI (SLLSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDSI (FLD (f_uimm6), 63)));
5347     if (UNLIKELY(current_cpu->trace_result_p))
5348       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5349     current_cpu->h_gr_set (FLD (f_dest), opval);
5350   }
5351
5352   current_cpu->done_insn (npc, status);
5353 #undef FLD
5354 }
5355
5356 // ********** shlrd: shlrd $rm, $rn, $rd
5357
5358 void
5359 sh5_media_sem_shlrd (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5360         sh5_media::write_stacks &buf)
5361 {
5362 #define FLD(f) abuf->fields.sfmt_mcmv.f
5363   sem_status status = SEM_STATUS_NORMAL;
5364   sh5_media_scache* abuf = sem;
5365   unsigned long long written = 0;
5366   PCADDR pc = abuf->addr;
5367   PCADDR npc = pc + 4;
5368
5369   {
5370     DI opval = SRLDI (current_cpu->h_gr_get (FLD (f_left)), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 63));
5371     if (UNLIKELY(current_cpu->trace_result_p))
5372       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5373     current_cpu->h_gr_set (FLD (f_dest), opval);
5374   }
5375
5376   current_cpu->done_insn (npc, status);
5377 #undef FLD
5378 }
5379
5380 // ********** shlrdl: shlrd.l $rm, $rn, $rd
5381
5382 void
5383 sh5_media_sem_shlrdl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5384         sh5_media::write_stacks &buf)
5385 {
5386 #define FLD(f) abuf->fields.sfmt_mcmv.f
5387   sem_status status = SEM_STATUS_NORMAL;
5388   sh5_media_scache* abuf = sem;
5389   unsigned long long written = 0;
5390   PCADDR pc = abuf->addr;
5391   PCADDR npc = pc + 4;
5392
5393   {
5394     DI opval = EXTSIDI (SRLSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDDI (current_cpu->h_gr_get (FLD (f_right)), 63)));
5395     if (UNLIKELY(current_cpu->trace_result_p))
5396       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5397     current_cpu->h_gr_set (FLD (f_dest), opval);
5398   }
5399
5400   current_cpu->done_insn (npc, status);
5401 #undef FLD
5402 }
5403
5404 // ********** shlri: shlri $rm, $uimm6, $rd
5405
5406 void
5407 sh5_media_sem_shlri (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5408         sh5_media::write_stacks &buf)
5409 {
5410 #define FLD(f) abuf->fields.sfmt_shari.f
5411   sem_status status = SEM_STATUS_NORMAL;
5412   sh5_media_scache* abuf = sem;
5413   unsigned long long written = 0;
5414   PCADDR pc = abuf->addr;
5415   PCADDR npc = pc + 4;
5416
5417   {
5418     DI opval = SRLDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_uimm6));
5419     if (UNLIKELY(current_cpu->trace_result_p))
5420       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5421     current_cpu->h_gr_set (FLD (f_dest), opval);
5422   }
5423
5424   current_cpu->done_insn (npc, status);
5425 #undef FLD
5426 }
5427
5428 // ********** shlril: shlri.l $rm, $uimm6, $rd
5429
5430 void
5431 sh5_media_sem_shlril (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5432         sh5_media::write_stacks &buf)
5433 {
5434 #define FLD(f) abuf->fields.sfmt_shari.f
5435   sem_status status = SEM_STATUS_NORMAL;
5436   sh5_media_scache* abuf = sem;
5437   unsigned long long written = 0;
5438   PCADDR pc = abuf->addr;
5439   PCADDR npc = pc + 4;
5440
5441   {
5442     DI opval = EXTSIDI (SRLSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), ANDSI (FLD (f_uimm6), 63)));
5443     if (UNLIKELY(current_cpu->trace_result_p))
5444       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5445     current_cpu->h_gr_set (FLD (f_dest), opval);
5446   }
5447
5448   current_cpu->done_insn (npc, status);
5449 #undef FLD
5450 }
5451
5452 // ********** shori: shori $uimm16, $rd
5453
5454 void
5455 sh5_media_sem_shori (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5456         sh5_media::write_stacks &buf)
5457 {
5458 #define FLD(f) abuf->fields.sfmt_shori.f
5459   sem_status status = SEM_STATUS_NORMAL;
5460   sh5_media_scache* abuf = sem;
5461   unsigned long long written = 0;
5462   PCADDR pc = abuf->addr;
5463   PCADDR npc = pc + 4;
5464
5465   {
5466     DI opval = ORDI (SLLDI (current_cpu->h_gr_get (FLD (f_dest)), 16), ZEXTSIDI (FLD (f_uimm16)));
5467     if (UNLIKELY(current_cpu->trace_result_p))
5468       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
5469     current_cpu->h_gr_set (FLD (f_dest), opval);
5470   }
5471
5472   current_cpu->done_insn (npc, status);
5473 #undef FLD
5474 }
5475
5476 // ********** sleep: sleep
5477
5478 void
5479 sh5_media_sem_sleep (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5480         sh5_media::write_stacks &buf)
5481 {
5482 #define FLD(f) abuf->fields.fmt_empty.f
5483   sem_status status = SEM_STATUS_NORMAL;
5484   sh5_media_scache* abuf = sem;
5485   unsigned long long written = 0;
5486   PCADDR pc = abuf->addr;
5487   PCADDR npc = pc + 4;
5488
5489 ((void) 0); /*nop*/
5490
5491   current_cpu->done_insn (npc, status);
5492 #undef FLD
5493 }
5494
5495 // ********** stb: st.b $rm, $disp10, $rd
5496
5497 void
5498 sh5_media_sem_stb (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5499         sh5_media::write_stacks &buf)
5500 {
5501 #define FLD(f) abuf->fields.sfmt_stb.f
5502   sem_status status = SEM_STATUS_NORMAL;
5503   sh5_media_scache* abuf = sem;
5504   unsigned long long written = 0;
5505   PCADDR pc = abuf->addr;
5506   PCADDR npc = pc + 4;
5507
5508   {
5509     UQI opval = ANDQI (current_cpu->h_gr_get (FLD (f_dest)), 255);
5510     if (UNLIKELY(current_cpu->trace_result_p))
5511       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10))) << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
5512     current_cpu->SETMEMUQI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10))), opval);
5513   }
5514
5515   current_cpu->done_insn (npc, status);
5516 #undef FLD
5517 }
5518
5519 // ********** stl: st.l $rm, $disp10x4, $rd
5520
5521 void
5522 sh5_media_sem_stl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5523         sh5_media::write_stacks &buf)
5524 {
5525 #define FLD(f) abuf->fields.sfmt_stl.f
5526   sem_status status = SEM_STATUS_NORMAL;
5527   sh5_media_scache* abuf = sem;
5528   unsigned long long written = 0;
5529   PCADDR pc = abuf->addr;
5530   PCADDR npc = pc + 4;
5531
5532   {
5533     SI opval = ANDSI (current_cpu->h_gr_get (FLD (f_dest)), 0xffffffff);
5534     if (UNLIKELY(current_cpu->trace_result_p))
5535       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10x4))) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5536     current_cpu->SETMEMSI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10x4))), opval);
5537   }
5538
5539   current_cpu->done_insn (npc, status);
5540 #undef FLD
5541 }
5542
5543 // ********** stq: st.q $rm, $disp10x8, $rd
5544
5545 void
5546 sh5_media_sem_stq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5547         sh5_media::write_stacks &buf)
5548 {
5549 #define FLD(f) abuf->fields.sfmt_stq.f
5550   sem_status status = SEM_STATUS_NORMAL;
5551   sh5_media_scache* abuf = sem;
5552   unsigned long long written = 0;
5553   PCADDR pc = abuf->addr;
5554   PCADDR npc = pc + 4;
5555
5556   {
5557     DI opval = current_cpu->h_gr_get (FLD (f_dest));
5558     if (UNLIKELY(current_cpu->trace_result_p))
5559       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10x8))) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5560     current_cpu->SETMEMDI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10x8))), opval);
5561   }
5562
5563   current_cpu->done_insn (npc, status);
5564 #undef FLD
5565 }
5566
5567 // ********** stw: st.w $rm, $disp10x2, $rd
5568
5569 void
5570 sh5_media_sem_stw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5571         sh5_media::write_stacks &buf)
5572 {
5573 #define FLD(f) abuf->fields.sfmt_stw.f
5574   sem_status status = SEM_STATUS_NORMAL;
5575   sh5_media_scache* abuf = sem;
5576   unsigned long long written = 0;
5577   PCADDR pc = abuf->addr;
5578   PCADDR npc = pc + 4;
5579
5580   {
5581     HI opval = ANDHI (current_cpu->h_gr_get (FLD (f_dest)), 65535);
5582     if (UNLIKELY(current_cpu->trace_result_p))
5583       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10x2))) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5584     current_cpu->SETMEMHI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_disp10x2))), opval);
5585   }
5586
5587   current_cpu->done_insn (npc, status);
5588 #undef FLD
5589 }
5590
5591 // ********** sthil: sthi.l $rm, $disp6, $rd
5592
5593 void
5594 sh5_media_sem_sthil (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5595         sh5_media::write_stacks &buf)
5596 {
5597 #define FLD(f) abuf->fields.sfmt_putcfg.f
5598   sem_status status = SEM_STATUS_NORMAL;
5599   sh5_media_scache* abuf = sem;
5600   unsigned long long written = 0;
5601   PCADDR pc = abuf->addr;
5602   PCADDR npc = pc + 4;
5603
5604 {
5605   DI tmp_addr;
5606   QI tmp_bytecount;
5607   DI tmp_val;
5608   tmp_addr = ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp6));
5609   tmp_bytecount = ADDDI (ANDDI (tmp_addr, 3), 1);
5610 if (ANDQI (tmp_bytecount, 4)) {
5611   {
5612     SI opval = current_cpu->h_gr_get (FLD (f_dest));
5613     written |= (1ULL << 5);
5614     if (UNLIKELY(current_cpu->trace_result_p))
5615       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (tmp_addr, -4) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5616     current_cpu->SETMEMSI (pc, ANDDI (tmp_addr, -4), opval);
5617   }
5618 } else {
5619 if (current_cpu->h_endian_get ()) {
5620 {
5621   tmp_val = current_cpu->h_gr_get (FLD (f_dest));
5622 if (ANDQI (tmp_bytecount, 1)) {
5623 {
5624   {
5625     UQI opval = ANDQI (tmp_val, 255);
5626     written |= (1ULL << 6);
5627     if (UNLIKELY(current_cpu->trace_result_p))
5628       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
5629     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
5630   }
5631   tmp_val = SRLDI (tmp_val, 8);
5632 }
5633 }
5634 if (ANDQI (tmp_bytecount, 2)) {
5635 {
5636   {
5637     HI opval = ANDHI (tmp_val, 65535);
5638     written |= (1ULL << 4);
5639     if (UNLIKELY(current_cpu->trace_result_p))
5640       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (tmp_addr, -4) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5641     current_cpu->SETMEMHI (pc, ANDDI (tmp_addr, -4), opval);
5642   }
5643   tmp_val = SRLDI (tmp_val, 16);
5644 }
5645 }
5646 }
5647 } else {
5648 {
5649   tmp_val = SRLDI (current_cpu->h_gr_get (FLD (f_dest)), SUBSI (32, MULSI (8, tmp_bytecount)));
5650 if (ANDQI (tmp_bytecount, 2)) {
5651 {
5652   {
5653     HI opval = ANDHI (tmp_val, 65535);
5654     written |= (1ULL << 4);
5655     if (UNLIKELY(current_cpu->trace_result_p))
5656       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (tmp_addr, -4) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5657     current_cpu->SETMEMHI (pc, ANDDI (tmp_addr, -4), opval);
5658   }
5659   tmp_val = SRLDI (tmp_val, 16);
5660 }
5661 }
5662 if (ANDQI (tmp_bytecount, 1)) {
5663 {
5664   {
5665     UQI opval = ANDQI (tmp_val, 255);
5666     written |= (1ULL << 6);
5667     if (UNLIKELY(current_cpu->trace_result_p))
5668       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
5669     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
5670   }
5671   tmp_val = SRLDI (tmp_val, 8);
5672 }
5673 }
5674 }
5675 }
5676 }
5677 }
5678
5679   abuf->written = written;
5680   current_cpu->done_insn (npc, status);
5681 #undef FLD
5682 }
5683
5684 // ********** sthiq: sthi.q $rm, $disp6, $rd
5685
5686 void
5687 sh5_media_sem_sthiq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5688         sh5_media::write_stacks &buf)
5689 {
5690 #define FLD(f) abuf->fields.sfmt_putcfg.f
5691   sem_status status = SEM_STATUS_NORMAL;
5692   sh5_media_scache* abuf = sem;
5693   unsigned long long written = 0;
5694   PCADDR pc = abuf->addr;
5695   PCADDR npc = pc + 4;
5696
5697 {
5698   DI tmp_addr;
5699   QI tmp_bytecount;
5700   DI tmp_val;
5701   tmp_addr = ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp6));
5702   tmp_bytecount = ADDDI (ANDDI (tmp_addr, 7), 1);
5703 if (ANDQI (tmp_bytecount, 8)) {
5704   {
5705     DI opval = current_cpu->h_gr_get (FLD (f_dest));
5706     written |= (1ULL << 4);
5707     if (UNLIKELY(current_cpu->trace_result_p))
5708       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (tmp_addr, -8) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5709     current_cpu->SETMEMDI (pc, ANDDI (tmp_addr, -8), opval);
5710   }
5711 } else {
5712 if (current_cpu->h_endian_get ()) {
5713 {
5714   tmp_val = current_cpu->h_gr_get (FLD (f_dest));
5715 if (ANDQI (tmp_bytecount, 1)) {
5716 {
5717   {
5718     UQI opval = ANDQI (tmp_val, 255);
5719     written |= (1ULL << 7);
5720     if (UNLIKELY(current_cpu->trace_result_p))
5721       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
5722     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
5723   }
5724   tmp_val = SRLDI (tmp_val, 8);
5725 }
5726 }
5727 if (ANDQI (tmp_bytecount, 2)) {
5728 {
5729   {
5730     HI opval = ANDHI (tmp_val, 65535);
5731     written |= (1ULL << 5);
5732     if (UNLIKELY(current_cpu->trace_result_p))
5733       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (tmp_addr, -4) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5734     current_cpu->SETMEMHI (pc, ANDDI (tmp_addr, -4), opval);
5735   }
5736   tmp_val = SRLDI (tmp_val, 16);
5737 }
5738 }
5739 if (ANDQI (tmp_bytecount, 4)) {
5740 {
5741   {
5742     SI opval = ANDSI (tmp_val, 0xffffffff);
5743     written |= (1ULL << 6);
5744     if (UNLIKELY(current_cpu->trace_result_p))
5745       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (tmp_addr, -8) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5746     current_cpu->SETMEMSI (pc, ANDDI (tmp_addr, -8), opval);
5747   }
5748   tmp_val = SRLDI (tmp_val, 32);
5749 }
5750 }
5751 }
5752 } else {
5753 {
5754   tmp_val = SRLDI (current_cpu->h_gr_get (FLD (f_dest)), SUBSI (64, MULSI (8, tmp_bytecount)));
5755 if (ANDQI (tmp_bytecount, 4)) {
5756 {
5757   {
5758     SI opval = ANDSI (tmp_val, 0xffffffff);
5759     written |= (1ULL << 6);
5760     if (UNLIKELY(current_cpu->trace_result_p))
5761       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (tmp_addr, -8) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5762     current_cpu->SETMEMSI (pc, ANDDI (tmp_addr, -8), opval);
5763   }
5764   tmp_val = SRLDI (tmp_val, 32);
5765 }
5766 }
5767 if (ANDQI (tmp_bytecount, 2)) {
5768 {
5769   {
5770     HI opval = ANDHI (tmp_val, 65535);
5771     written |= (1ULL << 5);
5772     if (UNLIKELY(current_cpu->trace_result_p))
5773       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (tmp_addr, -4) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5774     current_cpu->SETMEMHI (pc, ANDDI (tmp_addr, -4), opval);
5775   }
5776   tmp_val = SRLDI (tmp_val, 16);
5777 }
5778 }
5779 if (ANDQI (tmp_bytecount, 1)) {
5780 {
5781   {
5782     UQI opval = ANDQI (tmp_val, 255);
5783     written |= (1ULL << 7);
5784     if (UNLIKELY(current_cpu->trace_result_p))
5785       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
5786     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
5787   }
5788   tmp_val = SRLDI (tmp_val, 8);
5789 }
5790 }
5791 }
5792 }
5793 }
5794 }
5795
5796   abuf->written = written;
5797   current_cpu->done_insn (npc, status);
5798 #undef FLD
5799 }
5800
5801 // ********** stlol: stlo.l $rm, $disp6, $rd
5802
5803 void
5804 sh5_media_sem_stlol (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5805         sh5_media::write_stacks &buf)
5806 {
5807 #define FLD(f) abuf->fields.sfmt_putcfg.f
5808   sem_status status = SEM_STATUS_NORMAL;
5809   sh5_media_scache* abuf = sem;
5810   unsigned long long written = 0;
5811   PCADDR pc = abuf->addr;
5812   PCADDR npc = pc + 4;
5813
5814 {
5815   DI tmp_addr;
5816   QI tmp_bytecount;
5817   DI tmp_val;
5818   tmp_addr = ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp6));
5819   tmp_bytecount = SUBSI (4, ANDDI (tmp_addr, 3));
5820 if (ANDQI (tmp_bytecount, 4)) {
5821   {
5822     USI opval = current_cpu->h_gr_get (FLD (f_dest));
5823     written |= (1ULL << 6);
5824     if (UNLIKELY(current_cpu->trace_result_p))
5825       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5826     current_cpu->SETMEMUSI (pc, tmp_addr, opval);
5827   }
5828 } else {
5829 if (current_cpu->h_endian_get ()) {
5830 {
5831   tmp_val = SRLDI (current_cpu->h_gr_get (FLD (f_dest)), SUBSI (32, MULSI (8, tmp_bytecount)));
5832 if (ANDQI (tmp_bytecount, 2)) {
5833 {
5834   {
5835     UHI opval = ANDHI (tmp_val, 65535);
5836     written |= (1ULL << 4);
5837     if (UNLIKELY(current_cpu->trace_result_p))
5838       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (ADDDI (tmp_addr, 1), -2) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5839     current_cpu->SETMEMUHI (pc, ANDDI (ADDDI (tmp_addr, 1), -2), opval);
5840   }
5841   tmp_val = SRLDI (tmp_val, 16);
5842 }
5843 }
5844 if (ANDQI (tmp_bytecount, 1)) {
5845 {
5846   {
5847     UQI opval = ANDQI (tmp_val, 255);
5848     written |= (1ULL << 5);
5849     if (UNLIKELY(current_cpu->trace_result_p))
5850       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
5851     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
5852   }
5853   tmp_val = SRLDI (tmp_val, 8);
5854 }
5855 }
5856 }
5857 } else {
5858 {
5859   tmp_val = current_cpu->h_gr_get (FLD (f_dest));
5860 if (ANDQI (tmp_bytecount, 1)) {
5861 {
5862   {
5863     UQI opval = ANDQI (tmp_val, 255);
5864     written |= (1ULL << 5);
5865     if (UNLIKELY(current_cpu->trace_result_p))
5866       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
5867     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
5868   }
5869   tmp_val = SRLDI (tmp_val, 8);
5870 }
5871 }
5872 if (ANDQI (tmp_bytecount, 2)) {
5873 {
5874   {
5875     UHI opval = ANDHI (tmp_val, 65535);
5876     written |= (1ULL << 4);
5877     if (UNLIKELY(current_cpu->trace_result_p))
5878       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (ADDDI (tmp_addr, 1), -2) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5879     current_cpu->SETMEMUHI (pc, ANDDI (ADDDI (tmp_addr, 1), -2), opval);
5880   }
5881   tmp_val = SRLDI (tmp_val, 16);
5882 }
5883 }
5884 }
5885 }
5886 }
5887 }
5888
5889   abuf->written = written;
5890   current_cpu->done_insn (npc, status);
5891 #undef FLD
5892 }
5893
5894 // ********** stloq: stlo.q $rm, $disp6, $rd
5895
5896 void
5897 sh5_media_sem_stloq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
5898         sh5_media::write_stacks &buf)
5899 {
5900 #define FLD(f) abuf->fields.sfmt_putcfg.f
5901   sem_status status = SEM_STATUS_NORMAL;
5902   sh5_media_scache* abuf = sem;
5903   unsigned long long written = 0;
5904   PCADDR pc = abuf->addr;
5905   PCADDR npc = pc + 4;
5906
5907 {
5908   DI tmp_addr;
5909   QI tmp_bytecount;
5910   DI tmp_val;
5911   tmp_addr = ADDDI (current_cpu->h_gr_get (FLD (f_left)), FLD (f_disp6));
5912   tmp_bytecount = SUBSI (8, ANDDI (tmp_addr, 7));
5913 if (ANDQI (tmp_bytecount, 8)) {
5914   {
5915     UDI opval = current_cpu->h_gr_get (FLD (f_dest));
5916     written |= (1ULL << 4);
5917     if (UNLIKELY(current_cpu->trace_result_p))
5918       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5919     current_cpu->SETMEMUDI (pc, tmp_addr, opval);
5920   }
5921 } else {
5922 if (current_cpu->h_endian_get ()) {
5923 {
5924   tmp_val = SRLDI (current_cpu->h_gr_get (FLD (f_dest)), SUBSI (64, MULSI (8, tmp_bytecount)));
5925 if (ANDQI (tmp_bytecount, 4)) {
5926 {
5927   {
5928     USI opval = ANDSI (tmp_val, 0xffffffff);
5929     written |= (1ULL << 7);
5930     if (UNLIKELY(current_cpu->trace_result_p))
5931       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (ADDDI (tmp_addr, 3), -4) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5932     current_cpu->SETMEMUSI (pc, ANDDI (ADDDI (tmp_addr, 3), -4), opval);
5933   }
5934   tmp_val = SRLDI (tmp_val, 32);
5935 }
5936 }
5937 if (ANDQI (tmp_bytecount, 2)) {
5938 {
5939   {
5940     UHI opval = ANDHI (tmp_val, 65535);
5941     written |= (1ULL << 5);
5942     if (UNLIKELY(current_cpu->trace_result_p))
5943       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (ADDDI (tmp_addr, 1), -2) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5944     current_cpu->SETMEMUHI (pc, ANDDI (ADDDI (tmp_addr, 1), -2), opval);
5945   }
5946   tmp_val = SRLDI (tmp_val, 16);
5947 }
5948 }
5949 if (ANDQI (tmp_bytecount, 1)) {
5950 {
5951   {
5952     UQI opval = ANDQI (tmp_val, 255);
5953     written |= (1ULL << 6);
5954     if (UNLIKELY(current_cpu->trace_result_p))
5955       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
5956     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
5957   }
5958   tmp_val = SRLDI (tmp_val, 8);
5959 }
5960 }
5961 }
5962 } else {
5963 {
5964   tmp_val = current_cpu->h_gr_get (FLD (f_dest));
5965 if (ANDQI (tmp_bytecount, 1)) {
5966 {
5967   {
5968     UQI opval = ANDQI (tmp_val, 255);
5969     written |= (1ULL << 6);
5970     if (UNLIKELY(current_cpu->trace_result_p))
5971       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
5972     current_cpu->SETMEMUQI (pc, tmp_addr, opval);
5973   }
5974   tmp_val = SRLDI (tmp_val, 8);
5975 }
5976 }
5977 if (ANDQI (tmp_bytecount, 2)) {
5978 {
5979   {
5980     UHI opval = ANDHI (tmp_val, 65535);
5981     written |= (1ULL << 5);
5982     if (UNLIKELY(current_cpu->trace_result_p))
5983       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (ADDDI (tmp_addr, 1), -2) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5984     current_cpu->SETMEMUHI (pc, ANDDI (ADDDI (tmp_addr, 1), -2), opval);
5985   }
5986   tmp_val = SRLDI (tmp_val, 16);
5987 }
5988 }
5989 if (ANDQI (tmp_bytecount, 4)) {
5990 {
5991   {
5992     USI opval = ANDSI (tmp_val, 0xffffffff);
5993     written |= (1ULL << 7);
5994     if (UNLIKELY(current_cpu->trace_result_p))
5995       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDDI (ADDDI (tmp_addr, 3), -4) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
5996     current_cpu->SETMEMUSI (pc, ANDDI (ADDDI (tmp_addr, 3), -4), opval);
5997   }
5998   tmp_val = SRLDI (tmp_val, 32);
5999 }
6000 }
6001 }
6002 }
6003 }
6004 }
6005
6006   abuf->written = written;
6007   current_cpu->done_insn (npc, status);
6008 #undef FLD
6009 }
6010
6011 // ********** stxb: stx.b $rm, $rn, $rd
6012
6013 void
6014 sh5_media_sem_stxb (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
6015         sh5_media::write_stacks &buf)
6016 {
6017 #define FLD(f) abuf->fields.sfmt_mcmv.f
6018   sem_status status = SEM_STATUS_NORMAL;
6019   sh5_media_scache* abuf = sem;
6020   unsigned long long written = 0;
6021   PCADDR pc = abuf->addr;
6022   PCADDR npc = pc + 4;
6023
6024   {
6025     UQI opval = SUBWORDDIQI (current_cpu->h_gr_get (FLD (f_dest)), 7);
6026     if (UNLIKELY(current_cpu->trace_result_p))
6027       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))) << dec << ']' << ":=0x" << hex << (USI) opval << dec << "  ";
6028     current_cpu->SETMEMUQI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))), opval);
6029   }
6030
6031   current_cpu->done_insn (npc, status);
6032 #undef FLD
6033 }
6034
6035 // ********** stxl: stx.l $rm, $rn, $rd
6036
6037 void
6038 sh5_media_sem_stxl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
6039         sh5_media::write_stacks &buf)
6040 {
6041 #define FLD(f) abuf->fields.sfmt_mcmv.f
6042   sem_status status = SEM_STATUS_NORMAL;
6043   sh5_media_scache* abuf = sem;
6044   unsigned long long written = 0;
6045   PCADDR pc = abuf->addr;
6046   PCADDR npc = pc + 4;
6047
6048   {
6049     SI opval = SUBWORDDISI (current_cpu->h_gr_get (FLD (f_dest)), 1);
6050     if (UNLIKELY(current_cpu->trace_result_p))
6051       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
6052     current_cpu->SETMEMSI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))), opval);
6053   }
6054
6055   current_cpu->done_insn (npc, status);
6056 #undef FLD
6057 }
6058
6059 // ********** stxq: stx.q $rm, $rn, $rd
6060
6061 void
6062 sh5_media_sem_stxq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
6063         sh5_media::write_stacks &buf)
6064 {
6065 #define FLD(f) abuf->fields.sfmt_mcmv.f
6066   sem_status status = SEM_STATUS_NORMAL;
6067   sh5_media_scache* abuf = sem;
6068   unsigned long long written = 0;
6069   PCADDR pc = abuf->addr;
6070   PCADDR npc = pc + 4;
6071
6072   {
6073     DI opval = current_cpu->h_gr_get (FLD (f_dest));
6074     if (UNLIKELY(current_cpu->trace_result_p))
6075       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
6076     current_cpu->SETMEMDI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))), opval);
6077   }
6078
6079   current_cpu->done_insn (npc, status);
6080 #undef FLD
6081 }
6082
6083 // ********** stxw: stx.w $rm, $rn, $rd
6084
6085 void
6086 sh5_media_sem_stxw (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
6087         sh5_media::write_stacks &buf)
6088 {
6089 #define FLD(f) abuf->fields.sfmt_mcmv.f
6090   sem_status status = SEM_STATUS_NORMAL;
6091   sh5_media_scache* abuf = sem;
6092   unsigned long long written = 0;
6093   PCADDR pc = abuf->addr;
6094   PCADDR npc = pc + 4;
6095
6096   {
6097     HI opval = SUBWORDDIHI (current_cpu->h_gr_get (FLD (f_dest)), 3);
6098     if (UNLIKELY(current_cpu->trace_result_p))
6099       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
6100     current_cpu->SETMEMHI (pc, ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right))), opval);
6101   }
6102
6103   current_cpu->done_insn (npc, status);
6104 #undef FLD
6105 }
6106
6107 // ********** sub: sub $rm, $rn, $rd
6108
6109 void
6110 sh5_media_sem_sub (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
6111         sh5_media::write_stacks &buf)
6112 {
6113 #define FLD(f) abuf->fields.sfmt_mcmv.f
6114   sem_status status = SEM_STATUS_NORMAL;
6115   sh5_media_scache* abuf = sem;
6116   unsigned long long written = 0;
6117   PCADDR pc = abuf->addr;
6118   PCADDR npc = pc + 4;
6119
6120   {
6121     DI opval = SUBDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)));
6122     if (UNLIKELY(current_cpu->trace_result_p))
6123       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
6124     current_cpu->h_gr_set (FLD (f_dest), opval);
6125   }
6126
6127   current_cpu->done_insn (npc, status);
6128 #undef FLD
6129 }
6130
6131 // ********** subl: sub.l $rm, $rn, $rd
6132
6133 void
6134 sh5_media_sem_subl (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
6135         sh5_media::write_stacks &buf)
6136 {
6137 #define FLD(f) abuf->fields.sfmt_mcmv.f
6138   sem_status status = SEM_STATUS_NORMAL;
6139   sh5_media_scache* abuf = sem;
6140   unsigned long long written = 0;
6141   PCADDR pc = abuf->addr;
6142   PCADDR npc = pc + 4;
6143
6144   {
6145     DI opval = EXTSIDI (SUBSI (SUBWORDDISI (current_cpu->h_gr_get (FLD (f_left)), 1), SUBWORDDISI (current_cpu->h_gr_get (FLD (f_right)), 1)));
6146     if (UNLIKELY(current_cpu->trace_result_p))
6147       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
6148     current_cpu->h_gr_set (FLD (f_dest), opval);
6149   }
6150
6151   current_cpu->done_insn (npc, status);
6152 #undef FLD
6153 }
6154
6155 // ********** swapq: swap.q $rm, $rn, $rd
6156
6157 void
6158 sh5_media_sem_swapq (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
6159         sh5_media::write_stacks &buf)
6160 {
6161 #define FLD(f) abuf->fields.sfmt_mcmv.f
6162   sem_status status = SEM_STATUS_NORMAL;
6163   sh5_media_scache* abuf = sem;
6164   unsigned long long written = 0;
6165   PCADDR pc = abuf->addr;
6166   PCADDR npc = pc + 4;
6167
6168 {
6169   DI tmp_addr;
6170   DI tmp_temp;
6171   tmp_addr = ADDDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)));
6172   tmp_temp = current_cpu->GETMEMDI (pc, tmp_addr);
6173   {
6174     DI opval = current_cpu->h_gr_get (FLD (f_dest));
6175     if (UNLIKELY(current_cpu->trace_result_p))
6176       current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_addr << dec << ']' << ":=0x" << hex << opval << dec << "  ";
6177     current_cpu->SETMEMDI (pc, tmp_addr, opval);
6178   }
6179   {
6180     DI opval = tmp_temp;
6181     if (UNLIKELY(current_cpu->trace_result_p))
6182       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
6183     current_cpu->h_gr_set (FLD (f_dest), opval);
6184   }
6185 }
6186
6187   current_cpu->done_insn (npc, status);
6188 #undef FLD
6189 }
6190
6191 // ********** synci: synci
6192
6193 void
6194 sh5_media_sem_synci (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
6195         sh5_media::write_stacks &buf)
6196 {
6197 #define FLD(f) abuf->fields.fmt_empty.f
6198   sem_status status = SEM_STATUS_NORMAL;
6199   sh5_media_scache* abuf = sem;
6200   unsigned long long written = 0;
6201   PCADDR pc = abuf->addr;
6202   PCADDR npc = pc + 4;
6203
6204 ((void) 0); /*nop*/
6205
6206   current_cpu->done_insn (npc, status);
6207 #undef FLD
6208 }
6209
6210 // ********** synco: synco
6211
6212 void
6213 sh5_media_sem_synco (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
6214         sh5_media::write_stacks &buf)
6215 {
6216 #define FLD(f) abuf->fields.fmt_empty.f
6217   sem_status status = SEM_STATUS_NORMAL;
6218   sh5_media_scache* abuf = sem;
6219   unsigned long long written = 0;
6220   PCADDR pc = abuf->addr;
6221   PCADDR npc = pc + 4;
6222
6223 ((void) 0); /*nop*/
6224
6225   current_cpu->done_insn (npc, status);
6226 #undef FLD
6227 }
6228
6229 // ********** trapa: trapa $rm
6230
6231 void
6232 sh5_media_sem_trapa (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
6233         sh5_media::write_stacks &buf)
6234 {
6235 #define FLD(f) abuf->fields.sfmt_alloco.f
6236   sem_status status = SEM_STATUS_NORMAL;
6237   sh5_media_scache* abuf = sem;
6238   unsigned long long written = 0;
6239   PCADDR pc = abuf->addr;
6240   PCADDR npc = pc + 4;
6241
6242 current_cpu->sh64_trapa (current_cpu->h_gr_get (FLD (f_left)), pc);
6243
6244   current_cpu->done_insn (npc, status);
6245 #undef FLD
6246 }
6247
6248 // ********** xor: xor $rm, $rn, $rd
6249
6250 void
6251 sh5_media_sem_xor (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
6252         sh5_media::write_stacks &buf)
6253 {
6254 #define FLD(f) abuf->fields.sfmt_mcmv.f
6255   sem_status status = SEM_STATUS_NORMAL;
6256   sh5_media_scache* abuf = sem;
6257   unsigned long long written = 0;
6258   PCADDR pc = abuf->addr;
6259   PCADDR npc = pc + 4;
6260
6261   {
6262     DI opval = XORDI (current_cpu->h_gr_get (FLD (f_left)), current_cpu->h_gr_get (FLD (f_right)));
6263     if (UNLIKELY(current_cpu->trace_result_p))
6264       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
6265     current_cpu->h_gr_set (FLD (f_dest), opval);
6266   }
6267
6268   current_cpu->done_insn (npc, status);
6269 #undef FLD
6270 }
6271
6272 // ********** xori: xori $rm, $imm6, $rd
6273
6274 void
6275 sh5_media_sem_xori (sh5_cpu* current_cpu, sh5_media_scache* sem, const int tick, 
6276         sh5_media::write_stacks &buf)
6277 {
6278 #define FLD(f) abuf->fields.sfmt_xori.f
6279   sem_status status = SEM_STATUS_NORMAL;
6280   sh5_media_scache* abuf = sem;
6281   unsigned long long written = 0;
6282   PCADDR pc = abuf->addr;
6283   PCADDR npc = pc + 4;
6284
6285   {
6286     DI opval = XORDI (current_cpu->h_gr_get (FLD (f_left)), EXTSIDI (FLD (f_imm6)));
6287     if (UNLIKELY(current_cpu->trace_result_p))
6288       current_cpu->trace_stream << "gr" << '[' << FLD (f_dest) << ']' << ":=0x" << hex << opval << dec << "  ";
6289     current_cpu->h_gr_set (FLD (f_dest), opval);
6290   }
6291
6292   current_cpu->done_insn (npc, status);
6293 #undef FLD
6294 }
6295