ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/newcpu.cpp
(Generate patch)

Comparing BasiliskII/src/uae_cpu/newcpu.cpp (file contents):
Revision 1.2 by cebix, 1999-10-28T15:33:23Z vs.
Revision 1.8 by gbeauche, 2001-03-20T17:35:46Z

# Line 22 | Line 22 | extern int intlev(void);       // From baisili
22   #include "memory.h"
23   #include "readcpu.h"
24   #include "newcpu.h"
25 #include "compiler.h"
25  
26   int quit_program = 0;
27   int debugging = 0;
# Line 111 | Line 110 | static __inline__ unsigned int cft_map (
110   #endif
111   }
112  
113 < static unsigned long REGPARAM2 op_illg_1 (uae_u32 opcode) REGPARAM;
113 > static void REGPARAM2 op_illg_1 (uae_u32 opcode) REGPARAM;
114  
115 < static unsigned long REGPARAM2 op_illg_1 (uae_u32 opcode)
115 > static void REGPARAM2 op_illg_1 (uae_u32 opcode)
116   {
117      op_illg (cft_map (opcode));
119    return 4;
118   }
119  
120   static void build_cpufunctbl (void)
# Line 184 | Line 182 | void init_m68k (void)
182          for (j = 7 ; j >= 0 ; j--) {
183                  if (i & (1 << j)) break;
184          }
185 <        fpp_movem_index1[i] = j;
186 <        fpp_movem_index2[i] = 7-j;
185 >        fpp_movem_index1[i] = 7-j;
186 >        fpp_movem_index2[i] = j;
187          fpp_movem_next[i] = i & (~(1 << j));
188      }
189   #if COUNT_INSTRS
# Line 208 | Line 206 | void init_m68k (void)
206      do_merges ();
207  
208      build_cpufunctbl ();
209 +    
210 +    fpu_init ();
211 +    fpu_set_integral_fpu (CPUType == 4);
212 + }
213 +
214 + void exit_m68k (void)
215 + {
216 +        fpu_exit ();
217   }
218  
219   struct regstruct regs, lastint_regs;
# Line 216 | Line 222 | static int backup_pointer = 0;
222   static long int m68kpc_offset;
223   int lastint_no;
224  
225 + #if REAL_ADDRESSING || DIRECT_ADDRESSING
226 + #define get_ibyte_1(o) get_byte(get_virtual_address(regs.pc_p) + (o) + 1)
227 + #define get_iword_1(o) get_word(get_virtual_address(regs.pc_p) + (o))
228 + #define get_ilong_1(o) get_long(get_virtual_address(regs.pc_p) + (o))
229 + #else
230   #define get_ibyte_1(o) get_byte(regs.pc + (regs.pc_p - regs.pc_oldp) + (o) + 1)
231   #define get_iword_1(o) get_word(regs.pc + (regs.pc_p - regs.pc_oldp) + (o))
232   #define get_ilong_1(o) get_long(regs.pc + (regs.pc_p - regs.pc_oldp) + (o))
233 + #endif
234  
235   uae_s32 ShowEA (int reg, amodes mode, wordsizes size, char *buf)
236   {
# Line 251 | Line 263 | uae_s32 ShowEA (int reg, amodes mode, wo
263          disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2;
264          addr = m68k_areg(regs,reg) + (uae_s16)disp16;
265          sprintf (buffer,"(A%d,$%04x) == $%08lx", reg, disp16 & 0xffff,
266 <                                        (long unsigned int)addr);
266 >                                        (unsigned long)addr);
267          break;
268       case Ad8r:
269          dp = get_iword_1 (m68kpc_offset); m68kpc_offset += 2;
# Line 284 | Line 296 | uae_s32 ShowEA (int reg, amodes mode, wo
296                      dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W',
297                      1 << ((dp >> 9) & 3),
298                      disp,outer,
299 <                    (long unsigned int)addr);
299 >                    (unsigned long)addr);
300          } else {
301            addr = m68k_areg(regs,reg) + (uae_s32)((uae_s8)disp8) + dispreg;
302            sprintf (buffer,"(A%d, %c%d.%c*%d, $%02x) == $%08lx", reg,
303                 dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W',
304                 1 << ((dp >> 9) & 3), disp8,
305 <               (long unsigned int)addr);
305 >               (unsigned long)addr);
306          }
307          break;
308       case PC16:
309          addr = m68k_getpc () + m68kpc_offset;
310          disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2;
311          addr += (uae_s16)disp16;
312 <        sprintf (buffer,"(PC,$%04x) == $%08lx", disp16 & 0xffff,(long unsigned int)addr);
312 >        sprintf (buffer,"(PC,$%04x) == $%08lx", disp16 & 0xffff,(unsigned long)addr);
313          break;
314       case PC8r:
315          addr = m68k_getpc () + m68kpc_offset;
# Line 331 | Line 343 | uae_s32 ShowEA (int reg, amodes mode, wo
343                      dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W',
344                      1 << ((dp >> 9) & 3),
345                      disp,outer,
346 <                    (long unsigned int)addr);
346 >                    (unsigned long)addr);
347          } else {
348            addr += (uae_s32)((uae_s8)disp8) + dispreg;
349            sprintf (buffer,"(PC, %c%d.%c*%d, $%02x) == $%08lx", dp & 0x8000 ? 'A' : 'D',
350                  (int)r, dp & 0x800 ? 'L' : 'W',  1 << ((dp >> 9) & 3),
351 <                disp8, (long unsigned int)addr);
351 >                disp8, (unsigned long)addr);
352          }
353          break;
354       case absw:
355 <        sprintf (buffer,"$%08lx", (long unsigned int)(uae_s32)(uae_s16)get_iword_1 (m68kpc_offset));
355 >        sprintf (buffer,"$%08lx", (unsigned long)(uae_s32)(uae_s16)get_iword_1 (m68kpc_offset));
356          m68kpc_offset += 2;
357          break;
358       case absl:
359 <        sprintf (buffer,"$%08lx", (long unsigned int)get_ilong_1 (m68kpc_offset));
359 >        sprintf (buffer,"$%08lx", (unsigned long)get_ilong_1 (m68kpc_offset));
360          m68kpc_offset += 4;
361          break;
362       case imm:
# Line 358 | Line 370 | uae_s32 ShowEA (int reg, amodes mode, wo
370              m68kpc_offset += 2;
371              break;
372           case sz_long:
373 <            sprintf (buffer,"#$%08lx", (long unsigned int)(get_ilong_1 (m68kpc_offset)));
373 >            sprintf (buffer,"#$%08lx", (unsigned long)(get_ilong_1 (m68kpc_offset)));
374              m68kpc_offset += 4;
375              break;
376           default:
# Line 378 | Line 390 | uae_s32 ShowEA (int reg, amodes mode, wo
390       case imm2:
391          offset = (uae_s32)get_ilong_1 (m68kpc_offset);
392          m68kpc_offset += 4;
393 <        sprintf (buffer,"#$%08lx", (long unsigned int)offset);
393 >        sprintf (buffer,"#$%08lx", (unsigned long)offset);
394          break;
395       case immi:
396          offset = (uae_s32)(uae_s8)(reg & 0xff);
397 <        sprintf (buffer,"#$%08lx", (long unsigned int)offset);
397 >        sprintf (buffer,"#$%08lx", (unsigned long)offset);
398          break;
399       default:
400          break;
# Line 646 | Line 658 | void MakeFromSR (void)
658  
659   void Exception(int nr, uaecptr oldpc)
660   {
649    compiler_flush_jsr_stack();
661      MakeSR();
662      if (!regs.s) {
663          regs.usp = m68k_areg(regs, 7);
# Line 1048 | Line 1059 | void m68k_reset (void)
1059      regs.spcflags = 0;
1060      regs.intmask = 7;
1061      regs.vbr = regs.sfc = regs.dfc = 0;
1062 <    regs.fpcr = regs.fpsr = regs.fpiar = 0;
1062 >    /* gb-- moved into {fpp,fpu_x86}.cpp::fpu_init()
1063 >    regs.fpcr = regs.fpsr = regs.fpiar = 0; */
1064 >    fpu_reset();
1065   }
1066  
1067 < unsigned long REGPARAM2 op_illg (uae_u32 opcode)
1067 > void REGPARAM2 op_illg (uae_u32 opcode)
1068   {
1069      uaecptr pc = m68k_getpc ();
1070  
1058    compiler_flush_jsr_stack ();
1059
1071          if ((opcode & 0xFF00) == 0x7100) {
1072                  struct M68kRegisters r;
1073                  int i;
# Line 1065 | Line 1076 | unsigned long REGPARAM2 op_illg (uae_u32
1076                  if (opcode == M68K_EXEC_RETURN) {
1077                          regs.spcflags |= SPCFLAG_BRK;
1078                          quit_program = 1;
1079 <                        return 4;
1079 >                        return;
1080                  }
1081  
1082                  // Call EMUL_OP opcode
# Line 1084 | Line 1095 | unsigned long REGPARAM2 op_illg (uae_u32
1095                  MakeFromSR();
1096                  m68k_incpc(2);
1097                  fill_prefetch_0 ();
1098 <                return 4;
1098 >                return;
1099          }
1100  
1101      if ((opcode & 0xF000) == 0xA000) {
1102          Exception(0xA,0);
1103 <        return 4;
1103 >        return;
1104      }
1105  
1106 < printf("Illegal instruction %04x at %08lx\n", opcode, pc);      //!!
1106 > //    write_log ("Illegal instruction: %04x at %08lx\n", opcode, pc);
1107 >
1108      if ((opcode & 0xF000) == 0xF000) {
1109          Exception(0xB,0);
1110 <        return 4;
1110 >        return;
1111      }
1112  
1113      write_log ("Illegal instruction: %04x at %08lx\n", opcode, pc);
1114 +
1115      Exception (4,0);
1103    return 4;
1116   }
1117  
1118   void mmu_op(uae_u32 opcode, uae_u16 extra)
# Line 1156 | Line 1168 | static void do_trace (void)
1168   static int do_specialties (void)
1169   {
1170      /*n_spcinsns++;*/
1159    run_compiled_code();
1171      if (regs.spcflags & SPCFLAG_DOTRACE) {
1172          Exception (9,last_trace_ad);
1173      }
# Line 1195 | Line 1206 | static int do_specialties (void)
1206  
1207   static void m68k_run_1 (void)
1208   {
1209 <    for (;;) {
1210 <        int cycles;
1211 <        uae_u32 opcode = GET_OPCODE;
1212 < #if 0
1213 <        if (get_ilong (0) != do_get_mem_long (&regs.prefetch)) {
1214 <            debugging = 1;
1215 <            return;
1205 <        }
1206 < #endif
1207 <        /* assert (!regs.stopped && !(regs.spcflags & SPCFLAG_STOP)); */
1208 < /*      regs_backup[backup_pointer = (backup_pointer + 1) % 16] = regs;*/
1209 < #if COUNT_INSTRS == 2
1210 <        if (table68k[cft_map (opcode)].handler != -1)
1211 <            instrcount[table68k[cft_map (opcode)].handler]++;
1212 < #elif COUNT_INSTRS == 1
1213 <        instrcount[opcode]++;
1214 < #endif
1215 < #if defined(X86_ASSEMBLYxxx)
1216 <        __asm__ __volatile__("\tcall *%%ebx"
1217 <                             : "=&a" (cycles) : "b" (cpufunctbl[opcode]), "0" (opcode)
1218 <                             : "%edx", "%ecx",
1219 <                             "%esi", "%edi", "%ebp", "memory", "cc");
1220 < #else
1221 <        cycles = (*cpufunctbl[opcode])(opcode);
1222 < #endif
1223 <        /*n_insns++;*/
1224 <        if (regs.spcflags) {
1225 <            if (do_specialties ())
1226 <                return;
1209 >        for (;;) {
1210 >                uae_u32 opcode = GET_OPCODE;
1211 >                (*cpufunctbl[opcode])(opcode);
1212 >                if (regs.spcflags) {
1213 >                        if (do_specialties())
1214 >                                return;
1215 >                }
1216          }
1228    }
1217   }
1218  
1231 #ifdef X86_ASSEMBLYxxx
1232 static __inline__ void m68k_run1 (void)
1233 {
1234    /* Work around compiler bug: GCC doesn't push %ebp in m68k_run_1. */
1235    __asm__ __volatile__ ("pushl %%ebp\n\tcall *%0\n\tpopl %%ebp" : : "r" (m68k_run_1) : "%eax", "%edx", "%ecx", "memory", "cc");
1236 }
1237 #else
1219   #define m68k_run1 m68k_run_1
1239 #endif
1220  
1221   int in_m68k_go = 0;
1222  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines