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.6 by gbeauche, 2000-09-05T16:53:19Z vs.
Revision 1.23 by gbeauche, 2007-06-15T08:10:48Z

# 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 > #include "compiler/compemu.h"
26 > #include "fpu/fpu.h"
27  
28 < int quit_program = 0;
29 < int debugging = 0;
28 > #if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS)
29 > B2_mutex *spcflags_lock = NULL;
30 > #endif
31 >
32 > #if ENABLE_MON
33 > #include "mon.h"
34 > #include "mon_disass.h"
35 > #endif
36 >
37 > bool quit_program = false;
38   struct flag_struct regflags;
39  
40   /* Opcode of faulting instruction */
# Line 42 | Line 51 | int movem_index1[256];
51   int movem_index2[256];
52   int movem_next[256];
53  
45 int fpp_movem_index1[256];
46 int fpp_movem_index2[256];
47 int fpp_movem_next[256];
48
54   cpuop_func *cpufunctbl[65536];
55  
56 + #if FLIGHT_RECORDER
57 + struct rec_step {
58 +        uae_u32 pc;
59 + #if FLIGHT_RECORDER >= 2
60 +        uae_u32 d[8];
61 +        uae_u32 a[8];
62 + #endif
63 + };
64 +
65 + const int LOG_SIZE = 32768;
66 + static rec_step log[LOG_SIZE];
67 + static int log_ptr = -1; // First time initialization
68 +
69 + static const char *log_filename(void)
70 + {
71 +        const char *name = getenv("M68K_LOG_FILE");
72 +        return name ? name : "log.68k";
73 + }
74 +
75 + void m68k_record_step(uaecptr pc)
76 + {
77 + #if FLIGHT_RECORDER >= 2
78 +        /* XXX: if LSB is set, we are recording from generated code and we
79 +           don't support registers recording yet.  */
80 +        if ((pc & 1) == 0) {
81 +                for (int i = 0; i < 8; i++) {
82 +                        log[log_ptr].d[i] = m68k_dreg(regs, i);
83 +                        log[log_ptr].a[i] = m68k_areg(regs, i);
84 +                }
85 +        }
86 + #endif
87 +        log[log_ptr].pc = pc;
88 +        log_ptr = (log_ptr + 1) % LOG_SIZE;
89 + }
90 +
91 + static void dump_log(void)
92 + {
93 +        FILE *f = fopen(log_filename(), "w");
94 +        if (f == NULL)
95 +                return;
96 +        for (int i = 0; i < LOG_SIZE; i++) {
97 +                int j = (i + log_ptr) % LOG_SIZE;
98 +                uae_u32 pc = log[j].pc & ~1;
99 +                fprintf(f, "pc %08x", pc);
100 + #if FLIGHT_RECORDER >= 2
101 +                fprintf(f, "\n");
102 +                if ((log[j].pc & 1) == 0) {
103 +                        fprintf(f, "d0 %08x d1 %08x d2 %08x d3 %08x\n", log[j].d[0], log[j].d[1], log[j].d[2], log[j].d[3]);
104 +                        fprintf(f, "d4 %08x d5 %08x d6 %08x d7 %08x\n", log[j].d[4], log[j].d[5], log[j].d[6], log[j].d[7]);
105 +                        fprintf(f, "a0 %08x a1 %08x a2 %08x a3 %08x\n", log[j].a[0], log[j].a[1], log[j].a[2], log[j].a[3]);
106 +                        fprintf(f, "a4 %08x a5 %08x a6 %08x a7 %08x\n", log[j].a[4], log[j].a[5], log[j].a[6], log[j].a[7]);
107 +                }
108 + #else
109 +                fprintf(f, " | ");
110 + #endif
111 + #if ENABLE_MON
112 +                disass_68k(f, pc);
113 + #endif
114 +        }
115 +        fclose(f);
116 + }
117 + #endif
118 +
119 + #if ENABLE_MON
120 + static void dump_regs(void)
121 + {
122 +        m68k_dumpstate(NULL);
123 + }
124 + #endif
125 +
126   #define COUNT_INSTRS 0
127  
128   #if COUNT_INSTRS
# Line 111 | Line 186 | static __inline__ unsigned int cft_map (
186   #endif
187   }
188  
189 < static void REGPARAM2 op_illg_1 (uae_u32 opcode) REGPARAM;
189 > void REGPARAM2 op_illg_1 (uae_u32 opcode) REGPARAM;
190  
191 < static void REGPARAM2 op_illg_1 (uae_u32 opcode)
191 > void REGPARAM2 op_illg_1 (uae_u32 opcode)
192   {
193      op_illg (cft_map (opcode));
194   }
# Line 134 | Line 209 | static void build_cpufunctbl (void)
209                          cpu_level = 1;
210          }
211      struct cputbl *tbl = (
212 <                  cpu_level == 4 ? op_smalltbl_0
213 <                : cpu_level == 3 ? op_smalltbl_1
214 <                : cpu_level == 2 ? op_smalltbl_2
215 <                : cpu_level == 1 ? op_smalltbl_3
216 <                : op_smalltbl_4);
212 >                  cpu_level == 4 ? op_smalltbl_0_ff
213 >                : cpu_level == 3 ? op_smalltbl_1_ff
214 >                : cpu_level == 2 ? op_smalltbl_2_ff
215 >                : cpu_level == 1 ? op_smalltbl_3_ff
216 >                : op_smalltbl_4_ff);
217  
218      for (opcode = 0; opcode < 65536; opcode++)
219          cpufunctbl[cft_map (opcode)] = op_illg_1;
# Line 178 | Line 253 | void init_m68k (void)
253          movem_index2[i] = 7-j;
254          movem_next[i] = i & (~(1 << j));
255      }
181    for (i = 0 ; i < 256 ; i++) {
182        int j;
183        for (j = 7 ; j >= 0 ; j--) {
184                if (i & (1 << j)) break;
185        }
186        fpp_movem_index1[i] = 7-j;
187        fpp_movem_index2[i] = j;
188        fpp_movem_next[i] = i & (~(1 << j));
189    }
256   #if COUNT_INSTRS
257      {
258          FILE *f = fopen (icountfilename (), "r");
# Line 207 | Line 273 | void init_m68k (void)
273      do_merges ();
274  
275      build_cpufunctbl ();
276 <    
277 <    fpu_init ();
278 <    fpu_set_integral_fpu (CPUType == 4);
276 >        
277 > #if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS)
278 >        spcflags_lock = B2_create_mutex();
279 > #endif
280 >    fpu_init(CPUType == 4);
281   }
282  
283   void exit_m68k (void)
284   {
285          fpu_exit ();
286 + #if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS)
287 +        B2_delete_mutex(spcflags_lock);
288 + #endif
289   }
290  
291   struct regstruct regs, lastint_regs;
# Line 223 | Line 294 | static int backup_pointer = 0;
294   static long int m68kpc_offset;
295   int lastint_no;
296  
297 + #if REAL_ADDRESSING || DIRECT_ADDRESSING
298 + #define get_ibyte_1(o) get_byte(get_virtual_address(regs.pc_p) + (o) + 1)
299 + #define get_iword_1(o) get_word(get_virtual_address(regs.pc_p) + (o))
300 + #define get_ilong_1(o) get_long(get_virtual_address(regs.pc_p) + (o))
301 + #else
302   #define get_ibyte_1(o) get_byte(regs.pc + (regs.pc_p - regs.pc_oldp) + (o) + 1)
303   #define get_iword_1(o) get_word(regs.pc + (regs.pc_p - regs.pc_oldp) + (o))
304   #define get_ilong_1(o) get_long(regs.pc + (regs.pc_p - regs.pc_oldp) + (o))
305 + #endif
306  
307   uae_s32 ShowEA (int reg, amodes mode, wordsizes size, char *buf)
308   {
# Line 644 | Line 721 | void MakeFromSR (void)
721          }
722      }
723  
724 <    regs.spcflags |= SPCFLAG_INT;
724 >    SPCFLAGS_SET( SPCFLAG_INT );
725      if (regs.t1 || regs.t0)
726 <        regs.spcflags |= SPCFLAG_TRACE;
726 >                SPCFLAGS_SET( SPCFLAG_TRACE );
727      else
728 <        regs.spcflags &= ~(SPCFLAG_TRACE | SPCFLAG_DOTRACE);
728 >        /* Keep SPCFLAG_DOTRACE, we still want a trace exception for
729 >           SR-modifying instructions (including STOP).  */
730 >                SPCFLAGS_CLEAR( SPCFLAG_TRACE );
731   }
732  
733   void Exception(int nr, uaecptr oldpc)
734   {
735 <    compiler_flush_jsr_stack();
735 >    uae_u32 currpc = m68k_getpc ();
736      MakeSR();
737      if (!regs.s) {
738          regs.usp = m68k_areg(regs, 7);
# Line 682 | Line 761 | void Exception(int nr, uaecptr oldpc)
761              m68k_areg(regs, 7) -= 2;
762              put_word (m68k_areg(regs, 7), nr * 4);
763              m68k_areg(regs, 7) -= 4;
764 <            put_long (m68k_areg(regs, 7), m68k_getpc ());
764 >            put_long (m68k_areg(regs, 7), currpc);
765              m68k_areg(regs, 7) -= 2;
766              put_word (m68k_areg(regs, 7), regs.sr);
767              regs.sr |= (1 << 13);
# Line 708 | Line 787 | void Exception(int nr, uaecptr oldpc)
787          }
788      }
789      m68k_areg(regs, 7) -= 4;
790 <    put_long (m68k_areg(regs, 7), m68k_getpc ());
790 >    put_long (m68k_areg(regs, 7), currpc);
791   kludge_me_do:
792      m68k_areg(regs, 7) -= 2;
793      put_word (m68k_areg(regs, 7), regs.sr);
794      m68k_setpc (get_long (regs.vbr + 4*nr));
795 +        SPCFLAGS_SET( SPCFLAG_JIT_END_COMPILE );
796      fill_prefetch_0 ();
797      regs.t1 = regs.t0 = regs.m = 0;
798 <    regs.spcflags &= ~(SPCFLAG_TRACE | SPCFLAG_DOTRACE);
798 >        SPCFLAGS_CLEAR( SPCFLAG_TRACE | SPCFLAG_DOTRACE );
799   }
800  
801   static void Interrupt(int nr)
# Line 726 | Line 806 | static void Interrupt(int nr)
806      Exception(nr+24, 0);
807  
808      regs.intmask = nr;
809 <    regs.spcflags |= SPCFLAG_INT;
809 >        SPCFLAGS_SET( SPCFLAG_INT );
810   }
811  
812 < static int caar, cacr, tc, itt0, itt1, dtt0, dtt1;
812 > static int caar, cacr, tc, itt0, itt1, dtt0, dtt1, mmusr, urp, srp;
813 >
814 > static int movec_illg (int regno)
815 > {
816 >        switch (CPUType) {
817 >        case 1:
818 >                if ((regno & 0x7ff) <= 1)
819 >                        return 0;
820 >                break;
821 >        case 2:
822 >        case 3:
823 >                if ((regno & 0x7ff) <= 2)
824 >                        return 0;
825 >                if (regno == 3 || regno == 4)
826 >                        return 0;
827 >                break;
828 >        case 4:
829 >                if ((regno & 0x7ff) <= 7) {
830 >                        if (regno != 0x802)
831 >                                return 0;
832 >                }
833 >                break;
834 >        }
835 >        return 1;
836 > }
837  
838 < void m68k_move2c (int regno, uae_u32 *regp)
838 > int m68k_move2c (int regno, uae_u32 *regp)
839   {
840 <    if (CPUType == 1 && (regno & 0x7FF) > 1)
840 >  if (movec_illg (regno)) {
841          op_illg (0x4E7B);
842 <    else
842 >        return 0;
843 >  } else {
844          switch (regno) {
845           case 0: regs.sfc = *regp & 7; break;
846           case 1: regs.dfc = *regp & 7; break;
847 <         case 2: cacr = *regp & 0x3; break;     /* ignore C and CE */
847 >         case 2:
848 >                cacr = *regp & (CPUType < 4 ? 0x3 : 0x80008000);
849 > #if USE_JIT
850 >                if (CPUType < 4) {
851 >                        set_cache_state(cacr&1);
852 >                        if (*regp & 0x08)
853 >                                flush_icache(1);
854 >                }
855 >                else {
856 >                        set_cache_state(cacr&0x8000);
857 >                }
858 > #endif
859 >         break;
860           case 3: tc = *regp & 0xc000; break;
861           case 4: itt0 = *regp & 0xffffe364; break;
862           case 5: itt1 = *regp & 0xffffe364; break;
# Line 750 | Line 867 | void m68k_move2c (int regno, uae_u32 *re
867           case 0x802: caar = *regp &0xfc; break;
868           case 0x803: regs.msp = *regp; if (regs.m == 1) m68k_areg(regs, 7) = regs.msp; break;
869           case 0x804: regs.isp = *regp; if (regs.m == 0) m68k_areg(regs, 7) = regs.isp; break;
870 +        case 0x805: mmusr = *regp; break;
871 +        case 0x806: urp = *regp; break;
872 +        case 0x807: srp = *regp; break;
873           default:
874              op_illg (0x4E7B);
875 <            break;
875 >            return 0;
876          }
877 +  }
878 +  return 1;
879   }
880  
881 < void m68k_movec2 (int regno, uae_u32 *regp)
881 > int m68k_movec2 (int regno, uae_u32 *regp)
882   {
883 <    if (CPUType == 1 && (regno & 0x7FF) > 1)
883 >    if (movec_illg (regno))
884 >    {
885          op_illg (0x4E7A);
886 <    else
886 >        return 0;
887 >    } else {
888          switch (regno) {
889           case 0: *regp = regs.sfc; break;
890           case 1: *regp = regs.dfc; break;
# Line 775 | Line 899 | void m68k_movec2 (int regno, uae_u32 *re
899           case 0x802: *regp = caar; break;
900           case 0x803: *regp = regs.m == 1 ? m68k_areg(regs, 7) : regs.msp; break;
901           case 0x804: *regp = regs.m == 0 ? m68k_areg(regs, 7) : regs.isp; break;
902 +        case 0x805: *regp = mmusr; break;
903 +        case 0x806: *regp = urp; break;
904 +        case 0x807: *regp = srp; break;
905           default:
906              op_illg (0x4E7A);
907 <            break;
907 >            return 0;
908          }
909 +        }
910 +        return 1;
911   }
912  
913   static __inline__ int
# Line 1036 | Line 1165 | static char* ccnames[] =
1165   { "T ","F ","HI","LS","CC","CS","NE","EQ",
1166    "VC","VS","PL","MI","GE","LT","GT","LE" };
1167  
1168 + // If value is greater than zero, this means we are still processing an EmulOp
1169 + // because the counter is incremented only in m68k_execute(), i.e. interpretive
1170 + // execution only
1171 + static int m68k_execute_depth = 0;
1172 +
1173   void m68k_reset (void)
1174   {
1175      m68k_areg (regs, 7) = 0x2000;
1176      m68k_setpc (ROMBaseMac + 0x2a);
1177      fill_prefetch_0 ();
1044    regs.kick_mask = 0xF80000;
1178      regs.s = 1;
1179      regs.m = 0;
1180      regs.stopped = 0;
# Line 1052 | Line 1185 | void m68k_reset (void)
1185      SET_CFLG (0);
1186      SET_VFLG (0);
1187      SET_NFLG (0);
1188 <    regs.spcflags = 0;
1188 >        SPCFLAGS_INIT( 0 );
1189      regs.intmask = 7;
1190      regs.vbr = regs.sfc = regs.dfc = 0;
1058    /* gb-- moved into {fpp,fpu_x86}.cpp::fpu_init()
1059    regs.fpcr = regs.fpsr = regs.fpiar = 0; */
1191      fpu_reset();
1192 +        
1193 + #if FLIGHT_RECORDER
1194 +        log_ptr = 0;
1195 +        memset(log, 0, sizeof(log));
1196 + #endif
1197 +
1198 + #if ENABLE_MON
1199 +        static bool first_time = true;
1200 +        if (first_time) {
1201 +                first_time = false;
1202 +                mon_add_command("regs", dump_regs, "regs                    Dump m68k emulator registers\n");
1203 + #if FLIGHT_RECORDER
1204 +                // Install "log" command in mon
1205 +                mon_add_command("log", dump_log, "log                      Dump m68k emulation log\n");
1206 + #endif
1207 +        }
1208 + #endif
1209   }
1210  
1211 < void REGPARAM2 op_illg (uae_u32 opcode)
1211 > void m68k_emulop_return(void)
1212   {
1213 <    uaecptr pc = m68k_getpc ();
1214 <
1215 <    compiler_flush_jsr_stack ();
1213 >        SPCFLAGS_SET( SPCFLAG_BRK );
1214 >        quit_program = true;
1215 > }
1216  
1217 <        if ((opcode & 0xFF00) == 0x7100) {
1217 > void m68k_emulop(uae_u32 opcode)
1218 > {
1219                  struct M68kRegisters r;
1220                  int i;
1221  
1073                // Return from Execute68k()?
1074                if (opcode == M68K_EXEC_RETURN) {
1075                        regs.spcflags |= SPCFLAG_BRK;
1076                        quit_program = 1;
1077                        return;
1078                }
1079
1080                // Call EMUL_OP opcode
1222                  for (i=0; i<8; i++) {
1223                          r.d[i] = m68k_dreg(regs, i);
1224                          r.a[i] = m68k_areg(regs, i);
# Line 1091 | Line 1232 | void REGPARAM2 op_illg (uae_u32 opcode)
1232                  }
1233                  regs.sr = r.sr;
1234                  MakeFromSR();
1235 <                m68k_incpc(2);
1236 <                fill_prefetch_0 ();
1237 <                return;
1238 <        }
1235 > }
1236 >
1237 > void REGPARAM2 op_illg (uae_u32 opcode)
1238 > {
1239 >        uaecptr pc = m68k_getpc ();
1240  
1241      if ((opcode & 0xF000) == 0xA000) {
1242          Exception(0xA,0);
1243          return;
1244      }
1245  
1104 //    write_log ("Illegal instruction: %04x at %08lx\n", opcode, pc);
1105
1246      if ((opcode & 0xF000) == 0xF000) {
1247          Exception(0xB,0);
1248          return;
1249      }
1250  
1251      write_log ("Illegal instruction: %04x at %08lx\n", opcode, pc);
1252 + #if USE_JIT && JIT_DEBUG
1253 +    compiler_dumpstate();
1254 + #endif
1255  
1256      Exception (4,0);
1257 +        return;
1258   }
1259  
1260   void mmu_op(uae_u32 opcode, uae_u16 extra)
1261   {
1262 <    if ((extra & 0xB000) == 0) { /* PMOVE instruction */
1263 <
1264 <    } else if ((extra & 0xF000) == 0x2000) { /* PLOAD instruction */
1265 <    } else if ((extra & 0xF000) == 0x8000) { /* PTEST instruction */
1262 >    if ((opcode & 0xFE0) == 0x0500) {
1263 >                /* PFLUSH */
1264 >                mmusr = 0;
1265 >        } else if ((opcode & 0x0FD8) == 0x548) {
1266 >                /* PTEST */
1267      } else
1268 <        op_illg (opcode);
1268 >                op_illg (opcode);
1269   }
1270  
1271   static int n_insns = 0, n_spcinsns = 0;
# Line 1129 | Line 1274 | static uaecptr last_trace_ad = 0;
1274  
1275   static void do_trace (void)
1276   {
1277 <    if (regs.t0) {
1277 >    if (regs.t0 && CPUType >= 2) {
1278         uae_u16 opcode;
1279         /* should also include TRAP, CHK, SR modification FPcc */
1280         /* probably never used so why bother */
1281         /* We can afford this to be inefficient... */
1282         m68k_setpc (m68k_getpc ());
1283         fill_prefetch_0 ();
1284 <       opcode = get_word (regs.pc);
1284 >       opcode = get_word(m68k_getpc());
1285         if (opcode == 0x4e72            /* RTE */
1286             || opcode == 0x4e74                 /* RTD */
1287             || opcode == 0x4e75                 /* RTS */
# Line 1152 | Line 1297 | static void do_trace (void)
1297                 && (uae_s16)m68k_dreg(regs, opcode & 7) != 0))
1298        {
1299              last_trace_ad = m68k_getpc ();
1300 <            regs.spcflags &= ~SPCFLAG_TRACE;
1301 <            regs.spcflags |= SPCFLAG_DOTRACE;
1300 >                SPCFLAGS_CLEAR( SPCFLAG_TRACE );
1301 >                SPCFLAGS_SET( SPCFLAG_DOTRACE );
1302          }
1303      } else if (regs.t1) {
1304         last_trace_ad = m68k_getpc ();
1305 <       regs.spcflags &= ~SPCFLAG_TRACE;
1306 <       regs.spcflags |= SPCFLAG_DOTRACE;
1305 >       SPCFLAGS_CLEAR( SPCFLAG_TRACE );
1306 >       SPCFLAGS_SET( SPCFLAG_DOTRACE );
1307      }
1308   }
1309  
1310 <
1166 < static int do_specialties (void)
1310 > int m68k_do_specialties (void)
1311   {
1312 <    /*n_spcinsns++;*/
1313 <    run_compiled_code();
1314 <    if (regs.spcflags & SPCFLAG_DOTRACE) {
1312 > #if USE_JIT
1313 >    // Block was compiled
1314 >    SPCFLAGS_CLEAR( SPCFLAG_JIT_END_COMPILE );
1315 >
1316 >    // Retain the request to get out of compiled code until
1317 >    // we reached the toplevel execution, i.e. the one that
1318 >    // can compile then run compiled code. This also means
1319 >    // we processed all (nested) EmulOps
1320 >    if ((m68k_execute_depth == 0) && SPCFLAGS_TEST( SPCFLAG_JIT_EXEC_RETURN ))
1321 >        SPCFLAGS_CLEAR( SPCFLAG_JIT_EXEC_RETURN );
1322 > #endif
1323 >        
1324 >    if (SPCFLAGS_TEST( SPCFLAG_DOTRACE )) {
1325          Exception (9,last_trace_ad);
1326      }
1327 <    while (regs.spcflags & SPCFLAG_STOP) {
1328 <        if (regs.spcflags & (SPCFLAG_INT | SPCFLAG_DOINT)){
1327 >    while (SPCFLAGS_TEST( SPCFLAG_STOP )) {
1328 >        if (SPCFLAGS_TEST( SPCFLAG_INT | SPCFLAG_DOINT )){
1329 >                SPCFLAGS_CLEAR( SPCFLAG_INT | SPCFLAG_DOINT );
1330              int intr = intlev ();
1176            regs.spcflags &= ~(SPCFLAG_INT | SPCFLAG_DOINT);
1331              if (intr != -1 && intr > regs.intmask) {
1332                  Interrupt (intr);
1333                  regs.stopped = 0;
1334 <                regs.spcflags &= ~SPCFLAG_STOP;
1334 >                SPCFLAGS_CLEAR( SPCFLAG_STOP );
1335              }
1336          }
1337      }
1338 <    if (regs.spcflags & SPCFLAG_TRACE)
1338 >    if (SPCFLAGS_TEST( SPCFLAG_TRACE ))
1339         do_trace ();
1340  
1341 <    if (regs.spcflags & SPCFLAG_DOINT) {
1341 >    if (SPCFLAGS_TEST( SPCFLAG_DOINT )) {
1342 >        SPCFLAGS_CLEAR( SPCFLAG_DOINT );
1343          int intr = intlev ();
1189        regs.spcflags &= ~SPCFLAG_DOINT;
1344          if (intr != -1 && intr > regs.intmask) {
1345              Interrupt (intr);
1346              regs.stopped = 0;
1347          }
1348      }
1349 <    if (regs.spcflags & SPCFLAG_INT) {
1350 <        regs.spcflags &= ~SPCFLAG_INT;
1351 <        regs.spcflags |= SPCFLAG_DOINT;
1349 >    if (SPCFLAGS_TEST( SPCFLAG_INT )) {
1350 >        SPCFLAGS_CLEAR( SPCFLAG_INT );
1351 >        SPCFLAGS_SET( SPCFLAG_DOINT );
1352      }
1353 <    if (regs.spcflags & (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE)) {
1354 <        regs.spcflags &= ~(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE);
1353 >    if (SPCFLAGS_TEST( SPCFLAG_BRK )) {
1354 >        SPCFLAGS_CLEAR( SPCFLAG_BRK );
1355          return 1;
1356      }
1357      return 0;
1358   }
1359  
1360 < static void m68k_run_1 (void)
1360 > void m68k_do_execute (void)
1361   {
1362          for (;;) {
1363                  uae_u32 opcode = GET_OPCODE;
1364 + #if FLIGHT_RECORDER
1365 +                m68k_record_step(m68k_getpc());
1366 + #endif
1367                  (*cpufunctbl[opcode])(opcode);
1368 <                if (regs.spcflags) {
1369 <                        if (do_specialties())
1368 >                cpu_check_ticks();
1369 >                if (SPCFLAGS_TEST(SPCFLAG_ALL_BUT_EXEC_RETURN)) {
1370 >                        if (m68k_do_specialties())
1371                                  return;
1372                  }
1373          }
1374   }
1375  
1376 < #define m68k_run1 m68k_run_1
1219 <
1220 < int in_m68k_go = 0;
1221 <
1222 < void m68k_go (int may_quit)
1376 > void m68k_execute (void)
1377   {
1378 < // m68k_go() must be reentrant for Execute68k() and Execute68kTrap() to work
1379 < /*
1380 <    if (in_m68k_go || !may_quit) {
1227 <        write_log("Bug! m68k_go is not reentrant.\n");
1228 <        abort();
1229 <    }
1230 < */
1231 <    in_m68k_go++;
1378 > #if USE_JIT
1379 >    ++m68k_execute_depth;
1380 > #endif
1381      for (;;) {
1382 <        if (quit_program > 0) {
1234 <            if (quit_program == 1)
1382 >          if (quit_program)
1383                  break;
1384 <            quit_program = 0;
1237 <            m68k_reset ();
1238 <        }
1239 <        m68k_run1();
1384 >          m68k_do_execute();
1385      }
1386 <        if (debugging) {
1387 <                uaecptr nextpc;
1388 <                m68k_dumpstate(&nextpc);
1244 <                exit(1);
1245 <        }
1246 <    in_m68k_go--;
1386 > #if USE_JIT
1387 >    --m68k_execute_depth;
1388 > #endif
1389   }
1390  
1391   static void m68k_verify (uaecptr addr, uaecptr *nextpc)
# Line 1352 | Line 1494 | void m68k_dumpstate (uaecptr *nextpc)
1494      printf ("T=%d%d S=%d M=%d X=%d N=%d Z=%d V=%d C=%d IMASK=%d\n",
1495              regs.t1, regs.t0, regs.s, regs.m,
1496              GET_XFLG, GET_NFLG, GET_ZFLG, GET_VFLG, GET_CFLG, regs.intmask);
1497 <    for (i = 0; i < 8; i++){
1498 <        printf ("FP%d: %g ", i, regs.fp[i]);
1499 <        if ((i & 3) == 3) printf ("\n");
1500 <    }
1359 <    printf ("N=%d Z=%d I=%d NAN=%d\n",
1360 <                (regs.fpsr & 0x8000000) != 0,
1361 <                (regs.fpsr & 0x4000000) != 0,
1362 <                (regs.fpsr & 0x2000000) != 0,
1363 <                (regs.fpsr & 0x1000000) != 0);
1364 <
1497 >        
1498 >        fpu_dump_registers();
1499 >        fpu_dump_flags();
1500 >        
1501      m68k_disasm(m68k_getpc (), nextpc, 1);
1502      if (nextpc)
1503          printf ("next PC: %08lx\n", *nextpc);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines