1 |
/* |
/* |
2 |
* Copyright (C) 2005-2006 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2007 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_sh.c,v 1.53 2006/10/31 11:07:05 debug Exp $ |
* $Id: cpu_sh.c,v 1.66 2007/04/13 07:06:31 debug Exp $ |
29 |
* |
* |
30 |
* Hitachi SuperH ("SH") CPU emulation. |
* Hitachi SuperH ("SH") CPU emulation. |
31 |
* |
* |
42 |
#include "cpu.h" |
#include "cpu.h" |
43 |
#include "device.h" |
#include "device.h" |
44 |
#include "float_emul.h" |
#include "float_emul.h" |
45 |
|
#include "interrupt.h" |
46 |
#include "machine.h" |
#include "machine.h" |
47 |
#include "memory.h" |
#include "memory.h" |
48 |
#include "misc.h" |
#include "misc.h" |
133 |
CPU_SETTINGS_ADD_REGISTER32("gbr", cpu->cd.sh.gbr); |
CPU_SETTINGS_ADD_REGISTER32("gbr", cpu->cd.sh.gbr); |
134 |
CPU_SETTINGS_ADD_REGISTER32("macl", cpu->cd.sh.macl); |
CPU_SETTINGS_ADD_REGISTER32("macl", cpu->cd.sh.macl); |
135 |
CPU_SETTINGS_ADD_REGISTER32("mach", cpu->cd.sh.mach); |
CPU_SETTINGS_ADD_REGISTER32("mach", cpu->cd.sh.mach); |
136 |
|
CPU_SETTINGS_ADD_REGISTER32("expevt", cpu->cd.sh.expevt); |
137 |
|
CPU_SETTINGS_ADD_REGISTER32("intevt", cpu->cd.sh.intevt); |
138 |
|
CPU_SETTINGS_ADD_REGISTER32("tra", cpu->cd.sh.tra); |
139 |
CPU_SETTINGS_ADD_REGISTER32("fpscr", cpu->cd.sh.fpscr); |
CPU_SETTINGS_ADD_REGISTER32("fpscr", cpu->cd.sh.fpscr); |
140 |
CPU_SETTINGS_ADD_REGISTER32("fpul", cpu->cd.sh.fpul); |
CPU_SETTINGS_ADD_REGISTER32("fpul", cpu->cd.sh.fpul); |
141 |
for (i=0; i<SH_N_GPRS; i++) { |
for (i=0; i<SH_N_GPRS; i++) { |
170 |
CPU_SETTINGS_ADD_REGISTER32(tmpstr, cpu->cd.sh.utlb_lo[i]); |
CPU_SETTINGS_ADD_REGISTER32(tmpstr, cpu->cd.sh.utlb_lo[i]); |
171 |
} |
} |
172 |
|
|
173 |
|
/* Register the CPU's interrupts: */ |
174 |
|
for (i=SH_INTEVT_NMI; i<0x1000; i+=0x20) { |
175 |
|
struct interrupt template; |
176 |
|
char name[100]; |
177 |
|
snprintf(name, sizeof(name), "%s.irq[0x%x]", cpu->path, i); |
178 |
|
memset(&template, 0, sizeof(template)); |
179 |
|
template.line = i; |
180 |
|
template.name = name; |
181 |
|
template.extra = cpu; |
182 |
|
template.interrupt_assert = sh_cpu_interrupt_assert; |
183 |
|
template.interrupt_deassert = sh_cpu_interrupt_deassert; |
184 |
|
interrupt_handler_register(&template); |
185 |
|
} |
186 |
|
|
187 |
/* SH4-specific memory mapped registers, TLBs, caches, etc: */ |
/* SH4-specific memory mapped registers, TLBs, caches, etc: */ |
188 |
if (cpu->cd.sh.cpu_type.arch == 4) |
if (cpu->cd.sh.cpu_type.arch == 4) { |
189 |
device_add(machine, "sh4"); |
device_add(machine, "sh4"); |
190 |
|
|
191 |
|
/* |
192 |
|
* Interrupt Controller initial values, according to the |
193 |
|
* SH7760 manual: |
194 |
|
*/ |
195 |
|
cpu->cd.sh.intc_iprd = 0xda74; |
196 |
|
cpu->cd.sh.intc_intmsk00 = 0xf3ff7fff; |
197 |
|
cpu->cd.sh.intc_intmsk04 = 0x00ffffff; |
198 |
|
/* All others are zero. */ |
199 |
|
|
200 |
|
/* TODO: Initial priorities? */ |
201 |
|
cpu->cd.sh.intc_intpri00 = 0x33333333; |
202 |
|
cpu->cd.sh.intc_intpri04 = 0x33333333; |
203 |
|
cpu->cd.sh.intc_intpri08 = 0x33333333; |
204 |
|
cpu->cd.sh.intc_intpri0c = 0x33333333; |
205 |
|
} |
206 |
|
|
207 |
|
sh_update_interrupt_priorities(cpu); |
208 |
|
|
209 |
return 1; |
return 1; |
210 |
} |
} |
211 |
|
|
212 |
|
|
213 |
/* |
/* |
214 |
|
* sh_update_interrupt_priorities(): |
215 |
|
* |
216 |
|
* SH interrupts are a bit complicated; there are several intc registers |
217 |
|
* controlling priorities for various peripherals: |
218 |
|
* |
219 |
|
* Register: Bits 15..12 11..8 7..4 3..0 |
220 |
|
* --------- ----------- ----- ---- ---- |
221 |
|
* ipra TMU0 TMU1 TMU2 Reserved |
222 |
|
* iprb WDT REF Reserved Reserved |
223 |
|
* iprc GPIO DMAC Reserved H-UDI |
224 |
|
* iprd IRL0 IRL1 IRL2 IRL3 |
225 |
|
* |
226 |
|
* Register: 31..28 27..24 23..20 19..16 15..12 11..8 7..4 3..0 |
227 |
|
* --------- ------ ------ ------ ------ ------ ----- ---- ---- |
228 |
|
* intpri00 IRQ4 IRQ5 IRQ6 IRQ7 Rsrvd. Rsrvd. Rsrvd. Reserved |
229 |
|
* intpri04 HCAN2,0 HCAN2,1 SSI(0) SSI(1) HAC(0) HAC(1) I2C(0) I2C(1) |
230 |
|
* intpri08 USB LCDC DMABRG SCIF(0) SCIF(1) SCIF(2) SIM HSPI |
231 |
|
* intpri0c Reserv. Reserv. MMCIF Reserv. MFI Rsrvd. ADC CMT |
232 |
|
*/ |
233 |
|
void sh_update_interrupt_priorities(struct cpu *cpu) |
234 |
|
{ |
235 |
|
int i; |
236 |
|
|
237 |
|
/* |
238 |
|
* Set priorities of known interrupts, without affecting the |
239 |
|
* SH_INT_ASSERTED bit: |
240 |
|
*/ |
241 |
|
|
242 |
|
for (i=SH4_INTEVT_IRQ0; i<=SH4_INTEVT_IRQ14; i+=0x20) { |
243 |
|
cpu->cd.sh.int_prio_and_pending[i/0x20] &= ~SH_INT_PRIO_MASK; |
244 |
|
cpu->cd.sh.int_prio_and_pending[i/0x20] |= (15 - ((i - |
245 |
|
SH4_INTEVT_IRQ0) / 0x20)); |
246 |
|
} |
247 |
|
|
248 |
|
cpu->cd.sh.int_prio_and_pending[SH_INTEVT_TMU0_TUNI0 / 0x20] &= |
249 |
|
~SH_INT_PRIO_MASK; |
250 |
|
cpu->cd.sh.int_prio_and_pending[SH_INTEVT_TMU0_TUNI0 / 0x20] |= |
251 |
|
(cpu->cd.sh.intc_ipra >> 12) & 0xf; |
252 |
|
|
253 |
|
cpu->cd.sh.int_prio_and_pending[SH_INTEVT_TMU1_TUNI1 / 0x20] &= |
254 |
|
~SH_INT_PRIO_MASK; |
255 |
|
cpu->cd.sh.int_prio_and_pending[SH_INTEVT_TMU1_TUNI1 / 0x20] |= |
256 |
|
(cpu->cd.sh.intc_ipra >> 8) & 0xf; |
257 |
|
|
258 |
|
cpu->cd.sh.int_prio_and_pending[SH_INTEVT_TMU2_TUNI2 / 0x20] &= |
259 |
|
~SH_INT_PRIO_MASK; |
260 |
|
cpu->cd.sh.int_prio_and_pending[SH_INTEVT_TMU2_TUNI2 / 0x20] |= |
261 |
|
(cpu->cd.sh.intc_ipra >> 4) & 0xf; |
262 |
|
|
263 |
|
for (i=SH4_INTEVT_SCIF_ERI; i<=SH4_INTEVT_SCIF_TXI; i+=0x20) { |
264 |
|
cpu->cd.sh.int_prio_and_pending[i/0x20] &= ~SH_INT_PRIO_MASK; |
265 |
|
cpu->cd.sh.int_prio_and_pending[i/0x20] |= |
266 |
|
((cpu->cd.sh.intc_intpri08 >> 16) & 0xf); |
267 |
|
} |
268 |
|
} |
269 |
|
|
270 |
|
|
271 |
|
/* |
272 |
|
* sh_cpu_interrupt_assert(): |
273 |
|
*/ |
274 |
|
void sh_cpu_interrupt_assert(struct interrupt *interrupt) |
275 |
|
{ |
276 |
|
struct cpu *cpu = interrupt->extra; |
277 |
|
int irq_nr = interrupt->line; |
278 |
|
int index = irq_nr / 0x20; |
279 |
|
int prio; |
280 |
|
|
281 |
|
/* Assert the interrupt, and check its priority level: */ |
282 |
|
cpu->cd.sh.int_prio_and_pending[index] |= SH_INT_ASSERTED; |
283 |
|
prio = cpu->cd.sh.int_prio_and_pending[index] & SH_INT_PRIO_MASK; |
284 |
|
|
285 |
|
if (prio == 0) { |
286 |
|
/* Interrupt not implemented? Hm. */ |
287 |
|
fatal("[ SH interrupt 0x%x, prio 0 (?), aborting ]\n", irq_nr); |
288 |
|
exit(1); |
289 |
|
} |
290 |
|
|
291 |
|
if (cpu->cd.sh.int_to_assert == 0 || prio > cpu->cd.sh.int_level) { |
292 |
|
cpu->cd.sh.int_to_assert = irq_nr; |
293 |
|
cpu->cd.sh.int_level = prio; |
294 |
|
} |
295 |
|
} |
296 |
|
|
297 |
|
|
298 |
|
/* |
299 |
|
* sh_cpu_interrupt_deassert(): |
300 |
|
*/ |
301 |
|
void sh_cpu_interrupt_deassert(struct interrupt *interrupt) |
302 |
|
{ |
303 |
|
struct cpu *cpu = interrupt->extra; |
304 |
|
int irq_nr = interrupt->line; |
305 |
|
int index = irq_nr / 0x20; |
306 |
|
|
307 |
|
/* Deassert the interrupt: */ |
308 |
|
if (cpu->cd.sh.int_prio_and_pending[index] & SH_INT_ASSERTED) { |
309 |
|
cpu->cd.sh.int_prio_and_pending[index] &= ~SH_INT_ASSERTED; |
310 |
|
|
311 |
|
/* Calculate new interrupt assertion: */ |
312 |
|
cpu->cd.sh.int_to_assert = 0; |
313 |
|
cpu->cd.sh.int_level = 0; |
314 |
|
|
315 |
|
/* NOTE/TODO: This is slow, but should hopefully work: */ |
316 |
|
for (index=0; index<0x1000/0x20; index++) { |
317 |
|
uint8_t x = cpu->cd.sh.int_prio_and_pending[index]; |
318 |
|
uint8_t prio = x & SH_INT_PRIO_MASK; |
319 |
|
if (x & SH_INT_ASSERTED && |
320 |
|
prio > cpu->cd.sh.int_level) { |
321 |
|
cpu->cd.sh.int_to_assert = index * 0x20; |
322 |
|
cpu->cd.sh.int_level = prio; |
323 |
|
} |
324 |
|
} |
325 |
|
} |
326 |
|
} |
327 |
|
|
328 |
|
|
329 |
|
/* |
330 |
* sh_cpu_list_available_types(): |
* sh_cpu_list_available_types(): |
331 |
* |
* |
332 |
* Print a list of available SH CPU types. |
* Print a list of available SH CPU types. |
541 |
|
|
542 |
|
|
543 |
/* |
/* |
|
* sh_cpu_gdb_stub(): |
|
|
* |
|
|
* Execute a "remote GDB" command. Returns a newly allocated response string |
|
|
* on success, NULL on failure. |
|
|
*/ |
|
|
char *sh_cpu_gdb_stub(struct cpu *cpu, char *cmd) |
|
|
{ |
|
|
fatal("sh_cpu_gdb_stub(): TODO\n"); |
|
|
return NULL; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* sh_cpu_interrupt(): |
|
|
* |
|
|
* Note: This gives higher interrupt priority to lower number interrupts. |
|
|
* Hopefully this is correct. |
|
|
*/ |
|
|
int sh_cpu_interrupt(struct cpu *cpu, uint64_t irq_nr) |
|
|
{ |
|
|
int word_index, bit_index; |
|
|
|
|
|
if (cpu->cd.sh.int_to_assert == 0 || irq_nr < cpu->cd.sh.int_to_assert) |
|
|
cpu->cd.sh.int_to_assert = irq_nr; |
|
|
|
|
|
/* |
|
|
* TODO: Keep track of all pending interrupts at multiple levels... |
|
|
* |
|
|
* This is just a quick hack: |
|
|
*/ |
|
|
cpu->cd.sh.int_level = 1; |
|
|
if (irq_nr == SH_INTEVT_TMU0_TUNI0) |
|
|
cpu->cd.sh.int_level = (cpu->cd.sh.intc_ipra >> 12) & 0xf; |
|
|
if (irq_nr == SH_INTEVT_TMU1_TUNI1) |
|
|
cpu->cd.sh.int_level = (cpu->cd.sh.intc_ipra >> 8) & 0xf; |
|
|
if (irq_nr == SH_INTEVT_TMU2_TUNI2) |
|
|
cpu->cd.sh.int_level = (cpu->cd.sh.intc_ipra >> 4) & 0xf; |
|
|
if (irq_nr >= SH4_INTEVT_SCIF_ERI && |
|
|
irq_nr <= SH4_INTEVT_SCIF_TXI) |
|
|
cpu->cd.sh.int_level = (cpu->cd.sh.intc_iprc >> 4) & 0xf; |
|
|
|
|
|
irq_nr /= 0x20; |
|
|
word_index = irq_nr / (sizeof(uint32_t)*8); |
|
|
bit_index = irq_nr & ((sizeof(uint32_t)*8) - 1); |
|
|
|
|
|
cpu->cd.sh.int_pending[word_index] |= (1 << bit_index); |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* sh_cpu_interrupt_ack(): |
|
|
*/ |
|
|
int sh_cpu_interrupt_ack(struct cpu *cpu, uint64_t irq_nr) |
|
|
{ |
|
|
int word_index, bit_index; |
|
|
|
|
|
if (cpu->cd.sh.int_to_assert == irq_nr) { |
|
|
/* |
|
|
* Rescan all interrupts to see if any are still asserted. |
|
|
* |
|
|
* Note: The scan only has to go from irq_nr + 0x20 to the max |
|
|
* index, since any lower interrupt cannot be asserted |
|
|
* at this time. |
|
|
*/ |
|
|
int i, max = 0x1000; |
|
|
cpu->cd.sh.int_to_assert = 0; |
|
|
|
|
|
for (i=irq_nr+0x20; i<max; i+=0x20) { |
|
|
int j = i / 0x20; |
|
|
int word_index = j / (sizeof(uint32_t)*8); |
|
|
int bit_index = j & ((sizeof(uint32_t)*8) - 1); |
|
|
|
|
|
/* Skip entire word if no bits are set: */ |
|
|
if (bit_index == 0 && |
|
|
cpu->cd.sh.int_pending[word_index] == 0) |
|
|
i += (sizeof(uint32_t)*8 - 1) * 0x20; |
|
|
else if (cpu->cd.sh.int_pending[word_index] |
|
|
& (1 << bit_index)) { |
|
|
cpu->cd.sh.int_to_assert = i; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
irq_nr /= 0x20; |
|
|
word_index = irq_nr / (sizeof(uint32_t)*8); |
|
|
bit_index = irq_nr & ((sizeof(uint32_t)*8) - 1); |
|
|
|
|
|
cpu->cd.sh.int_pending[word_index] &= ~(1 << bit_index); |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
544 |
* sh_update_sr(): |
* sh_update_sr(): |
545 |
* |
* |
546 |
* Writes a new value to the status register. |
* Writes a new value to the status register. |
589 |
* |
* |
590 |
* Causes a transfer of control to an exception or interrupt handler. |
* Causes a transfer of control to an exception or interrupt handler. |
591 |
* If intevt > 0, then it is an interrupt, otherwise an exception. |
* If intevt > 0, then it is an interrupt, otherwise an exception. |
592 |
|
* |
593 |
|
* vaddr contains the faulting address, on TLB exceptions. |
594 |
*/ |
*/ |
595 |
void sh_exception(struct cpu *cpu, int expevt, int intevt, uint32_t vaddr) |
void sh_exception(struct cpu *cpu, int expevt, int intevt, uint32_t vaddr) |
596 |
{ |
{ |
602 |
else |
else |
603 |
debug("[ exception 0x%03x", expevt); |
debug("[ exception 0x%03x", expevt); |
604 |
|
|
605 |
debug(", pc=0x%08"PRIx32" ", (uint32_t)vaddr); |
debug(", pc=0x%08"PRIx32" ", (uint32_t)cpu->pc); |
606 |
if (intevt == 0) |
if (intevt == 0) |
607 |
debug("vaddr=0x%08"PRIx32" ", vaddr); |
debug("vaddr=0x%08"PRIx32" ", vaddr); |
608 |
|
|
610 |
} |
} |
611 |
|
|
612 |
if (cpu->cd.sh.sr & SH_SR_BL) { |
if (cpu->cd.sh.sr & SH_SR_BL) { |
613 |
fatal("sh_exception(): BL bit already set. TODO\n"); |
fatal("[ sh_exception(): BL bit already set. ]\n"); |
614 |
|
|
615 |
/* This is actually OK in two cases: a User Break, |
/* This is actually OK in two cases: a User Break, |
616 |
or on NMI interrupts if a special flag is set? */ |
or on NMI interrupts if a special flag is set? */ |
635 |
cpu->pc -= sizeof(uint16_t); |
cpu->pc -= sizeof(uint16_t); |
636 |
} |
} |
637 |
|
|
638 |
/* Stuff common to all exceptions: */ |
|
639 |
|
/* |
640 |
|
* Stuff common to all exceptions: |
641 |
|
*/ |
642 |
|
|
643 |
cpu->cd.sh.spc = cpu->pc; |
cpu->cd.sh.spc = cpu->pc; |
644 |
cpu->cd.sh.ssr = cpu->cd.sh.sr; |
cpu->cd.sh.ssr = cpu->cd.sh.sr; |
645 |
cpu->cd.sh.sgr = cpu->cd.sh.r[15]; |
cpu->cd.sh.sgr = cpu->cd.sh.r[15]; |
646 |
|
|
647 |
if (intevt > 0) { |
if (intevt > 0) { |
648 |
cpu->cd.sh.intevt = intevt; |
cpu->cd.sh.intevt = intevt; |
649 |
expevt = -1; |
expevt = -1; |
650 |
} else |
} else { |
651 |
cpu->cd.sh.expevt = expevt; |
cpu->cd.sh.expevt = expevt; |
652 |
|
} |
653 |
|
|
654 |
sh_update_sr(cpu, cpu->cd.sh.sr | SH_SR_MD | SH_SR_RB | SH_SR_BL); |
sh_update_sr(cpu, cpu->cd.sh.sr | SH_SR_MD | SH_SR_RB | SH_SR_BL); |
655 |
|
|
656 |
/* Most exceptions set PC to VBR + 0x100. */ |
/* Most exceptions set PC to VBR + 0x100. */ |
657 |
cpu->pc = vbr + 0x100; |
cpu->pc = vbr + 0x100; |
658 |
|
|
659 |
|
|
660 |
/* Specific cases: */ |
/* Specific cases: */ |
661 |
switch (expevt) { |
switch (expevt) { |
662 |
|
|
683 |
break; |
break; |
684 |
|
|
685 |
case EXPEVT_TRAPA: |
case EXPEVT_TRAPA: |
686 |
/* Note: The TRA register is already set by the |
/* |
687 |
implementation of the trapa instruction. See |
* Note: The TRA register is already set by the implementation |
688 |
cpu_sh_instr.c. */ |
* of the trapa instruction. See cpu_sh_instr.c for details. |
689 |
|
* Here, spc is incremented, so that a return from the trap |
690 |
|
* handler transfers control to the instruction _following_ |
691 |
|
* the trapa. |
692 |
|
*/ |
693 |
cpu->cd.sh.spc += sizeof(uint16_t); |
cpu->cd.sh.spc += sizeof(uint16_t); |
694 |
break; |
break; |
695 |
|
|
696 |
|
case EXPEVT_RES_INST: |
697 |
|
/* |
698 |
|
* Note: Having this code here makes it possible to catch |
699 |
|
* reserved instructions; during normal instruction execution, |
700 |
|
* these are not very common. |
701 |
|
*/ |
702 |
|
#if 1 |
703 |
|
printf("\nRESERVED SuperH instruction at spc=%08"PRIx32"\n", |
704 |
|
cpu->cd.sh.spc); |
705 |
|
exit(1); |
706 |
|
#else |
707 |
|
break; |
708 |
|
#endif |
709 |
|
|
710 |
|
case EXPEVT_FPU_DISABLE: |
711 |
|
break; |
712 |
|
|
713 |
default:fatal("sh_exception(): exception 0x%x is not yet " |
default:fatal("sh_exception(): exception 0x%x is not yet " |
714 |
"implemented.\n", expevt); |
"implemented.\n", expevt); |
715 |
exit(1); |
exit(1); |
752 |
debug("stc\tsr,r%i\n", r8); |
debug("stc\tsr,r%i\n", r8); |
753 |
else if (lo8 == 0x03) |
else if (lo8 == 0x03) |
754 |
debug("bsrf\tr%i\n", r8); |
debug("bsrf\tr%i\n", r8); |
755 |
else if (lo4 == 0x4) |
else if (lo4 >= 4 && lo4 <= 6) { |
756 |
debug("mov.b\tr%i,@(r0,r%i)\n", r4, r8); |
if (lo4 == 0x4) |
757 |
else if (lo4 == 0x5) |
debug("mov.b\tr%i,@(r0,r%i)", r4, r8); |
758 |
debug("mov.w\tr%i,@(r0,r%i)\n", r4, r8); |
else if (lo4 == 0x5) |
759 |
else if (lo4 == 0x6) |
debug("mov.w\tr%i,@(r0,r%i)", r4, r8); |
760 |
debug("mov.l\tr%i,@(r0,r%i)\n", r4, r8); |
else if (lo4 == 0x6) |
761 |
else if (lo4 == 0x7) |
debug("mov.l\tr%i,@(r0,r%i)", r4, r8); |
762 |
|
if (running) { |
763 |
|
debug("\t; r0+r%i = 0x%08"PRIx32, r8, |
764 |
|
cpu->cd.sh.r[0] + cpu->cd.sh.r[r8]); |
765 |
|
} |
766 |
|
debug("\n"); |
767 |
|
} else if (lo4 == 0x7) |
768 |
debug("mul.l\tr%i,r%i\n", r4, r8); |
debug("mul.l\tr%i,r%i\n", r4, r8); |
769 |
else if (iword == 0x0008) |
else if (iword == 0x0008) |
770 |
debug("clrt\n"); |
debug("clrt\n"); |
774 |
debug("sts\tmach,r%i\n", r8); |
debug("sts\tmach,r%i\n", r8); |
775 |
else if (iword == 0x000b) |
else if (iword == 0x000b) |
776 |
debug("rts\n"); |
debug("rts\n"); |
777 |
else if (lo4 == 0xc) |
else if (lo4 >= 0xc && lo4 <= 0xe) { |
778 |
debug("mov.b\t@(r0,r%i),r%i\n", r4, r8); |
if (lo4 == 0xc) |
779 |
else if (lo4 == 0xd) |
debug("mov.b\t@(r0,r%i),r%i", r4, r8); |
780 |
debug("mov.w\t@(r0,r%i),r%i\n", r4, r8); |
else if (lo4 == 0xd) |
781 |
else if (lo4 == 0xe) |
debug("mov.w\t@(r0,r%i),r%i", r4, r8); |
782 |
debug("mov.l\t@(r0,r%i),r%i\n", r4, r8); |
else if (lo4 == 0xe) |
783 |
else if (lo8 == 0x12) |
debug("mov.l\t@(r0,r%i),r%i", r4, r8); |
784 |
|
if (running) { |
785 |
|
debug("\t; r0+r%i = 0x%08"PRIx32, r4, |
786 |
|
cpu->cd.sh.r[0] + cpu->cd.sh.r[r4]); |
787 |
|
} |
788 |
|
debug("\n"); |
789 |
|
} else if (lo8 == 0x12) |
790 |
debug("stc\tgbr,r%i\n", r8); |
debug("stc\tgbr,r%i\n", r8); |
791 |
else if (iword == 0x0018) |
else if (iword == 0x0018) |
792 |
debug("sett\n"); |
debug("sett\n"); |
838 |
debug("movca.l\tr0,@r%i\n", r8); |
debug("movca.l\tr0,@r%i\n", r8); |
839 |
else if (lo8 == 0xfa) |
else if (lo8 == 0xfa) |
840 |
debug("stc\tdbr,r%i\n", r8); |
debug("stc\tdbr,r%i\n", r8); |
841 |
else if (iword == 0x00ff) |
else if (iword == SH_INVALID_INSTR) |
842 |
debug("gxemul_dreamcast_prom_emul\n"); |
debug("gxemul_dreamcast_prom_emul\n"); |
843 |
else |
else |
844 |
debug("UNIMPLEMENTED hi4=0x%x, lo8=0x%02x\n", hi4, lo8); |
debug("UNIMPLEMENTED hi4=0x%x, lo8=0x%02x\n", hi4, lo8); |
845 |
break; |
break; |
846 |
case 0x1: |
case 0x1: |
847 |
debug("mov.l\tr%i,@(%i,r%i)\n", r4, lo4 * 4, r8); |
debug("mov.l\tr%i,@(%i,r%i)", r4, lo4 * 4, r8); |
848 |
|
if (running) { |
849 |
|
debug("\t; r%i+%i = 0x%08"PRIx32, r8, lo4 * 4, |
850 |
|
cpu->cd.sh.r[r8] + lo4 * 4); |
851 |
|
} |
852 |
|
debug("\n"); |
853 |
break; |
break; |
854 |
case 0x2: |
case 0x2: |
855 |
if (lo4 == 0x0) |
if (lo4 == 0x0) |
1034 |
debug("UNIMPLEMENTED hi4=0x%x, lo8=0x%02x\n", hi4, lo8); |
debug("UNIMPLEMENTED hi4=0x%x, lo8=0x%02x\n", hi4, lo8); |
1035 |
break; |
break; |
1036 |
case 0x5: |
case 0x5: |
1037 |
debug("mov.l\t@(%i,r%i),r%i\n", lo4 * 4, r4, r8); |
debug("mov.l\t@(%i,r%i),r%i", lo4 * 4, r4, r8); |
1038 |
|
if (running) { |
1039 |
|
debug("\t; r%i+%i = 0x%08"PRIx32, r4, lo4 * 4, |
1040 |
|
cpu->cd.sh.r[r4] + lo4 * 4); |
1041 |
|
} |
1042 |
|
debug("\n"); |
1043 |
break; |
break; |
1044 |
case 0x6: |
case 0x6: |
1045 |
if (lo4 == 0x0) |
if (lo4 == 0x0) |
1081 |
debug("add\t#%i,r%i\n", (int8_t)lo8, r8); |
debug("add\t#%i,r%i\n", (int8_t)lo8, r8); |
1082 |
break; |
break; |
1083 |
case 0x8: |
case 0x8: |
1084 |
if (r8 == 0x0) { |
if (r8 == 0 || r8 == 4) { |
1085 |
debug("mov.b\tr0,@(%i,r%i)\n", lo4, r4); |
if (r8 == 0x0) |
1086 |
} else if (r8 == 0x1) { |
debug("mov.b\tr0,@(%i,r%i)", lo4, r4); |
1087 |
debug("mov.w\tr0,@(%i,r%i)\n", lo4 * 2, r4); |
else if (r8 == 0x4) |
1088 |
} else if (r8 == 0x4) { |
debug("mov.b\t@(%i,r%i),r0", lo4, r4); |
1089 |
debug("mov.b\t@(%i,r%i),r0\n", lo4, r4); |
if (running) { |
1090 |
} else if (r8 == 0x5) { |
debug("\t; r%i+%i = 0x%08"PRIx32, r4, lo4, |
1091 |
debug("mov.w\t@(%i,r%i),r0\n", lo4 * 2, r4); |
cpu->cd.sh.r[r4] + lo4); |
1092 |
|
} |
1093 |
|
debug("\n"); |
1094 |
|
} else if (r8 == 1 || r8 == 5) { |
1095 |
|
if (r8 == 0x1) |
1096 |
|
debug("mov.w\tr0,@(%i,r%i)", lo4 * 2, r4); |
1097 |
|
else if (r8 == 0x5) |
1098 |
|
debug("mov.w\t@(%i,r%i),r0", lo4 * 2, r4); |
1099 |
|
if (running) { |
1100 |
|
debug("\t; r%i+%i = 0x%08"PRIx32, r4, lo4 * 2, |
1101 |
|
cpu->cd.sh.r[r4] + lo4 * 2); |
1102 |
|
} |
1103 |
|
debug("\n"); |
1104 |
} else if (r8 == 0x8) { |
} else if (r8 == 0x8) { |
1105 |
debug("cmp/eq\t#%i,r0\n", (int8_t)lo8); |
debug("cmp/eq\t#%i,r0\n", (int8_t)lo8); |
1106 |
} else if (r8 == 0x9 || r8 == 0xb || r8 == 0xd || r8 == 0xf) { |
} else if (r8 == 0x9 || r8 == 0xb || r8 == 0xd || r8 == 0xf) { |