Previous 199869 Revisions Next

r23947 Tuesday 25th June, 2013 at 23:25:05 UTC by David Haywood
setjmp / longjmp doesn't play nice in 64-bit debug compiles in a modern core, so use c++ exceptions to mimic the behavior.  probably could be improved.
[src/emu/cpu/m68000]m68000.h m68kcpu.c m68kcpu.h

trunk/src/emu/cpu/m68000/m68000.h
r23946r23947
1616
1717#include "../../../lib/softfloat/milieu.h"
1818#include "../../../lib/softfloat/softfloat.h"
19#include <setjmp.h>
2019
2120
2221/* MMU constants */
r23946r23947
2827
2928
3029
31/* Address error */
32/* sigjmp() on Mac OS X and *BSD in general saves signal contexts and is super-slow, use sigsetjmp() to tell it not to */
33#ifdef _BSD_SETJMP_H
34#define m68ki_set_address_error_trap(m68k) \
35   if(sigsetjmp(m68k->aerr_trap, 0) != 0) \
36   { \
37      m68ki_exception_address_error(m68k); \
38      if(m68k->stopped) \
39      { \
40         if (m68k->remaining_cycles > 0) \
41            m68k->remaining_cycles = 0; \
42         return; \
43      } \
44   }
45
4630#define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \
4731   if((ADDR)&1) \
4832   { \
4933      m68k->aerr_address = ADDR; \
5034      m68k->aerr_write_mode = WRITE_MODE; \
5135      m68k->aerr_fc = FC; \
52      siglongjmp(m68k->aerr_trap, 1); \
36      throw 10; \
5337   }
54#else
55#define m68ki_set_address_error_trap(m68k) \
56   SETJMP_GNUC_PROTECT(); \
57   if(setjmp(m68k->aerr_trap) != 0) \
58   { \
59      m68ki_exception_address_error(m68k); \
60      if(m68k->stopped) \
61      { \
62         if (m68k->remaining_cycles > 0) \
63            m68k->remaining_cycles = 0; \
64         return; \
65      } \
66   }
6738
68#define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \
69   if((ADDR)&1) \
70   { \
71      m68k->aerr_address = ADDR; \
72      m68k->aerr_write_mode = WRITE_MODE; \
73      m68k->aerr_fc = FC; \
74      longjmp(m68k->aerr_trap, 1); \
75   }
76#endif
7739
7840
79
8041/* There are 7 levels of interrupt to the 68K.
8142 * A transition from < 7 to 7 will cause a non-maskable interrupt (NMI).
8243 */
r23946r23947
286247   int  reset_cycles;
287248   UINT32 tracing;
288249
289#ifdef _BSD_SETJMP_H
290   sigjmp_buf aerr_trap;
291#else
292   jmp_buf aerr_trap;
293#endif
250   int m_address_error;
251
294252   UINT32    aerr_address;
295253   UINT32    aerr_write_mode;
296254   UINT32    aerr_fc;
r23946r23947
314272   address_space *program;
315273
316274
317
318275   /* Redirect memory calls */
319276
320277   typedef delegate<UINT8 (offs_t)> m68k_read8_delegate;
trunk/src/emu/cpu/m68000/m68kcpu.h
r23946r23947
3131
3232
3333#include <limits.h>
34#include <setjmp.h>
3534
35
3636/* ======================================================================== */
3737/* ==================== ARCHITECTURE-DEPENDANT DEFINES ==================== */
3838/* ======================================================================== */
trunk/src/emu/cpu/m68000/m68kcpu.c
r23946r23947
769769   if(!stopped)
770770   {
771771      /* Return point if we had an address error */
772      m68ki_set_address_error_trap(this); /* auto-disable (see m68kcpu.h) */
772      check_address_error:
773      if (m_address_error==1)
774      {
775         m_address_error = 0;
776         m68ki_exception_address_error(this);
777         if(stopped)
778         {
779            if (remaining_cycles > 0)
780               remaining_cycles = 0;
781            return;
782         }
783      }
773784
785
774786      /* Main loop.  Keep going until we run out of clock cycles */
775787      while (remaining_cycles > 0)
776788      {
r23946r23947
787799         /* Record previous program counter */
788800         REG_PPC(this) = REG_PC(this);
789801
802         try
803         {
790804         if (!pmmu_enabled)
791805         {
792806            run_mode = RUN_MODE_NORMAL;
r23946r23947
866880               // remaining_cycles -= cyc_exception[EXCEPTION_BUS_ERROR] - cyc_instruction[ir];
867881            }
868882         }
883         }
884         catch (int error)
885         {
886            if (error==10)
887            {
888               m_address_error = 1;
889               goto check_address_error;
890            }
891            else
892               throw;
893         }
869894
895
870896         /* Trace m68k_exception, if necessary */
871897         m68ki_exception_if_trace(this); /* auto-disable (see m68kcpu.h) */
872898      }
r23946r23947
26002626
26012627void m68000_base_device::clear_all()
26022628{
2603
26042629   cpu_type= 0;
26052630//   dasm_type= 0;
26062631   for (int i=0;i<16;i++)
r23946r23947
26592684   reset_cycles = 0;
26602685   tracing = 0;
26612686
2662//   aerr_trap = 0;
2687   m_address_error = 0;
26632688
26642689   aerr_address = 0;
26652690   aerr_write_mode = 0;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team