--- previous/src/uae-cpu/newcpu.c 2018/04/24 19:25:10 1.1 +++ previous/src/uae-cpu/newcpu.c 2018/04/24 19:26:10 1.1.1.2 @@ -108,6 +108,8 @@ /* 2008/12/20 [NP] In m68k_run_1(), when checking interrupts and STOP mode, we should test */ /* PendingInterruptCount before regs.spcflags to have a faster evaluation of the */ /* 'while' condition (PendingInterruptCount <= 0 is true less often than STOP==0) */ +/* 2011/04/29 [NP] In Exception(), check the new PC is not on odd address ; raise an address error */ +/* exception if it's the case. */ const char NewCpu_fileid[] = "Hatari newcpu.c : " __DATE__ " " __TIME__; @@ -123,11 +125,13 @@ const char NewCpu_fileid[] = "Hatari new #include "mfp.h" #include "cart.h" #include "dialog.h" +#include "screen.h" #include "video.h" #include "options.h" #include "log.h" #include "debugui.h" #include "debugcpu.h" +#include "68kDisass.h" //#define DEBUG_PREFETCH @@ -811,7 +815,7 @@ static void InterruptAddJitter (int Leve /* and get a conflict with 'normal' cpu exceptions. */ void Exception(int nr, uaecptr oldpc, int ExceptionSource) { - uae_u32 currpc = m68k_getpc (); + uae_u32 currpc = m68k_getpc () , newpc; /*if( nr>=2 && nr<10 ) fprintf(stderr,"Exception (-> %i bombs)!\n",nr);*/ @@ -912,7 +916,7 @@ void Exception(int nr, uaecptr oldpc, in if (bExceptionDebugging) DebugUI(); else - DlgAlert_Notice("Detected double bus error => CPU halted!\nEmulation needs to be reseted.\n"); + DlgAlert_Notice("Detected double bus error => CPU halted!\nEmulation needs to be reset.\n"); regs.intmask = 7; m68k_setstopped(true); return; @@ -929,6 +933,22 @@ void Exception(int nr, uaecptr oldpc, in write_log("Uninitialized exception handler #%i!\n", nr); DebugUI(); } + newpc = get_long (regs.vbr + 4*nr); + if ( newpc & 1) /* check new pc is even */ + { + if ( nr==2 || nr==3 ) /* address error during bus/address error -> stop emulation */ + { + fprintf(stderr,"Address Error during exception 2/3, aborting new PC=$%x\n",newpc); + DebugUI(); + } + else + { + fprintf(stderr,"Address Error during exception, new PC=$%x\n",newpc); + Exception ( 3 , m68k_getpc() , M68000_EXC_SRC_CPU ); + } + return; + } + m68k_setpc (get_long (regs.vbr + 4*nr)); fill_prefetch_0 (); /* Handle trace flags depending on current state */ @@ -1574,7 +1594,7 @@ static void m68k_run_1 (void) Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles ); LOG_TRACE_PRINT ( "cpu video_cyc=%6d %3d@%3d : " , FrameCycles, LineCycles, HblCounterVideo ); - m68k_disasm(stderr, m68k_getpc (), NULL, 1); + Disasm(stderr, m68k_getpc (), NULL, 1, DISASM_ENGINE_EXT); } /* assert (!regs.stopped && !(regs.spcflags & SPCFLAG_STOP)); */ @@ -1655,7 +1675,7 @@ static void m68k_run_2 (void) Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles ); LOG_TRACE_PRINT ( "cpu video_cyc=%6d %3d@%3d : " , FrameCycles, LineCycles, HblCounterVideo ); - m68k_disasm(stderr, m68k_getpc (), NULL, 1); + Disasm(stderr, m68k_getpc (), NULL, 1, DISASM_ENGINE_EXT); } /* assert (!regs.stopped && !(regs.spcflags & SPCFLAG_STOP)); */ @@ -1667,6 +1687,10 @@ static void m68k_run_2 (void) instrcount[opcode]++; #endif + /* In case of a Bus Error, we need the PC of the instruction that caused */ + /* the error to build the exception stack frame */ + BusErrorPC = m68k_getpc(); + cycles = (*cpufunctbl[opcode])(opcode);