From aa15fda82ceeac7082ef0354ab3f9f05d954ae38 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 5 Jul 2007 20:28:32 +0000 Subject: [PATCH] cyclone_debug improvements git-svn-id: file:///home/notaz/opt/svn/PicoDrive@182 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/_cyclone_debug.c | 195 ++++++++++++++++++++++++----------------- cpu/musashi/m68k_in.c | 1 + cpu/musashi/m68kcpu.h | 4 + cpu/musashi/m68kopnz.c | 1 + 4 files changed, 121 insertions(+), 80 deletions(-) diff --git a/Pico/_cyclone_debug.c b/Pico/_cyclone_debug.c index b47fccdd..25e94d63 100644 --- a/Pico/_cyclone_debug.c +++ b/Pico/_cyclone_debug.c @@ -1,11 +1,16 @@ #include "PicoInt.h" +// note: set SPLIT_MOVEL_PD to 0 + typedef unsigned char u8; static unsigned int pppc, ops=0; extern unsigned int lastread_a, lastread_d[16], lastwrite_cyc_d[16], lastwrite_mus_d[16]; extern int lrp_cyc, lrp_mus, lwp_cyc, lwp_mus; -unsigned int old_regs[16], old_sr, ppop; +unsigned int old_regs[16], old_sr, ppop, have_illegal = 0; + +#undef dprintf +#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) //static void dumpPCandExit() @@ -15,9 +20,10 @@ void dumpPCandExit() m68k_disassemble(buff, pppc, M68K_CPU_TYPE_68000); dprintf("PC: %06x: %04x: %s", pppc, ppop, buff); + dprintf(" this | prev"); for(i=0; i < 8; i++) dprintf("d%i=%08x, a%i=%08x | d%i=%08x, a%i=%08x", i, PicoCpu.d[i], i, PicoCpu.a[i], i, old_regs[i], i, old_regs[i+8]); - dprintf("SR: %04x | %04x (??s? 0iii 000x nzvc)", CycloneGetSr(&PicoCpu), old_sr); + dprintf("SR: %04x | %04x (??s? 0iii 000x nzvc)", CycloneGetSr(&PicoCpu), old_sr); dprintf("last_read: %08x @ %06x", lastread_d[--lrp_cyc&15], lastread_a); dprintf("ops done: %i", ops); exit(1); @@ -31,99 +37,128 @@ int CM_compareRun(int cyc) lrp_cyc = lrp_mus = 0; - while(cyc > cyc_done) { - pppc = SekPc; - ppop = m68k_read_disassembler_16(pppc); - memcpy(old_regs, PicoCpu.d, 4*16); - old_sr = CycloneGetSr(&PicoCpu); + while(cyc > cyc_done) + { + if (have_illegal && m68k_read_disassembler_16(m68ki_cpu.pc) != 0x4e73) // not rte + { + have_illegal = 0; + m68ki_cpu.pc += 2; + PicoCpu.pc=PicoCpu.checkpc(PicoCpu.pc + 2); + } + // hacks for test_misc2 + if (m68ki_cpu.pc == 0x0002e0 && m68k_read_disassembler_16(m68ki_cpu.pc) == 0x4e73) + { + // get out of "priviledge violation" loop + have_illegal = 1; + //m68ki_cpu.s_flag = SFLAG_SET; + //PicoCpu.srh|=0x20; + } + if (PicoCpu.a[7] < 0x00ff0000 || PicoCpu.a[7] >= 0x01000000) + { + PicoCpu.a[7] = m68ki_cpu.dar[15] = 0xff8000; + } - PicoCpu.cycles=1; + pppc = SekPc; + ppop = m68k_read_disassembler_16(pppc); + memcpy(old_regs, PicoCpu.d, 4*16); + old_sr = CycloneGetSr(&PicoCpu); + + //if (Pico.m.frame_count > 1400) + // dprintf("---"); + { + char buff[128]; + dprintf("---"); + m68k_disassemble(buff, pppc, M68K_CPU_TYPE_68000); + dprintf("PC: %06x: %04x: %s", pppc, ppop, buff); + } + + PicoCpu.cycles=1; CycloneRun(&PicoCpu); - cyc_cyclone=1-PicoCpu.cycles; - cyc_musashi=m68k_execute(1); - - if(cyc_cyclone != cyc_musashi) { - dprintf("cycles: %i vs %i", cyc_cyclone, cyc_musashi); - err=1; - } - - if(lrp_cyc != lrp_mus) { - dprintf("lrp: %i vs %i", lrp_cyc&15, lrp_mus&15); - err=1; - } - - if(lwp_cyc != lwp_mus) { - dprintf("lwp: %i vs %i", lwp_cyc&15, lwp_mus&15); - err=1; - } - - for(i=0; i < 16; i++) { - if(lastwrite_cyc_d[i] != lastwrite_mus_d[i]) { - dprintf("lastwrite: [%i]= %08x vs %08x", i, lastwrite_cyc_d[i], lastwrite_mus_d[i]); - err=1; - break; - } - } - - // compare PC - if( SekPc != (m68ki_cpu.pc&0xffffff) ) { - dprintf("PC: %06x vs %06x", SekPc, m68ki_cpu.pc&0xffffff); - err=1; - } + cyc_cyclone=1-PicoCpu.cycles; + cyc_musashi=m68k_execute(1); + + if(cyc_cyclone != cyc_musashi) { + dprintf("cycles: %i vs %i", cyc_cyclone, cyc_musashi); + err=1; + } + + if(lrp_cyc != lrp_mus) { + dprintf("lrp: %i vs %i", lrp_cyc&15, lrp_mus&15); + err=1; + } + + if(lwp_cyc != lwp_mus) { + dprintf("lwp: %i vs %i", lwp_cyc&15, lwp_mus&15); + err=1; + } + + for(i=0; i < 16; i++) { + if(lastwrite_cyc_d[i] != lastwrite_mus_d[i]) { + dprintf("lastwrite: [%i]= %08x vs %08x", i, lastwrite_cyc_d[i], lastwrite_mus_d[i]); + err=1; + break; + } + } + + // compare PC + m68ki_cpu.pc&=~1; + if( SekPc != (m68ki_cpu.pc&0xffffff) ) { + dprintf("PC: %06x vs %06x", SekPc, m68ki_cpu.pc&0xffffff); + err=1; + } #if 0 - if( SekPc > Pico.romsize || SekPc < 0x200 ) { - dprintf("PC out of bounds: %06x", SekPc); - err=1; - } + if( SekPc > Pico.romsize || SekPc < 0x200 ) { + dprintf("PC out of bounds: %06x", SekPc); + err=1; + } #endif // compare regs - for(i=0; i < 16; i++) { - if(PicoCpu.d[i] != m68ki_cpu.dar[i]) { - str = (i < 8) ? "d" : "a"; - dprintf("reg: %s%i: %08x vs %08x", str, i&7, PicoCpu.d[i], m68ki_cpu.dar[i]); - err=1; - break; - } - } - - // SR - if((CycloneGetSr(&PicoCpu)) != (mu_sr = m68k_get_reg(NULL, M68K_REG_SR))) { - dprintf("SR: %04x vs %04x (??s? 0iii 000x nzvc)", CycloneGetSr(&PicoCpu), mu_sr); - err=1; - } - - // IRQl - if(PicoCpu.irq != (m68ki_cpu.int_level>>8)) { - dprintf("IRQ: %i vs %i", PicoCpu.irq, (m68ki_cpu.int_level>>8)); - err=1; - } - - // OSP/USP - if(PicoCpu.osp != m68ki_cpu.sp[((mu_sr>>11)&4)^4]) { - dprintf("OSP: %06x vs %06x", PicoCpu.osp, m68ki_cpu.sp[0]); - err=1; - } - - // stopped - if((PicoCpu.stopped && !m68ki_cpu.stopped) || (!PicoCpu.stopped && m68ki_cpu.stopped)) { - dprintf("stopped: %i vs %i", PicoCpu.stopped, m68ki_cpu.stopped); - err=1; - } + for(i=0; i < 16; i++) { + if(PicoCpu.d[i] != m68ki_cpu.dar[i]) { + str = (i < 8) ? "d" : "a"; + dprintf("reg: %s%i: %08x vs %08x", str, i&7, PicoCpu.d[i], m68ki_cpu.dar[i]); + err=1; + } + } + + // SR + if((CycloneGetSr(&PicoCpu)) != (mu_sr = m68k_get_reg(NULL, M68K_REG_SR))) { + dprintf("SR: %04x vs %04x (??s? 0iii 000x nzvc)", CycloneGetSr(&PicoCpu), mu_sr); + err=1; + } + + // IRQl + if(PicoCpu.irq != (m68ki_cpu.int_level>>8)) { + dprintf("IRQ: %i vs %i", PicoCpu.irq, (m68ki_cpu.int_level>>8)); + err=1; + } + + // OSP/USP + if(PicoCpu.osp != m68ki_cpu.sp[((mu_sr>>11)&4)^4]) { + dprintf("OSP: %06x vs %06x", PicoCpu.osp, m68ki_cpu.sp[0]); + err=1; + } + + // stopped + if((PicoCpu.stopped && !m68ki_cpu.stopped) || (!PicoCpu.stopped && m68ki_cpu.stopped)) { + dprintf("stopped: %i vs %i", PicoCpu.stopped, m68ki_cpu.stopped); + err=1; + } if(err) dumpPCandExit(); #if 0 m68k_set_reg(M68K_REG_SR, ((mu_sr-1)&~0x2000)|(mu_sr&0x2000)); // broken - CycloneSetSr(&PicoCpu, ((mu_sr-1)&~0x2000)|(mu_sr&0x2000)); + CycloneSetSr(&PicoCpu, ((mu_sr-1)&~0x2000)|(mu_sr&0x2000)); PicoCpu.stopped = m68ki_cpu.stopped = 0; - if(SekPc > 0x400 && (PicoCpu.a[7] < 0xff0000 || PicoCpu.a[7] > 0xffffff)) - PicoCpu.a[7] = m68ki_cpu.dar[15] = 0xff8000; + if(SekPc > 0x400 && (PicoCpu.a[7] < 0xff0000 || PicoCpu.a[7] > 0xffffff)) + PicoCpu.a[7] = m68ki_cpu.dar[15] = 0xff8000; #endif - cyc_done += cyc_cyclone; - ops++; + cyc_done += cyc_cyclone; + ops++; } return cyc_done; diff --git a/cpu/musashi/m68k_in.c b/cpu/musashi/m68k_in.c index 5fa68a9d..bcc56120 100644 --- a/cpu/musashi/m68k_in.c +++ b/cpu/musashi/m68k_in.c @@ -8701,6 +8701,7 @@ M68KMAKE_OP(rol, 32, r, .) *r_dst = res; FLAG_C = (src >> (32 - shift)) << 8; + if (shift == 0) FLAG_C = src << 8; // notaz FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; diff --git a/cpu/musashi/m68kcpu.h b/cpu/musashi/m68kcpu.h index 79a6979c..14bc2e1b 100644 --- a/cpu/musashi/m68kcpu.h +++ b/cpu/musashi/m68kcpu.h @@ -1955,7 +1955,10 @@ void m68ki_exception_interrupt(uint int_level) /* If we are halted, don't do anything */ if(CPU_STOPPED) + { + printf("mu stopped! (%x)\n", CPU_STOPPED); return; + } /* Acknowledge the interrupt */ vector = m68ki_int_ack(int_level); @@ -2012,6 +2015,7 @@ void m68ki_exception_interrupt(uint int_level) /* ASG: Check for interrupts */ INLINE void m68ki_check_interrupts(void) { + //printf("mu level, mask: %04x %04x\n", CPU_INT_LEVEL, FLAG_INT_MASK); if(CPU_INT_LEVEL > FLAG_INT_MASK) m68ki_exception_interrupt(CPU_INT_LEVEL>>8); } diff --git a/cpu/musashi/m68kopnz.c b/cpu/musashi/m68kopnz.c index cda7939a..3c774ed2 100644 --- a/cpu/musashi/m68kopnz.c +++ b/cpu/musashi/m68kopnz.c @@ -3181,6 +3181,7 @@ void m68k_op_rol_32_r(void) *r_dst = res; FLAG_C = (src >> (32 - shift)) << 8; + if (shift == 0) FLAG_C = src << 8; // notaz FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; -- 2.39.5