+#ifdef PICODRIVE_HACK
+#define NOT_POLLING ctx->not_polling = 1;
+#else
+#define NOT_POLLING
+#endif
+
// ORI
OPCODE(0x0000)
{
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
#ifdef USE_CYCLONE_TIMING
RET(0)
#else
flag_NotZ = res;
flag_N = res >> 24;
DREGu32((Opcode >> 0) & 7) = res;
-#ifdef USE_CYCLONE_TIMING
-RET(14)
-#else
RET(16)
-#endif
}
// ANDI
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(20)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
RET(0)
+#else
+ RET(4)
+#endif
}
RET(20)
}
flag_NotZ = res & src;
res ^= src;
DREGu32((Opcode >> 0) & 7) = res;
+#ifdef USE_CYCLONE_TIMING
+ if (src >> 16) ctx->io_cycle_counter -= 2;
+RET(10)
+#else
RET(12)
+#endif
}
// BCHGn
flag_NotZ = res & src;
res &= ~src;
DREGu32((Opcode >> 0) & 7) = res;
+#ifdef USE_CYCLONE_TIMING
+ if (src >> 16) ctx->io_cycle_counter -= 2;
+RET(12)
+#else
RET(14)
+#endif
}
// BCLRn
flag_NotZ = res & src;
res |= src;
DREGu32((Opcode >> 0) & 7) = res;
+#ifdef USE_CYCLONE_TIMING
+ if (src >> 16) ctx->io_cycle_counter -= 2;
+RET(10)
+#else
RET(12)
+#endif
}
// BSETn
src = 1 << (src & 7);
FETCH_BYTE(res);
flag_NotZ = res & src;
-RET(8)
+RET(10)
}
// BTST
flag_NotZ = res & src;
res ^= src;
DREGu32((Opcode >> 0) & 7) = res;
+#ifdef USE_CYCLONE_TIMING
+ if (src >> 16) ctx->io_cycle_counter -= 2;
+RET(6)
+#else
RET(8)
+#endif
}
// BCHG
flag_NotZ = res & src;
res &= ~src;
DREGu32((Opcode >> 0) & 7) = res;
+#ifdef USE_CYCLONE_TIMING
+ if (src >> 16) ctx->io_cycle_counter -= 2;
+RET(8)
+#else
RET(10)
+#endif
}
// BCLR
flag_NotZ = res & src;
res |= src;
DREGu32((Opcode >> 0) & 7) = res;
+#ifdef USE_CYCLONE_TIMING
+ if (src >> 16) ctx->io_cycle_counter -= 2;
+RET(6)
+#else
RET(8)
+#endif
}
// BSET
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
flag_C = 0;
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
flag_C = 0;
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
flag_C = 0;
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
flag_C = 0;
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
flag_C = 0;
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
flag_C = 0;
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
flag_C = 0;
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
flag_C = 0;
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
flag_C = 0;
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
flag_C = 0;
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(12)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(16)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(16)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(18)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(20)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(22)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(20)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(24)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(20)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(22)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(16)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(16)
}
}
else
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+ RET(0)
+#else
RET(4)
+#endif
}
RET(18)
}
u32 adr, res;
u32 src, dst;
- res = DREGu8((Opcode >> 0) & 7);
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ dst = DREGu8((Opcode >> 0) & 7);
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- DREGu8((Opcode >> 0) & 7) = res;
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ DREGu8((Opcode >> 0) & 7) = res;
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
RET(6)
}
adr = AREG((Opcode >> 0) & 7);
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(12)
adr = AREG((Opcode >> 0) & 7);
AREG((Opcode >> 0) & 7) += 1;
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(12)
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(14)
FETCH_SWORD(adr);
adr += AREG((Opcode >> 0) & 7);
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(16)
adr = AREG((Opcode >> 0) & 7);
DECODE_EXT_WORD
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(18)
FETCH_SWORD(adr);
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(16)
FETCH_LONG(adr);
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(20)
adr = AREG(7);
AREG(7) += 2;
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(12)
adr = AREG(7) - 2;
AREG(7) = adr;
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(14)
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(8)
#else
} while (res >>= 1);
AREG((Opcode >> 0) & 7) = adr;
POST_IO
- m68kcontext.io_cycle_counter -= (dst - adr) * 2;
+ ctx->io_cycle_counter -= (dst - adr) * 2;
RET(8)
}
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(12)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(14)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(12)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(16)
#else
} while (res >>= 1);
AREG(7) = adr;
POST_IO
- m68kcontext.io_cycle_counter -= (dst - adr) * 2;
+ ctx->io_cycle_counter -= (dst - adr) * 2;
RET(8)
}
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(8)
#else
} while (res >>= 1);
AREG((Opcode >> 0) & 7) = adr;
POST_IO
- m68kcontext.io_cycle_counter -= (dst - adr) * 2;
+ ctx->io_cycle_counter -= (dst - adr) * 2;
RET(8)
}
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(12)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(14)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(12)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(16)
#else
} while (res >>= 1);
AREG(7) = adr;
POST_IO
- m68kcontext.io_cycle_counter -= (dst - adr) * 2;
+ ctx->io_cycle_counter -= (dst - adr) * 2;
RET(8)
}
flag_NotZ = res;
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(18)
+RET(14)
#else
RET(8)
#endif
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(18)
+RET(14)
#else
RET(8)
#endif
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(20)
+RET(16)
#else
RET(10)
#endif
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(22)
+RET(18)
#else
RET(12)
#endif
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(24)
+RET(20)
#else
RET(14)
#endif
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(22)
+RET(18)
#else
RET(12)
#endif
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(26)
+RET(22)
#else
RET(16)
#endif
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(18)
+RET(14)
#else
RET(8)
#endif
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
// ILLEGAL
OPCODE(0x4AFC)
{
- SET_PC(execute_exception(M68K_ILLEGAL_INSTRUCTION_EX, GET_PC-2, GET_SR));
+#ifdef PICODRIVE_HACK
+ extern void SekFinishIdleDet(void);
+ SekFinishIdleDet();
+#endif
+ SET_PC(execute_exception(ctx, M68K_ILLEGAL_INSTRUCTION_EX, GET_PC-2, GET_SR));
RET(0)
}
// ILLEGAL A000-AFFF
OPCODE(0xA000)
{
- SET_PC(execute_exception(M68K_1010_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_1010_EX, GET_PC-2, GET_SR));
RET(0)
}
// ILLEGAL F000-FFFF
OPCODE(0xF000)
{
- SET_PC(execute_exception(M68K_1111_EX, GET_PC-2, GET_SR));
-RET(0) // 4 already taken by exc. handler
+ SET_PC(execute_exception(ctx, M68K_1111_EX, GET_PC-2, GET_SR));
+RET(0)
}
// MOVEMaR
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(12)
#else
} while (res >>= 1);
AREG((Opcode >> 0) & 7) = adr;
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
RET(12)
}
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(16)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(18)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(16)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(20)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(16)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(18)
#else
} while (res >>= 1);
AREG(7) = adr;
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
RET(12)
}
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(12)
#else
} while (res >>= 1);
AREG((Opcode >> 0) & 7) = adr;
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
RET(12)
}
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(16)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(18)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(16)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(20)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(16)
#else
psrc++;
} while (res >>= 1);
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
#ifdef USE_CYCLONE_TIMING
RET(18)
#else
} while (res >>= 1);
AREG(7) = adr;
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
RET(12)
}
// TRAP
OPCODE(0x4E40)
{
- SET_PC(execute_exception(M68K_TRAP_BASE_EX + (Opcode & 0xF), GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_TRAP_BASE_EX + (Opcode & 0xF), GET_PC, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+RET(0)
+#else
RET(4)
+#endif
}
// LINK
if (!flag_S)
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+RET(0)
+#else
RET(4)
+#endif
}
res = AREGu32((Opcode >> 0) & 7);
ASP = res;
if (!flag_S)
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+RET(0)
+#else
RET(4)
+#endif
}
res = ASP;
AREG((Opcode >> 0) & 7) = res;
if (!flag_S)
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+RET(0)
+#else
RET(4)
+#endif
}
PRE_IO
- if (m68kcontext.reset_handler) m68kcontext.reset_handler();
+ if (ctx->reset_handler) ctx->reset_handler();
// CPU->Reset_CallBack();
POST_IO
RET(132)
if (!flag_S)
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+RET(0)
+#else
RET(4)
+#endif
}
FETCH_WORD(res);
res &= M68K_SR_MASK;
AREG(7) = ASP;
ASP = res;
}
- m68kcontext.execinfo |= FM68K_HALTED;
+ ctx->execinfo |= FM68K_HALTED;
RET0()
}
if (!flag_S)
{
- SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+RET(0)
+#else
RET(4)
+#endif
}
PRE_IO
POP_16_F(res)
AREG(7) = ASP;
ASP = res;
}
+ CHECK_BRANCH_EXCEPTION(res)
POST_IO
- m68kcontext.execinfo &= ~(FM68K_EMULATE_GROUP_0|FM68K_EMULATE_TRACE|FM68K_DO_TRACE);
+ ctx->execinfo &= ~(FM68K_EMULATE_GROUP_0|FM68K_EMULATE_TRACE|FM68K_DO_TRACE);
CHECK_INT_TO_JUMP(20)
RET(20)
}
// TRAPV
OPCODE(0x4E76)
{
- if (flag_V & 0x80)
- SET_PC(execute_exception(M68K_TRAPV_EX, GET_PC, GET_SR));
+ if (flag_V & 0x80) {
+ SET_PC(execute_exception(ctx, M68K_TRAPV_EX, GET_PC, GET_SR));
+#ifdef USE_CYCLONE_TIMING
+RET(0)
+#endif
+ }
RET(4)
}
// CHK
OPCODE(0x4180)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
- src = DREGu16((Opcode >> 0) & 7);
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ src = DREGs16((Opcode >> 0) & 7);
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(4)
}
RET(10)
}
// CHK
OPCODE(0x4190)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG((Opcode >> 0) & 7);
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(8)
}
POST_IO
RET(14)
// CHK
OPCODE(0x4198)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG((Opcode >> 0) & 7);
AREG((Opcode >> 0) & 7) += 2;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(8)
}
POST_IO
RET(14)
// CHK
OPCODE(0x41A0)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG((Opcode >> 0) & 7) - 2;
AREG((Opcode >> 0) & 7) = adr;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(10)
}
POST_IO
RET(16)
// CHK
OPCODE(0x41A8)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
FETCH_SWORD(adr);
adr += AREG((Opcode >> 0) & 7);
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(12)
}
POST_IO
RET(18)
// CHK
OPCODE(0x41B0)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG((Opcode >> 0) & 7);
DECODE_EXT_WORD
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(14)
}
POST_IO
RET(20)
// CHK
OPCODE(0x41B8)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
FETCH_SWORD(adr);
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(12)
}
POST_IO
RET(18)
// CHK
OPCODE(0x41B9)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
FETCH_LONG(adr);
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(16)
}
POST_IO
RET(22)
// CHK
OPCODE(0x41BA)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = GET_SWORD + GET_PC;
PC++;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(12)
}
POST_IO
RET(18)
// CHK
OPCODE(0x41BB)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(14)
}
POST_IO
RET(20)
// CHK
OPCODE(0x41BC)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
- FETCH_WORD(src);
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ FETCH_SWORD(src);
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(8)
}
POST_IO
RET(14)
// CHK
OPCODE(0x419F)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG(7);
AREG(7) += 2;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(8)
}
POST_IO
RET(14)
// CHK
OPCODE(0x41A7)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG(7) - 2;
AREG(7) = adr;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
+RET(10)
}
POST_IO
RET(16)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
res = DREGu16((Opcode >> 0) & 7);
res--;
DREGu16((Opcode >> 0) & 7) = res;
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if ((!flag_NotZ) || (flag_C & 0x100))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_NotZ && (!(flag_C & 0x100)))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_C & 0x100)
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!(flag_C & 0x100))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!flag_NotZ)
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_NotZ)
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_V & 0x80)
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!(flag_V & 0x80))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_N & 0x80)
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!(flag_N & 0x80))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if ((flag_N ^ flag_V) & 0x80)
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!((flag_N ^ flag_V) & 0x80))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if ((!flag_NotZ) || ((flag_N ^ flag_V) & 0x80))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_NotZ && (!((flag_N ^ flag_V) & 0x80)))
{
res = DREGu16((Opcode >> 0) & 7);
dst = AREGu32((Opcode >> 0) & 7);
res = dst + src;
AREG((Opcode >> 0) & 7) = res;
-#ifdef USE_CYCLONE_TIMING
-RET(4)
-#else
RET(8)
-#endif
}
// ADDQ
if (flag_NotZ && (!(flag_C & 0x100)))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if ((!flag_NotZ) || (flag_C & 0x100))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (!(flag_C & 0x100))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (flag_C & 0x100)
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (flag_NotZ)
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (!flag_NotZ)
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (!(flag_V & 0x80))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (flag_V & 0x80)
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (!(flag_N & 0x80))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (flag_N & 0x80)
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (!((flag_N ^ flag_V) & 0x80))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if ((flag_N ^ flag_V) & 0x80)
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (flag_NotZ && (!((flag_N ^ flag_V) & 0x80)))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if ((!flag_NotZ) || ((flag_N ^ flag_V) & 0x80))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
src = DREGu8((Opcode >> 0) & 7);
dst = DREGu8((Opcode >> 9) & 7);
res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res -= 6;
+ if (res > 0xF) corf = 6;
res += (dst & 0xF0) - (src & 0xF0);
- if (res > 0x99)
- {
- res += 0xA0;
- flag_X = flag_C = M68K_SR_C;
- }
- else flag_X = flag_C = 0;
- flag_NotZ |= res & 0xFF;
+ flag_V = res;
+ flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+ if (res > 0xff) res += 0xA0;
+ res = (res - corf) & 0xFF;
+ flag_V &= ~res;
+ flag_NotZ |= res;
flag_N = res;
DREGu8((Opcode >> 9) & 7) = res;
RET(6)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
AREG((Opcode >> 9) & 7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res -= 6;
+ if (res > 0xF) corf = 6;
res += (dst & 0xF0) - (src & 0xF0);
- if (res > 0x99)
- {
- res += 0xA0;
- flag_X = flag_C = M68K_SR_C;
- }
- else flag_X = flag_C = 0;
- flag_NotZ |= res & 0xFF;
+ flag_V = res;
+ flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+ if (res > 0xff) res += 0xA0;
+ res = (res - corf) & 0xFF;
+ flag_V &= ~res;
+ flag_NotZ |= res;
flag_N = res;
WRITE_BYTE_F(adr, res)
POST_IO
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG(7) - 2;
AREG(7) = adr;
AREG((Opcode >> 9) & 7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res -= 6;
+ if (res > 0xF) corf = 6;
res += (dst & 0xF0) - (src & 0xF0);
- if (res > 0x99)
- {
- res += 0xA0;
- flag_X = flag_C = M68K_SR_C;
- }
- else flag_X = flag_C = 0;
- flag_NotZ |= res & 0xFF;
+ flag_V = res;
+ flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+ if (res > 0xff) res += 0xA0;
+ res = (res - corf) & 0xFF;
+ flag_V &= ~res;
+ flag_NotZ |= res;
flag_N = res;
WRITE_BYTE_F(adr, res)
POST_IO
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
AREG(7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res -= 6;
+ if (res > 0xF) corf = 6;
res += (dst & 0xF0) - (src & 0xF0);
- if (res > 0x99)
- {
- res += 0xA0;
- flag_X = flag_C = M68K_SR_C;
- }
- else flag_X = flag_C = 0;
- flag_NotZ |= res & 0xFF;
+ flag_V = res;
+ flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+ if (res > 0xff) res += 0xA0;
+ res = (res - corf) & 0xFF;
+ flag_V &= ~res;
+ flag_NotZ |= res;
flag_N = res;
WRITE_BYTE_F(adr, res)
POST_IO
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG(7) - 2;
AREG(7) = adr;
AREG(7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res -= 6;
+ if (res > 0xF) corf = 6;
res += (dst & 0xF0) - (src & 0xF0);
- if (res > 0x99)
- {
- res += 0xA0;
- flag_X = flag_C = M68K_SR_C;
- }
- else flag_X = flag_C = 0;
- flag_NotZ |= res & 0xFF;
+ flag_V = res;
+ flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+ if (res > 0xff) res += 0xA0;
+ res = (res - corf) & 0xFF;
+ flag_V &= ~res;
+ flag_NotZ |= res;
flag_N = res;
WRITE_BYTE_F(adr, res)
POST_IO
src = DREGu16((Opcode >> 0) & 7);
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(140)
+RET(4)
#else
-RET(10)
+RET(14)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(140)
+RET(10)
#else
RET(70)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(140)
+RET(138-BITCOUNT(res,q)*2)
#else
RET(90)
#endif
+ }
}
// DIVU
READ_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(144)
+RET(8)
#else
-RET(14)
+RET(18)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(144)
+RET(14)
#else
RET(74)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(144)
+RET(142-BITCOUNT(res,q)*2)
#else
RET(94)
#endif
+ }
}
// DIVU
READ_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(144)
+RET(8)
#else
-RET(14)
+RET(18)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(144)
+RET(14)
#else
RET(74)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(144)
+RET(142-BITCOUNT(res,q)*2)
#else
RET(94)
#endif
+ }
}
// DIVU
READ_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(146)
+RET(10)
#else
-RET(16)
+RET(20)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(146)
+RET(16)
#else
RET(76)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(146)
+RET(144-BITCOUNT(res,q)*2)
#else
RET(96)
#endif
+ }
}
// DIVU
READ_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(148)
+RET(12)
#else
-RET(18)
+RET(22)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(148)
+RET(18)
#else
RET(78)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(148)
+RET(146-BITCOUNT(res,q)*2)
#else
RET(98)
#endif
+ }
}
// DIVU
READ_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(150)
+RET(14)
#else
-RET(20)
+RET(24)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(150)
+RET(20)
#else
RET(80)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(150)
+RET(148-BITCOUNT(res,q)*2)
#else
RET(100)
#endif
+ }
}
// DIVU
READ_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(148)
+RET(12)
#else
-RET(18)
+RET(22)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(148)
+RET(18)
#else
RET(78)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(148)
+RET(146-BITCOUNT(res,q)*2)
#else
RET(98)
#endif
+ }
}
// DIVU
READ_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(162)
+RET(16)
#else
-RET(22)
+RET(26)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(162)
+RET(22)
#else
RET(82)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(162)
+RET(150-BITCOUNT(res,q)*2)
#else
RET(102)
#endif
+ }
}
// DIVU
READ_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(148)
+RET(12)
#else
-RET(18)
+RET(22)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(148)
+RET(18)
#else
RET(78)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(148)
+RET(146-BITCOUNT(res,q)*2)
#else
RET(98)
#endif
+ }
}
// DIVU
READ_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(160)
+RET(14)
#else
-RET(20)
+RET(24)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(160)
+RET(20)
#else
RET(80)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(160)
+RET(148-BITCOUNT(res,q)*2)
#else
RET(100)
#endif
+ }
}
// DIVU
FETCH_WORD(src);
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(144)
+RET(8)
#else
-RET(14)
+RET(18)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(144)
+RET(14)
#else
RET(74)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(144)
+RET(142-BITCOUNT(res,q)*2)
#else
RET(94)
#endif
+ }
}
// DIVU
READ_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(144)
+RET(8)
#else
-RET(14)
+RET(18)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(144)
+RET(14)
#else
RET(74)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(144)
+RET(142-BITCOUNT(res,q)*2)
#else
RET(94)
#endif
+ }
}
// DIVU
READ_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(146)
+RET(10)
#else
-RET(16)
+RET(20)
#endif
}
dst = DREGu32((Opcode >> 9) & 7);
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(146)
+RET(16)
#else
RET(76)
#endif
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-RET(146)
+RET(144-BITCOUNT(res,q)*2)
#else
RET(96)
#endif
+ }
}
// DIVS
src = (s32)DREGs16((Opcode >> 0) & 7);
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81C0;
+RET(4)
+#else
+ RET(14)
#endif
- RET(10)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81C0;
-#endif
+RET(16+(dst>>31)*2)
+#else
RET(50)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81C0;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(16+(dst>>31)*2)
+} else RET(152+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(80)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81C0: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(152+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(108)
+#endif
+ }
}
// DIVS
READSX_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81D0;
+RET(8)
+#else
+ RET(18)
#endif
- RET(14)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81D0;
-#endif
+RET(20+(dst>>31)*2)
+#else
RET(54)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81D0;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(20+(dst>>31)*2)
+} else RET(156+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(84)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81D0: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(156+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(112)
+#endif
+ }
}
// DIVS
READSX_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81D8;
+RET(8)
+#else
+ RET(18)
#endif
- RET(14)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81D8;
-#endif
+RET(20+(dst>>31)*2)
+#else
RET(54)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81D8;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(20+(dst>>31)*2)
+} else RET(156+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(84)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81D8: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(156+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(112)
+#endif
+ }
}
// DIVS
READSX_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81E0;
+RET(10)
+#else
+ RET(20)
#endif
- RET(16)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81E0;
-#endif
+RET(22+(dst>>31)*2)
+#else
RET(56)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81E0;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(22+(dst>>31)*2)
+} else RET(158+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(86)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81E0: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(158+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(114)
+#endif
+ }
}
// DIVS
READSX_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81E8;
+RET(12)
+#else
+ RET(22)
#endif
- RET(18)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81E8;
-#endif
+RET(24+(dst>>31)*2)
+#else
RET(58)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81E8;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(24+(dst>>31)*2)
+} else RET(160+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(88)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81E8: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(160+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(116)
+#endif
+ }
}
// DIVS
READSX_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81F0;
+RET(14)
+#else
+ RET(24)
#endif
- RET(20)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81F0;
-#endif
+RET(26+(dst>>31)*2)
+#else
RET(60)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81F0;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(26+(dst>>31)*2)
+} else RET(162+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(90)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81F0: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(162+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(118)
+#endif
+ }
}
// DIVS
READSX_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81F8;
+RET(12)
+#else
+ RET(22)
#endif
- RET(18)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81F8;
-#endif
+RET(24+(dst>>31)*2)
+#else
RET(58)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81F8;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(24+(dst>>31)*2)
+} else RET(160+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(88)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81F8: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(160+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(116)
+#endif
+ }
}
// DIVS
READSX_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81F9;
+RET(16)
+#else
+ RET(26)
#endif
- RET(22)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81F9;
-#endif
+RET(28+(dst>>31)*2)
+#else
RET(62)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81F9;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(28+(dst>>31)*2)
+} else RET(164+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(92)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81F9: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(164+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(120)
+#endif
+ }
}
// DIVS
READSX_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81FA;
+RET(12)
+#else
+ RET(22)
#endif
- RET(18)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81FA;
-#endif
+RET(24+(dst>>31)*2)
+#else
RET(58)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81FA;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(24+(dst>>31)*2)
+} else RET(160+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(88)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81FA: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(160+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(116)
+#endif
+ }
}
// DIVS
READSX_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81FB;
+RET(14)
+#else
+ RET(24)
#endif
- RET(20)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81FB;
-#endif
+RET(26+(dst>>31)*2)
+#else
RET(60)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81FB;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(26+(dst>>31)*2)
+} else RET(162+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(90)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81FB: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(162+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(118)
+#endif
+ }
}
// DIVS
FETCH_SWORD(src);
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81FC;
+RET(8)
+#else
+ RET(18)
#endif
- RET(14)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81FC;
-#endif
+RET(20+(dst>>31)*2)
+#else
RET(54)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81FC;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(20+(dst>>31)*2)
+} else RET(156+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(84)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81FC: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(156+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(112)
+#endif
+ }
}
// DIVS
READSX_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81DF;
+RET(8)
+#else
+ RET(18)
#endif
- RET(14)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81DF;
-#endif
+RET(20+(dst>>31)*2)
+#else
RET(54)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81DF;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(20+(dst>>31)*2)
+} else RET(156+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(84)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81DF: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(156+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(112)
+#endif
+ }
}
// DIVS
READSX_WORD_F(adr, src)
if (src == 0)
{
- SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81E7;
+RET(10)
+#else
+ RET(20)
#endif
- RET(16)
}
dst = DREGu32((Opcode >> 9) & 7);
if ((dst == 0x80000000) && (src == (u32)-1))
res = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81E7;
-#endif
+RET(22+(dst>>31)*2)
+#else
RET(56)
+#endif
}
{
s32 q, r;
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-goto end81E7;
-#endif
+if (q > 0xFFFF || q < -0x10000) {
+ RET(22+(dst>>31)*2)
+} else RET(158+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(86)
+#endif
}
q &= 0x0000FFFF;
flag_NotZ = q;
flag_V = flag_C = 0;
res = q | (r << 16);
DREGu32((Opcode >> 9) & 7) = res;
- }
#ifdef USE_CYCLONE_TIMING_DIV
-end81E7: m68kcontext.io_cycle_counter -= 50;
-#endif
+RET(158+(dst>>31)*4-(q>>31)*2-BITCOUNT(res,abs(q))*2)
+#else
RET(114)
+#endif
+ }
}
// SUBaD
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
dst = DREGu8((Opcode >> 9) & 7);
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
dst = DREGu8((Opcode >> 9) & 7);
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
src = DREGu8((Opcode >> 0) & 7);
dst = DREGu8((Opcode >> 9) & 7);
res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res += 6;
+ if (res > 9) corf = 6;
res += (dst & 0xF0) + (src & 0xF0);
- if (res > 0x99)
+ flag_V = ~res;
+ res += corf;
+ if (res > 0x9F)
{
res -= 0xA0;
flag_X = flag_C = M68K_SR_C;
}
else flag_X = flag_C = 0;
+ flag_V &= res;
flag_NotZ |= res & 0xFF;
flag_N = res;
DREGu8((Opcode >> 9) & 7) = res;
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
AREG((Opcode >> 9) & 7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res += 6;
+ if (res > 9) corf = 6;
res += (dst & 0xF0) + (src & 0xF0);
- if (res > 0x99)
+ flag_V = ~res;
+ res += corf;
+ if (res > 0x9F)
{
res -= 0xA0;
flag_X = flag_C = M68K_SR_C;
}
else flag_X = flag_C = 0;
+ flag_V &= res;
flag_NotZ |= res & 0xFF;
flag_N = res;
WRITE_BYTE_F(adr, res)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG(7) - 2;
AREG(7) = adr;
AREG((Opcode >> 9) & 7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res += 6;
+ if (res > 9) corf = 6;
res += (dst & 0xF0) + (src & 0xF0);
- if (res > 0x99)
+ flag_V = ~res;
+ res += corf;
+ if (res > 0x9F)
{
res -= 0xA0;
flag_X = flag_C = M68K_SR_C;
}
else flag_X = flag_C = 0;
+ flag_V &= res;
flag_NotZ |= res & 0xFF;
flag_N = res;
WRITE_BYTE_F(adr, res)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
AREG(7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res += 6;
+ if (res > 9) corf = 6;
res += (dst & 0xF0) + (src & 0xF0);
- if (res > 0x99)
+ flag_V = ~res;
+ res += corf;
+ if (res > 0x9F)
{
res -= 0xA0;
flag_X = flag_C = M68K_SR_C;
}
else flag_X = flag_C = 0;
+ flag_V &= res;
flag_NotZ |= res & 0xFF;
flag_N = res;
WRITE_BYTE_F(adr, res)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG(7) - 2;
AREG(7) = adr;
AREG(7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res += 6;
+ if (res > 9) corf = 6;
res += (dst & 0xF0) + (src & 0xF0);
- if (res > 0x99)
+ flag_V = ~res;
+ res += corf;
+ if (res > 0x9F)
{
res -= 0xA0;
flag_X = flag_C = M68K_SR_C;
}
else flag_X = flag_C = 0;
+ flag_V &= res;
flag_NotZ |= res & 0xFF;
flag_N = res;
WRITE_BYTE_F(adr, res)
flag_V = flag_C = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING
-RET(54)
+RET(38+BITCOUNT(res,src)*2)
#else
RET(50)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(58)
+RET(42+BITCOUNT(res,src)*2)
#else
RET(54)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(58)
+RET(42+BITCOUNT(res,src)*2)
#else
RET(54)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(60)
+RET(44+BITCOUNT(res,src)*2)
#else
RET(56)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(62)
+RET(46+BITCOUNT(res,src)*2)
#else
RET(58)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(64)
+RET(48+BITCOUNT(res,src)*2)
#else
RET(60)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(62)
+RET(46+BITCOUNT(res,src)*2)
#else
RET(58)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(66)
+RET(50+BITCOUNT(res,src)*2)
#else
RET(62)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(62)
+RET(46+BITCOUNT(res,src)*2)
#else
RET(58)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(64)
+RET(48+BITCOUNT(res,src)*2)
#else
RET(60)
#endif
flag_V = flag_C = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING
-RET(58)
+RET(42+BITCOUNT(res,src)*2)
#else
RET(54)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(58)
+RET(42+BITCOUNT(res,src)*2)
#else
RET(54)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(60)
+RET(44+BITCOUNT(res,src)*2)
#else
RET(56)
#endif
flag_V = flag_C = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING
-RET(54)
+RET(38+BITCOUNT(res,src^(src<<1)))
#else
RET(50)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(58)
+RET(42+BITCOUNT(res,src^(src<<1))*2)
#else
RET(54)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(58)
+RET(42+BITCOUNT(res,src^(src<<1))*2)
#else
RET(54)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(60)
+RET(44+BITCOUNT(res,src^(src<<1))*2)
#else
RET(56)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(62)
+RET(46+BITCOUNT(res,src^(src<<1))*2)
#else
RET(58)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(64)
+RET(48+BITCOUNT(res,src^(src<<1))*2)
#else
RET(60)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(62)
+RET(46+BITCOUNT(res,src^(src<<1))*2)
#else
RET(58)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(66)
+RET(50+BITCOUNT(res,src^(src<<1))*2)
#else
RET(62)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(62)
+RET(46+BITCOUNT(res,src^(src<<1))*2)
#else
RET(58)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(64)
+RET(48+BITCOUNT(res,src^(src<<1))*2)
#else
RET(60)
#endif
flag_V = flag_C = 0;
DREGu32((Opcode >> 9) & 7) = res;
#ifdef USE_CYCLONE_TIMING
-RET(58)
+RET(42+BITCOUNT(res,src^(src<<1))*2)
#else
RET(54)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(58)
+RET(42+BITCOUNT(res,src^(src<<1))*2)
#else
RET(54)
#endif
DREGu32((Opcode >> 9) & 7) = res;
POST_IO
#ifdef USE_CYCLONE_TIMING
-RET(60)
+RET(44+BITCOUNT(res,src^(src<<1))*2)
#else
RET(56)
#endif
u32 src, dst;
// can't read byte from Ax registers !
- m68kcontext.execinfo |= M68K_FAULTED;
- m68kcontext.io_cycle_counter = 0;
+ ctx->execinfo |= M68K_FAULTED;
+ ctx->io_cycle_counter = 0;
/*
goto famec_Exec_End;
dst = DREGu8((Opcode >> 9) & 7);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = (s32)DREGs8((Opcode >> 0) & 7);
flag_V = 0;
flag_X = flag_C = src << ((M68K_SR_C_SFT + 1) - sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = (s32)DREGs16((Opcode >> 0) & 7);
flag_V = 0;
flag_X = flag_C = src << ((M68K_SR_C_SFT + 1) - sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = (s32)DREGs32((Opcode >> 0) & 7);
flag_V = 0;
flag_X = flag_C = src << ((M68K_SR_C_SFT + 1) - sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu8((Opcode >> 0) & 7);
flag_N = flag_V = 0;
flag_X = flag_C = src << ((M68K_SR_C_SFT + 1) - sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu16((Opcode >> 0) & 7);
flag_N = flag_V = 0;
flag_X = flag_C = src << ((M68K_SR_C_SFT + 1) - sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu32((Opcode >> 0) & 7);
flag_N = flag_V = 0;
flag_X = flag_C = src << ((M68K_SR_C_SFT + 1) - sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu8((Opcode >> 0) & 7);
src |= (flag_X & M68K_SR_X) << 0;
res = (src >> sft) | (src << (9 - sft));
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu16((Opcode >> 0) & 7);
src |= (flag_X & M68K_SR_X) << 8;
res = (src >> sft) | (src << (17 - sft));
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu32((Opcode >> 0) & 7);
flag_C = src << ((M68K_SR_C_SFT + 1) - sft);
if (sft == 1) res = (src >> 1) | ((flag_X & M68K_SR_X) << (32 - (M68K_SR_X_SFT + 1)));
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu8((Opcode >> 0) & 7);
flag_V = 0;
flag_C = src << ((M68K_SR_C_SFT + 1) - sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu16((Opcode >> 0) & 7);
flag_V = 0;
flag_C = src << ((M68K_SR_C_SFT + 1) - sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu32((Opcode >> 0) & 7);
flag_V = 0;
flag_C = src << ((M68K_SR_C_SFT + 1) - sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu8((Opcode >> 0) & 7);
if (sft < 8)
{
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu16((Opcode >> 0) & 7);
flag_X = flag_C = src >> (8 - sft);
res = src << sft;
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu32((Opcode >> 0) & 7);
flag_X = flag_C = src >> (24 - sft);
res = src << sft;
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu8((Opcode >> 0) & 7);
flag_V = 0;
flag_X = flag_C = src << (0 + sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu16((Opcode >> 0) & 7);
flag_V = 0;
flag_X = flag_C = src >> (8 - sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu32((Opcode >> 0) & 7);
flag_V = 0;
flag_X = flag_C = src >> (24 - sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu8((Opcode >> 0) & 7);
src |= (flag_X & M68K_SR_X) << 0;
res = (src << sft) | (src >> (9 - sft));
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu16((Opcode >> 0) & 7);
src |= (flag_X & M68K_SR_X) << 8;
res = (src << sft) | (src >> (17 - sft));
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu32((Opcode >> 0) & 7);
flag_C = src >> ((32 - M68K_SR_C_SFT) - sft);
if (sft == 1) res = (src << 1) | ((flag_X & M68K_SR_X) >> ((M68K_SR_X_SFT + 1) - 1));
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu8((Opcode >> 0) & 7);
flag_V = 0;
flag_C = src << (0 + sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu16((Opcode >> 0) & 7);
flag_V = 0;
flag_C = src >> (8 - sft);
u32 sft;
sft = (((Opcode >> 9) - 1) & 7) + 1;
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
src = DREGu32((Opcode >> 0) & 7);
flag_V = 0;
flag_C = src >> (24 - sft);
src = (s32)DREGs8((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft < 8)
{
flag_V = 0;
src = (s32)DREGs16((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft < 16)
{
flag_V = 0;
src = (s32)DREGs32((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft < 32)
{
flag_V = 0;
src = DREGu8((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft <= 8)
{
flag_N = flag_V = 0;
src = DREGu16((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft <= 16)
{
flag_N = flag_V = 0;
src = DREGu32((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft < 32)
{
flag_N = flag_V = 0;
src = DREGu8((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
sft %= 9;
src |= (flag_X & M68K_SR_X) << 0;
src = DREGu16((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
sft %= 17;
src |= (flag_X & M68K_SR_X) << 8;
src = DREGu32((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
sft %= 33;
if (sft != 0)
{
if (sft == 1) res = (src >> 1) | ((flag_X & M68K_SR_X) << (32 - (M68K_SR_X_SFT + 1)));
else res = (src >> sft) | (src << (33 - sft)) | (((flag_X & M68K_SR_X) << (32 - (M68K_SR_X_SFT + 1))) >> (sft - 1));
- flag_X = (src >> (32 - sft)) << M68K_SR_X_SFT;
+ flag_X = (src >> (sft - 1)) << M68K_SR_X_SFT;
}
else res = src;
flag_C = flag_X;
src = DREGu8((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
sft &= 0x07;
flag_C = src << (M68K_SR_C_SFT - ((sft - 1) & 7));
src = DREGu16((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
sft &= 0x0F;
flag_C = (src >> ((sft - 1) & 15)) << M68K_SR_C_SFT;
src = DREGu32((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
sft &= 0x1F;
flag_C = (src >> ((sft - 1) & 31)) << M68K_SR_C_SFT;
src = DREGu8((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft < 8)
{
flag_X = flag_C = (src << sft) >> 0;
src = DREGu16((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft < 16)
{
flag_X = flag_C = (src << sft) >> 8;
src = DREGu32((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft < 32)
{
flag_X = flag_C = (src >> (32 - sft)) << M68K_SR_C_SFT;
src = DREGu8((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft <= 8)
{
flag_X = flag_C = (src << sft) >> 0;
src = DREGu16((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft <= 16)
{
flag_X = flag_C = (src << sft) >> 8;
src = DREGu32((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft < 32)
{
flag_X = flag_C = (src >> (32 - sft)) << M68K_SR_C_SFT;
src = DREGu8((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
sft %= 9;
src |= (flag_X & M68K_SR_X) << 0;
src = DREGu16((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
sft %= 17;
src |= (flag_X & M68K_SR_X) << 8;
src = DREGu32((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
sft %= 33;
if (sft != 0)
src = DREGu8((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft &= 0x07)
{
flag_C = (src << sft) >> 0;
src = DREGu16((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft &= 0x0F)
{
flag_C = (src << sft) >> 8;
src = DREGu32((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
if (sft &= 0x1F)
{
flag_C = (src >> (32 - sft)) << M68K_SR_C_SFT;
}
+extern int SekIsIdleReady(void);
extern int SekIsIdleCode(unsigned short *dst, int bytes);
extern int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop, void *ctx);
OPCODE(idle_detector_bcc8)
{
- extern int idledet_start_frame;
- extern char Pico[];
int frame_count, cond_true, bytes, ret, newop;
u16 *dest_pc;
dest_pc = PC + (((s8)(Opcode & 0xFE)) >> 1);
- frame_count = *(int *)(Pico+0x22208+0x1c); // Pico.m.frame_count
- if (frame_count < idledet_start_frame)
+ if (!SekIsIdleReady())
goto end;
bytes = 0 - (s8)(Opcode & 0xFE) - 2;
if ( Opcode & 0x0100) newop |= 0x400; // beq
if (!(Opcode & 0x0f00)) newop |= 0xc00; // bra
- ret = SekRegisterIdlePatch(GET_PC - 2, Opcode, newop, &m68kcontext);
+ ret = SekRegisterIdlePatch(GET_PC - 2, Opcode, newop, ctx);
switch (ret)
{
case 0: PC[-1] = newop; break;
if (cond_true)
{
PC = dest_pc;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}