bugfixes, famec tuning

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@287 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2007-10-30 21:49:39 +00:00
parent 8ef001cc89
commit d0ae0cb4bb
3 changed files with 161 additions and 191 deletions

View file

@ -48,7 +48,7 @@ pm_file *pm_open(const char *path)
ext = zipentry->name+strlen(zipentry->name)-3; ext = zipentry->name+strlen(zipentry->name)-3;
for (i = 0; i < sizeof(rom_exts)/sizeof(rom_exts[0]); i++) for (i = 0; i < sizeof(rom_exts)/sizeof(rom_exts[0]); i++)
if (!strcasecmp(ext, rom_exts[i]) == 0) goto found_rom_zip; if (strcasecmp(ext, rom_exts[i]) == 0) goto found_rom_zip;
} }
/* zipfile given, but nothing found suitable for us inside */ /* zipfile given, but nothing found suitable for us inside */

View file

@ -17,12 +17,10 @@
// Options // // Options //
#define FAMEC_ROLL_INLINE #define FAMEC_ROLL_INLINE
#define FAMEC_EMULATE_TRACE #define FAMEC_EMULATE_TRACE
#define FAMEC_IRQ_CYCLES
#define FAMEC_CHECK_BRANCHES #define FAMEC_CHECK_BRANCHES
// #define FAMEC_USE_DATA_BANKS #define FAMEC_EXTRA_INLINE
// #define FAMEC_EXTRA_INLINE
// #define FAMEC_DEBUG // #define FAMEC_DEBUG
#define FAMEC_NO_GOTOS //#define FAMEC_NO_GOTOS
#define FAMEC_ADR_BITS 24 #define FAMEC_ADR_BITS 24
// #define FAMEC_FETCHBITS 8 // #define FAMEC_FETCHBITS 8
#define FAMEC_DATABITS 8 #define FAMEC_DATABITS 8
@ -41,6 +39,7 @@
#ifndef FAMEC_EXTRA_INLINE #ifndef FAMEC_EXTRA_INLINE
#define FAMEC_EXTRA_INLINE #define FAMEC_EXTRA_INLINE
#else #else
#undef FAMEC_EXTRA_INLINE
#define FAMEC_EXTRA_INLINE INLINE #define FAMEC_EXTRA_INLINE INLINE
#endif #endif
@ -84,17 +83,6 @@ typedef unsigned int u32;
typedef signed int s32; typedef signed int s32;
*/ */
#ifdef FAMEC_EMULATE_TRACE
static u32 flag_T;
#endif
static u32 flag_C;
static u32 flag_V;
static u32 flag_NotZ;
static u32 flag_N;
static u32 flag_X; // 16 bytes aligned
static u32 flag_S;
static u32 flag_I;
#ifndef M68K_OK #ifndef M68K_OK
#define M68K_OK 0 #define M68K_OK 0
#endif #endif
@ -288,22 +276,27 @@ static u32 flag_I;
#define M68K_PPL (m68kcontext.sr >> 8) & 7 #define M68K_PPL (m68kcontext.sr >> 8) & 7
#define GET_PC \ #define GET_PC \
(u32)PC - BasePC; ((u32)PC - BasePC)
#ifndef FAMEC_32BIT_PC #ifndef FAMEC_32BIT_PC
#define SET_PC(A) \ #define SET_PC(A) \
BasePC = g_m68kcontext->Fetch[((A) >> M68K_FETCHSFT) & M68K_FETCHMASK]; \ { \
/* BasePC -= (A) & 0xFF000000; */ \ u32 pc = A; \
PC = (u16*)(((A) & M68K_ADR_MASK) + BasePC); BasePC = m68kcontext.Fetch[(pc >> M68K_FETCHSFT) & M68K_FETCHMASK]; \
PC = (u16*)((pc & M68K_ADR_MASK) + BasePC); \
}
#else #else
#define SET_PC(A) \ #define SET_PC(A) \
BasePC = g_m68kcontext->Fetch[((A) >> M68K_FETCHSFT) & M68K_FETCHMASK]; \ { \
BasePC -= (A) & 0xFF000000; \ u32 pc = A; \
PC = (u16*)((A) + BasePC); BasePC = m68kcontext.Fetch[(pc >> M68K_FETCHSFT) & M68K_FETCHMASK]; \
BasePC -= pc & 0xFF000000; \
PC = (u16*)(pc + BasePC); \
}
#endif #endif
@ -473,7 +466,7 @@ static u32 flag_I;
if (interrupt_chk__()) \ if (interrupt_chk__()) \
{ \ { \
cycles_needed=m68kcontext.io_cycle_counter-(CLK); \ cycles_needed=m68kcontext.io_cycle_counter-(CLK); \
m68kcontext.io_cycle_counter= (CLK); \ m68kcontext.io_cycle_counter=(CLK); \
} }
@ -488,9 +481,10 @@ static u32 flag_I;
#define CHECK_BRANCH_EXCEPTION(_PC_) \ #define CHECK_BRANCH_EXCEPTION(_PC_) \
if ((_PC_)&1) \ if ((_PC_)&1) \
{ \ { \
u32 pr_PC=GET_PC; \ u32 new_PC, pr_PC=GET_PC; \
m68kcontext.execinfo |= FM68K_EMULATE_GROUP_0; \ m68kcontext.execinfo |= FM68K_EMULATE_GROUP_0; \
execute_exception_group_0(M68K_ADDRESS_ERROR_EX, 0, pr_PC, 0x12 ); \ new_PC = execute_exception_group_0(M68K_ADDRESS_ERROR_EX, 0, pr_PC, 0x12 ); \
SET_PC(new_PC); \
CHECK_BRANCH_EXCEPTION_GOTO_END \ CHECK_BRANCH_EXCEPTION_GOTO_END \
} }
#else #else
@ -500,9 +494,6 @@ static u32 flag_I;
static int init_jump_table(void); static int init_jump_table(void);
/* Custom function handler */
typedef void (*icust_handler_func)(u32 vector);
// global variable // global variable
/////////////////// ///////////////////
@ -510,20 +501,30 @@ typedef void (*icust_handler_func)(u32 vector);
M68K_CONTEXT *g_m68kcontext; M68K_CONTEXT *g_m68kcontext;
#define m68kcontext (*g_m68kcontext) #define m68kcontext (*g_m68kcontext)
/* static s32 io_cycle_counter; */ #ifdef FAMEC_NO_GOTOS
static s32 cycles_needed=0; static u32 Opcode;
static s32 cycles_needed;
static u16 *PC; static u16 *PC;
static u32 BasePC; static u32 BasePC;
// static u32 Fetch[M68K_FETCHBANK]; static u32 flag_V;
static u32 flag_NotZ;
static u32 flag_N;
static u32 flag_X;
#endif
#ifdef FAMEC_EMULATE_TRACE
static u32 flag_T;
#endif
static u32 flag_S;
static u32 flag_I;
static u32 initialised = 0;
/* Custom function handler */ /* Custom function handler */
typedef void (*opcode_func)(void); typedef void (*opcode_func)(void);
static opcode_func JumpTable[0x10000]; static opcode_func JumpTable[0x10000];
static u32 initialised = 0;
// exception cycle table (taken from musashi core) // exception cycle table (taken from musashi core)
static const s32 exception_cycle_table[256] = static const s32 exception_cycle_table[256] =
{ {
@ -673,7 +674,11 @@ int fm68k_reset(void)
/****************************************************************************/ /****************************************************************************/
u32 fm68k_get_pc(M68K_CONTEXT *context) u32 fm68k_get_pc(M68K_CONTEXT *context)
{ {
#ifdef FAMEC_NO_GOTOS
return (context->execinfo & M68K_RUNNING)?(u32)PC-BasePC:context->pc; return (context->execinfo & M68K_RUNNING)?(u32)PC-BasePC:context->pc;
#else
return context->pc; // approximate PC in this mode
#endif
} }
@ -692,17 +697,12 @@ int fm68k_would_interrupt(void)
return interrupt_chk__(); return interrupt_chk__();
} }
static FAMEC_EXTRA_INLINE void execute_exception(s32 vect) static FAMEC_EXTRA_INLINE u32 execute_exception(s32 vect, u32 oldPC, u32 oldSR)
{ {
extern u32 flag_S;
#ifndef FAMEC_IRQ_CYCLES
if ((vect<24)||(vect>31))
#endif
m68kcontext.io_cycle_counter -= exception_cycle_table[vect];
{
u32 newPC; u32 newPC;
u32 oldPC; //u32 oldSR = GET_SR;
u32 oldSR = GET_SR;
m68kcontext.io_cycle_counter -= exception_cycle_table[vect];
PRE_IO PRE_IO
@ -718,7 +718,7 @@ static FAMEC_EXTRA_INLINE void execute_exception(s32 vect)
AREG(7) = tmpSP; AREG(7) = tmpSP;
} }
oldPC = (u32)(PC) - BasePC; //oldPC = GET_PC;
PUSH_32_F(oldPC) PUSH_32_F(oldPC)
PUSH_16_F(oldSR) PUSH_16_F(oldSR)
@ -730,26 +730,29 @@ static FAMEC_EXTRA_INLINE void execute_exception(s32 vect)
#endif #endif
newPC&=~1; // don't crash on games with bad vector tables newPC&=~1; // don't crash on games with bad vector tables
SET_PC(newPC) // SET_PC(newPC)
POST_IO POST_IO
}
return newPC;
} }
static FAMEC_EXTRA_INLINE void execute_exception_group_0(s32 vect, u16 inst_reg, s32 addr, u16 spec_info) static FAMEC_EXTRA_INLINE u32 execute_exception_group_0(s32 vect, s32 addr, u16 spec_info, u32 oldSR)
{ {
execute_exception(vect); u32 newPC;
u16 inst_reg = 0;
newPC = execute_exception(vect, addr, oldSR);
//if (!(m68kcontext.icust_handler && m68kcontext.icust_handler[vect])) //if (!(m68kcontext.icust_handler && m68kcontext.icust_handler[vect]))
{ {
PUSH_16_F(inst_reg); PUSH_16_F(inst_reg);
PUSH_32_F(addr); PUSH_32_F(addr);
PUSH_16_F(spec_info); PUSH_16_F(spec_info);
} }
return newPC;
} }
static void setup_jumptable(void); static void setup_jumptable(void);
static u32 Opcode;
#ifdef FAMEC_NO_GOTOS #ifdef FAMEC_NO_GOTOS
@ -764,6 +767,18 @@ static u32 Opcode;
int fm68k_emulate(s32 cycles) int fm68k_emulate(s32 cycles)
{ {
#ifndef FAMEC_NO_GOTOS
u32 Opcode;
s32 cycles_needed;
u16 *PC;
u32 BasePC;
u32 flag_C;
u32 flag_V;
u32 flag_NotZ;
u32 flag_N;
u32 flag_X;
#endif
if (!initialised) if (!initialised)
{ {
#ifdef FAMEC_NO_GOTOS #ifdef FAMEC_NO_GOTOS
@ -824,7 +839,7 @@ int fm68k_emulate(s32 cycles)
else else
m68kcontext.interrupts[0] = 0; m68kcontext.interrupts[0] = 0;
execute_exception(line + 0x18); SET_PC(execute_exception(line + 0x18, GET_PC, GET_SR));
flag_I = (u32)line; flag_I = (u32)line;
if (m68kcontext.io_cycle_counter <= 0) goto famec_End; if (m68kcontext.io_cycle_counter <= 0) goto famec_End;
} }
@ -833,7 +848,7 @@ int fm68k_emulate(s32 cycles)
if (flag_T) if (flag_T)
{ {
m68kcontext.execinfo |= FM68K_EMULATE_TRACE; m68kcontext.execinfo |= FM68K_EMULATE_TRACE;
cycles_needed= m68kcontext.io_cycle_counter; cycles_needed = m68kcontext.io_cycle_counter;
m68kcontext.io_cycle_counter=0; m68kcontext.io_cycle_counter=0;
} }
#endif #endif
@ -862,22 +877,25 @@ famec_Exec:
#ifdef FAMEC_EMULATE_TRACE #ifdef FAMEC_EMULATE_TRACE
if (m68kcontext.execinfo & FM68K_EMULATE_TRACE) if (m68kcontext.execinfo & FM68K_EMULATE_TRACE)
{ {
m68kcontext.io_cycle_counter= cycles_needed; m68kcontext.io_cycle_counter = cycles_needed;
cycles_needed = 0;
m68kcontext.execinfo &= ~FM68K_EMULATE_TRACE; m68kcontext.execinfo &= ~FM68K_EMULATE_TRACE;
m68kcontext.execinfo |= FM68K_DO_TRACE; m68kcontext.execinfo |= FM68K_DO_TRACE;
execute_exception(M68K_TRACE_EX); SET_PC(execute_exception(M68K_TRACE_EX, GET_PC, GET_SR));
flag_T=0; flag_T=0;
if (m68kcontext.io_cycle_counter > 0) if (m68kcontext.io_cycle_counter > 0)
{ {
NEXT //NEXT
goto famec_Exec;
} }
} }
else else
#endif #endif
if (cycles_needed != 0) if (cycles_needed != 0)
{ {
m68kcontext.io_cycle_counter = cycles_needed;
cycles_needed = 0;
s32 line=interrupt_chk__(); s32 line=interrupt_chk__();
m68kcontext.io_cycle_counter= cycles_needed;
if (line>0) if (line>0)
{ {
if (m68kcontext.iack_handler != NULL) if (m68kcontext.iack_handler != NULL)
@ -885,11 +903,11 @@ famec_Exec:
else else
m68kcontext.interrupts[0] = 0; m68kcontext.interrupts[0] = 0;
execute_exception(line + 0x18); SET_PC(execute_exception(line + 0x18, GET_PC, GET_SR));
flag_I = (u32)line; flag_I = (u32)line;
} }
#ifdef FAMEC_EMULATE_TRACE #ifdef FAMEC_EMULATE_TRACE
else if (!(flag_T)) if (!(flag_T))
#endif #endif
if (m68kcontext.io_cycle_counter > 0) if (m68kcontext.io_cycle_counter > 0)
{ {

View file

@ -638,9 +638,7 @@ OPCODE(0x007C)
} }
else else
{ {
u32 newPC = (u32)(PC) - BasePC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(newPC-2);
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
#ifdef USE_CYCLONE_TIMING #ifdef USE_CYCLONE_TIMING
RET(0) RET(0)
#else #else
@ -1298,9 +1296,7 @@ OPCODE(0x027C)
} }
else else
{ {
u32 newPC = (u32)(PC) - BasePC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(newPC-2);
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(20) RET(20)
@ -1950,9 +1946,7 @@ OPCODE(0x0A7C)
} }
else else
{ {
u32 newPC = (u32)(PC) - BasePC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(newPC-2);
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(0) RET(0)
} }
RET(20) RET(20)
@ -16570,9 +16564,7 @@ OPCODE(0x46C0)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(12) RET(12)
@ -16601,9 +16593,7 @@ OPCODE(0x46D0)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(16) RET(16)
@ -16633,9 +16623,7 @@ OPCODE(0x46D8)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(16) RET(16)
@ -16665,9 +16653,7 @@ OPCODE(0x46E0)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(18) RET(18)
@ -16697,9 +16683,7 @@ OPCODE(0x46E8)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(20) RET(20)
@ -16729,9 +16713,7 @@ OPCODE(0x46F0)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(22) RET(22)
@ -16761,9 +16743,7 @@ OPCODE(0x46F8)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(20) RET(20)
@ -16792,9 +16772,7 @@ OPCODE(0x46F9)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(24) RET(24)
@ -16820,13 +16798,11 @@ OPCODE(0x46FA)
ASP = res; ASP = res;
} }
POST_IO POST_IO
CHECK_INT_TO_JUMP(24) CHECK_INT_TO_JUMP(20)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(20) RET(20)
@ -16856,9 +16832,7 @@ OPCODE(0x46FB)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(22) RET(22)
@ -16884,9 +16858,7 @@ OPCODE(0x46FC)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(16) RET(16)
@ -16916,9 +16888,7 @@ OPCODE(0x46DF)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(16) RET(16)
@ -16948,9 +16918,7 @@ OPCODE(0x46E7)
} }
else else
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
RET(18) RET(18)
@ -18473,27 +18441,21 @@ RET(10)
// ILLEGAL // ILLEGAL
OPCODE(0x4AFC) OPCODE(0x4AFC)
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_ILLEGAL_INSTRUCTION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_ILLEGAL_INSTRUCTION_EX);
RET(0) RET(0)
} }
// ILLEGAL A000-AFFF // ILLEGAL A000-AFFF
OPCODE(0xA000) OPCODE(0xA000)
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_1010_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_1010_EX);
RET(0) RET(0)
} }
// ILLEGAL F000-FFFF // ILLEGAL F000-FFFF
OPCODE(0xF000) OPCODE(0xF000)
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_1111_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_1111_EX);
RET(0) // 4 already taken by exc. handler RET(0) // 4 already taken by exc. handler
} }
@ -19054,7 +19016,7 @@ RET(12)
// TRAP // TRAP
OPCODE(0x4E40) OPCODE(0x4E40)
{ {
execute_exception(M68K_TRAP_BASE_EX + (Opcode & 0xF)); SET_PC(execute_exception(M68K_TRAP_BASE_EX + (Opcode & 0xF), GET_PC, GET_SR));
RET(4) RET(4)
} }
@ -19125,9 +19087,7 @@ OPCODE(0x4E60)
if (!flag_S) if (!flag_S)
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
res = AREGu32((Opcode >> 0) & 7); res = AREGu32((Opcode >> 0) & 7);
@ -19143,9 +19103,7 @@ OPCODE(0x4E68)
if (!flag_S) if (!flag_S)
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
res = ASP; res = ASP;
@ -19161,9 +19119,7 @@ OPCODE(0x4E70)
if (!flag_S) if (!flag_S)
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
PRE_IO PRE_IO
@ -19187,9 +19143,7 @@ OPCODE(0x4E72)
if (!flag_S) if (!flag_S)
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
FETCH_WORD(res); FETCH_WORD(res);
@ -19214,9 +19168,7 @@ OPCODE(0x4E73)
if (!flag_S) if (!flag_S)
{ {
u32 oldPC=GET_PC; SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
SET_PC(oldPC-2)
execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
RET(4) RET(4)
} }
PRE_IO PRE_IO
@ -19254,7 +19206,7 @@ RET(16)
OPCODE(0x4E76) OPCODE(0x4E76)
{ {
if (flag_V & 0x80) if (flag_V & 0x80)
execute_exception(M68K_TRAPV_EX); SET_PC(execute_exception(M68K_TRAPV_EX, GET_PC, GET_SR));
RET(4) RET(4)
} }
@ -19517,7 +19469,7 @@ OPCODE(0x4180)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
RET(10) RET(10)
} }
@ -19535,7 +19487,7 @@ OPCODE(0x4190)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
POST_IO POST_IO
RET(14) RET(14)
@ -19555,7 +19507,7 @@ OPCODE(0x4198)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
POST_IO POST_IO
RET(14) RET(14)
@ -19575,7 +19527,7 @@ OPCODE(0x41A0)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
POST_IO POST_IO
RET(16) RET(16)
@ -19595,7 +19547,7 @@ OPCODE(0x41A8)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
POST_IO POST_IO
RET(18) RET(18)
@ -19615,7 +19567,7 @@ OPCODE(0x41B0)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
POST_IO POST_IO
RET(20) RET(20)
@ -19634,7 +19586,7 @@ OPCODE(0x41B8)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
POST_IO POST_IO
RET(18) RET(18)
@ -19653,7 +19605,7 @@ OPCODE(0x41B9)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
POST_IO POST_IO
RET(22) RET(22)
@ -19673,7 +19625,7 @@ OPCODE(0x41BA)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
POST_IO POST_IO
RET(18) RET(18)
@ -19693,7 +19645,7 @@ OPCODE(0x41BB)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
POST_IO POST_IO
RET(20) RET(20)
@ -19710,7 +19662,7 @@ OPCODE(0x41BC)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
POST_IO POST_IO
RET(14) RET(14)
@ -19730,7 +19682,7 @@ OPCODE(0x419F)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
POST_IO POST_IO
RET(14) RET(14)
@ -19750,7 +19702,7 @@ OPCODE(0x41A7)
if (((s32)res < 0) || (res > src)) if (((s32)res < 0) || (res > src))
{ {
flag_N = res >> 8; flag_N = res >> 8;
execute_exception(M68K_CHK_EX); SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
} }
POST_IO POST_IO
RET(16) RET(16)
@ -26983,7 +26935,7 @@ OPCODE(0x80C0)
src = DREGu16((Opcode >> 0) & 7); src = DREGu16((Opcode >> 0) & 7);
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(140) RET(140)
#else #else
@ -27031,7 +26983,7 @@ OPCODE(0x80D0)
READ_WORD_F(adr, src) READ_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(144) RET(144)
#else #else
@ -27080,7 +27032,7 @@ OPCODE(0x80D8)
READ_WORD_F(adr, src) READ_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(144) RET(144)
#else #else
@ -27129,7 +27081,7 @@ OPCODE(0x80E0)
READ_WORD_F(adr, src) READ_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(146) RET(146)
#else #else
@ -27178,7 +27130,7 @@ OPCODE(0x80E8)
READ_WORD_F(adr, src) READ_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(148) RET(148)
#else #else
@ -27227,7 +27179,7 @@ OPCODE(0x80F0)
READ_WORD_F(adr, src) READ_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(150) RET(150)
#else #else
@ -27275,7 +27227,7 @@ OPCODE(0x80F8)
READ_WORD_F(adr, src) READ_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(148) RET(148)
#else #else
@ -27323,7 +27275,7 @@ OPCODE(0x80F9)
READ_WORD_F(adr, src) READ_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(162) RET(162)
#else #else
@ -27372,7 +27324,7 @@ OPCODE(0x80FA)
READ_WORD_F(adr, src) READ_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(148) RET(148)
#else #else
@ -27421,7 +27373,7 @@ OPCODE(0x80FB)
READ_WORD_F(adr, src) READ_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(160) RET(160)
#else #else
@ -27467,7 +27419,7 @@ OPCODE(0x80FC)
FETCH_WORD(src); FETCH_WORD(src);
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(144) RET(144)
#else #else
@ -27516,7 +27468,7 @@ OPCODE(0x80DF)
READ_WORD_F(adr, src) READ_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(144) RET(144)
#else #else
@ -27565,7 +27517,7 @@ OPCODE(0x80E7)
READ_WORD_F(adr, src) READ_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
RET(146) RET(146)
#else #else
@ -27611,7 +27563,7 @@ OPCODE(0x81C0)
src = (s32)DREGs16((Opcode >> 0) & 7); src = (s32)DREGs16((Opcode >> 0) & 7);
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81C0; goto end81C0;
#endif #endif
@ -27667,7 +27619,7 @@ OPCODE(0x81D0)
READSX_WORD_F(adr, src) READSX_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81D0; goto end81D0;
#endif #endif
@ -27724,7 +27676,7 @@ OPCODE(0x81D8)
READSX_WORD_F(adr, src) READSX_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81D8; goto end81D8;
#endif #endif
@ -27781,7 +27733,7 @@ OPCODE(0x81E0)
READSX_WORD_F(adr, src) READSX_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81E0; goto end81E0;
#endif #endif
@ -27838,7 +27790,7 @@ OPCODE(0x81E8)
READSX_WORD_F(adr, src) READSX_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81E8; goto end81E8;
#endif #endif
@ -27895,7 +27847,7 @@ OPCODE(0x81F0)
READSX_WORD_F(adr, src) READSX_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81F0; goto end81F0;
#endif #endif
@ -27951,7 +27903,7 @@ OPCODE(0x81F8)
READSX_WORD_F(adr, src) READSX_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81F8; goto end81F8;
#endif #endif
@ -28007,7 +27959,7 @@ OPCODE(0x81F9)
READSX_WORD_F(adr, src) READSX_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81F9; goto end81F9;
#endif #endif
@ -28064,7 +28016,7 @@ OPCODE(0x81FA)
READSX_WORD_F(adr, src) READSX_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81FA; goto end81FA;
#endif #endif
@ -28121,7 +28073,7 @@ OPCODE(0x81FB)
READSX_WORD_F(adr, src) READSX_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81FB; goto end81FB;
#endif #endif
@ -28175,7 +28127,7 @@ OPCODE(0x81FC)
FETCH_SWORD(src); FETCH_SWORD(src);
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81FC; goto end81FC;
#endif #endif
@ -28232,7 +28184,7 @@ OPCODE(0x81DF)
READSX_WORD_F(adr, src) READSX_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81DF; goto end81DF;
#endif #endif
@ -28289,7 +28241,7 @@ OPCODE(0x81E7)
READSX_WORD_F(adr, src) READSX_WORD_F(adr, src)
if (src == 0) if (src == 0)
{ {
execute_exception(M68K_ZERO_DIVIDE_EX); SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV #ifdef USE_CYCLONE_TIMING_DIV
goto end81E7; goto end81E7;
#endif #endif