OSDN Git Service

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