diff --git a/src/emu/cpu/m68000/m68000.h b/src/emu/cpu/m68000/m68000.h index 027baba51fc..b19319a8ecd 100644 --- a/src/emu/cpu/m68000/m68000.h +++ b/src/emu/cpu/m68000/m68000.h @@ -16,7 +16,6 @@ #include "../../../lib/softfloat/milieu.h" #include "../../../lib/softfloat/softfloat.h" -#include /* MMU constants */ @@ -28,52 +27,14 @@ -/* Address error */ -/* sigjmp() on Mac OS X and *BSD in general saves signal contexts and is super-slow, use sigsetjmp() to tell it not to */ -#ifdef _BSD_SETJMP_H -#define m68ki_set_address_error_trap(m68k) \ - if(sigsetjmp(m68k->aerr_trap, 0) != 0) \ - { \ - m68ki_exception_address_error(m68k); \ - if(m68k->stopped) \ - { \ - if (m68k->remaining_cycles > 0) \ - m68k->remaining_cycles = 0; \ - return; \ - } \ - } - #define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \ if((ADDR)&1) \ { \ m68k->aerr_address = ADDR; \ m68k->aerr_write_mode = WRITE_MODE; \ m68k->aerr_fc = FC; \ - siglongjmp(m68k->aerr_trap, 1); \ + throw 10; \ } -#else -#define m68ki_set_address_error_trap(m68k) \ - SETJMP_GNUC_PROTECT(); \ - if(setjmp(m68k->aerr_trap) != 0) \ - { \ - m68ki_exception_address_error(m68k); \ - if(m68k->stopped) \ - { \ - if (m68k->remaining_cycles > 0) \ - m68k->remaining_cycles = 0; \ - return; \ - } \ - } - -#define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \ - if((ADDR)&1) \ - { \ - m68k->aerr_address = ADDR; \ - m68k->aerr_write_mode = WRITE_MODE; \ - m68k->aerr_fc = FC; \ - longjmp(m68k->aerr_trap, 1); \ - } -#endif @@ -286,11 +247,8 @@ public: int reset_cycles; UINT32 tracing; -#ifdef _BSD_SETJMP_H - sigjmp_buf aerr_trap; -#else - jmp_buf aerr_trap; -#endif + int m_address_error; + UINT32 aerr_address; UINT32 aerr_write_mode; UINT32 aerr_fc; @@ -314,7 +272,6 @@ public: address_space *program; - /* Redirect memory calls */ typedef delegate m68k_read8_delegate; diff --git a/src/emu/cpu/m68000/m68kcpu.c b/src/emu/cpu/m68000/m68kcpu.c index 3f7fd3a8b5d..54f78c391ec 100644 --- a/src/emu/cpu/m68000/m68kcpu.c +++ b/src/emu/cpu/m68000/m68kcpu.c @@ -769,7 +769,19 @@ inline void m68000_base_device::cpu_execute(void) if(!stopped) { /* Return point if we had an address error */ - m68ki_set_address_error_trap(this); /* auto-disable (see m68kcpu.h) */ + check_address_error: + if (m_address_error==1) + { + m_address_error = 0; + m68ki_exception_address_error(this); + if(stopped) + { + if (remaining_cycles > 0) + remaining_cycles = 0; + return; + } + } + /* Main loop. Keep going until we run out of clock cycles */ while (remaining_cycles > 0) @@ -787,6 +799,8 @@ inline void m68000_base_device::cpu_execute(void) /* Record previous program counter */ REG_PPC(this) = REG_PC(this); + try + { if (!pmmu_enabled) { run_mode = RUN_MODE_NORMAL; @@ -866,6 +880,18 @@ inline void m68000_base_device::cpu_execute(void) // remaining_cycles -= cyc_exception[EXCEPTION_BUS_ERROR] - cyc_instruction[ir]; } } + } + catch (int error) + { + if (error==10) + { + m_address_error = 1; + goto check_address_error; + } + else + throw; + } + /* Trace m68k_exception, if necessary */ m68ki_exception_if_trace(this); /* auto-disable (see m68kcpu.h) */ @@ -2600,7 +2626,6 @@ m68000_base_device::m68000_base_device(const machine_config &mconfig, const char void m68000_base_device::clear_all() { - cpu_type= 0; // dasm_type= 0; for (int i=0;i<16;i++) @@ -2659,7 +2684,7 @@ void m68000_base_device::clear_all() reset_cycles = 0; tracing = 0; -// aerr_trap = 0; + m_address_error = 0; aerr_address = 0; aerr_write_mode = 0; diff --git a/src/emu/cpu/m68000/m68kcpu.h b/src/emu/cpu/m68000/m68kcpu.h index 4ff0d83c0ca..081f75cc217 100644 --- a/src/emu/cpu/m68000/m68kcpu.h +++ b/src/emu/cpu/m68000/m68kcpu.h @@ -31,7 +31,7 @@ class m68000_base_device; #include -#include + /* ======================================================================== */ /* ==================== ARCHITECTURE-DEPENDANT DEFINES ==================== */