--- BasiliskII/src/uae_cpu/newcpu.cpp 1999/10/28 16:00:28 1.3 +++ BasiliskII/src/uae_cpu/newcpu.cpp 2000/09/05 16:53:19 1.6 @@ -111,12 +111,11 @@ static __inline__ unsigned int cft_map ( #endif } -static unsigned long REGPARAM2 op_illg_1 (uae_u32 opcode) REGPARAM; +static void REGPARAM2 op_illg_1 (uae_u32 opcode) REGPARAM; -static unsigned long REGPARAM2 op_illg_1 (uae_u32 opcode) +static void REGPARAM2 op_illg_1 (uae_u32 opcode) { op_illg (cft_map (opcode)); - return 4; } static void build_cpufunctbl (void) @@ -184,8 +183,8 @@ void init_m68k (void) for (j = 7 ; j >= 0 ; j--) { if (i & (1 << j)) break; } - fpp_movem_index1[i] = j; - fpp_movem_index2[i] = 7-j; + fpp_movem_index1[i] = 7-j; + fpp_movem_index2[i] = j; fpp_movem_next[i] = i & (~(1 << j)); } #if COUNT_INSTRS @@ -208,6 +207,14 @@ void init_m68k (void) do_merges (); build_cpufunctbl (); + + fpu_init (); + fpu_set_integral_fpu (CPUType == 4); +} + +void exit_m68k (void) +{ + fpu_exit (); } struct regstruct regs, lastint_regs; @@ -251,7 +258,7 @@ uae_s32 ShowEA (int reg, amodes mode, wo disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; addr = m68k_areg(regs,reg) + (uae_s16)disp16; sprintf (buffer,"(A%d,$%04x) == $%08lx", reg, disp16 & 0xffff, - (long unsigned int)addr); + (unsigned long)addr); break; case Ad8r: dp = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; @@ -284,20 +291,20 @@ uae_s32 ShowEA (int reg, amodes mode, wo dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W', 1 << ((dp >> 9) & 3), disp,outer, - (long unsigned int)addr); + (unsigned long)addr); } else { addr = m68k_areg(regs,reg) + (uae_s32)((uae_s8)disp8) + dispreg; sprintf (buffer,"(A%d, %c%d.%c*%d, $%02x) == $%08lx", reg, dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W', 1 << ((dp >> 9) & 3), disp8, - (long unsigned int)addr); + (unsigned long)addr); } break; case PC16: addr = m68k_getpc () + m68kpc_offset; disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2; addr += (uae_s16)disp16; - sprintf (buffer,"(PC,$%04x) == $%08lx", disp16 & 0xffff,(long unsigned int)addr); + sprintf (buffer,"(PC,$%04x) == $%08lx", disp16 & 0xffff,(unsigned long)addr); break; case PC8r: addr = m68k_getpc () + m68kpc_offset; @@ -331,20 +338,20 @@ uae_s32 ShowEA (int reg, amodes mode, wo dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W', 1 << ((dp >> 9) & 3), disp,outer, - (long unsigned int)addr); + (unsigned long)addr); } else { addr += (uae_s32)((uae_s8)disp8) + dispreg; sprintf (buffer,"(PC, %c%d.%c*%d, $%02x) == $%08lx", dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W', 1 << ((dp >> 9) & 3), - disp8, (long unsigned int)addr); + disp8, (unsigned long)addr); } break; case absw: - sprintf (buffer,"$%08lx", (long unsigned int)(uae_s32)(uae_s16)get_iword_1 (m68kpc_offset)); + sprintf (buffer,"$%08lx", (unsigned long)(uae_s32)(uae_s16)get_iword_1 (m68kpc_offset)); m68kpc_offset += 2; break; case absl: - sprintf (buffer,"$%08lx", (long unsigned int)get_ilong_1 (m68kpc_offset)); + sprintf (buffer,"$%08lx", (unsigned long)get_ilong_1 (m68kpc_offset)); m68kpc_offset += 4; break; case imm: @@ -358,7 +365,7 @@ uae_s32 ShowEA (int reg, amodes mode, wo m68kpc_offset += 2; break; case sz_long: - sprintf (buffer,"#$%08lx", (long unsigned int)(get_ilong_1 (m68kpc_offset))); + sprintf (buffer,"#$%08lx", (unsigned long)(get_ilong_1 (m68kpc_offset))); m68kpc_offset += 4; break; default: @@ -378,11 +385,11 @@ uae_s32 ShowEA (int reg, amodes mode, wo case imm2: offset = (uae_s32)get_ilong_1 (m68kpc_offset); m68kpc_offset += 4; - sprintf (buffer,"#$%08lx", (long unsigned int)offset); + sprintf (buffer,"#$%08lx", (unsigned long)offset); break; case immi: offset = (uae_s32)(uae_s8)(reg & 0xff); - sprintf (buffer,"#$%08lx", (long unsigned int)offset); + sprintf (buffer,"#$%08lx", (unsigned long)offset); break; default: break; @@ -1048,10 +1055,12 @@ void m68k_reset (void) regs.spcflags = 0; regs.intmask = 7; regs.vbr = regs.sfc = regs.dfc = 0; - regs.fpcr = regs.fpsr = regs.fpiar = 0; + /* gb-- moved into {fpp,fpu_x86}.cpp::fpu_init() + regs.fpcr = regs.fpsr = regs.fpiar = 0; */ + fpu_reset(); } -unsigned long REGPARAM2 op_illg (uae_u32 opcode) +void REGPARAM2 op_illg (uae_u32 opcode) { uaecptr pc = m68k_getpc (); @@ -1065,7 +1074,7 @@ unsigned long REGPARAM2 op_illg (uae_u32 if (opcode == M68K_EXEC_RETURN) { regs.spcflags |= SPCFLAG_BRK; quit_program = 1; - return 4; + return; } // Call EMUL_OP opcode @@ -1084,23 +1093,24 @@ unsigned long REGPARAM2 op_illg (uae_u32 MakeFromSR(); m68k_incpc(2); fill_prefetch_0 (); - return 4; + return; } if ((opcode & 0xF000) == 0xA000) { Exception(0xA,0); - return 4; + return; } - write_log ("Illegal instruction: %04x at %08lx\n", opcode, pc); +// write_log ("Illegal instruction: %04x at %08lx\n", opcode, pc); if ((opcode & 0xF000) == 0xF000) { Exception(0xB,0); - return 4; + return; } + write_log ("Illegal instruction: %04x at %08lx\n", opcode, pc); + Exception (4,0); - return 4; } void mmu_op(uae_u32 opcode, uae_u16 extra) @@ -1195,48 +1205,17 @@ static int do_specialties (void) static void m68k_run_1 (void) { - for (;;) { - int cycles; - uae_u32 opcode = GET_OPCODE; -#if 0 - if (get_ilong (0) != do_get_mem_long (®s.prefetch)) { - debugging = 1; - return; - } -#endif - /* assert (!regs.stopped && !(regs.spcflags & SPCFLAG_STOP)); */ -/* regs_backup[backup_pointer = (backup_pointer + 1) % 16] = regs;*/ -#if COUNT_INSTRS == 2 - if (table68k[cft_map (opcode)].handler != -1) - instrcount[table68k[cft_map (opcode)].handler]++; -#elif COUNT_INSTRS == 1 - instrcount[opcode]++; -#endif -#if defined(X86_ASSEMBLYxxx) - __asm__ __volatile__("\tcall *%%ebx" - : "=&a" (cycles) : "b" (cpufunctbl[opcode]), "0" (opcode) - : "%edx", "%ecx", - "%esi", "%edi", "%ebp", "memory", "cc"); -#else - cycles = (*cpufunctbl[opcode])(opcode); -#endif - /*n_insns++;*/ - if (regs.spcflags) { - if (do_specialties ()) - return; + for (;;) { + uae_u32 opcode = GET_OPCODE; + (*cpufunctbl[opcode])(opcode); + if (regs.spcflags) { + if (do_specialties()) + return; + } } - } } -#ifdef X86_ASSEMBLYxxx -static __inline__ void m68k_run1 (void) -{ - /* Work around compiler bug: GCC doesn't push %ebp in m68k_run_1. */ - __asm__ __volatile__ ("pushl %%ebp\n\tcall *%0\n\tpopl %%ebp" : : "r" (m68k_run_1) : "%eax", "%edx", "%ecx", "memory", "cc"); -} -#else #define m68k_run1 m68k_run_1 -#endif int in_m68k_go = 0;