Perform NULL segment checks upfront in opcode handlers, rather than on every memory access.
This removes the need to pass the segment to readmem*l()/writemem*l().
This commit is contained in:
parent
648aa0e3e8
commit
0f0a1c3223
31 changed files with 976 additions and 325 deletions
|
|
@ -14,9 +14,11 @@
|
|||
} \
|
||||
else \
|
||||
{ \
|
||||
uint8_t dst = geteab(); if (cpu_state.abrt) return 1; \
|
||||
uint8_t dst; \
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||
dst = geteab(); if (cpu_state.abrt) return 1; \
|
||||
uint8_t src = getr8(cpu_reg); \
|
||||
seteab(operation); if (cpu_state.abrt) return 1; \
|
||||
seteab(operation); if (cpu_state.abrt) return 1; \
|
||||
setflags ## 8 flagops; \
|
||||
CLOCK_CYCLES(timing_mr); \
|
||||
PREFETCH_RUN(timing_mr, 2, rmdat, 1,0,1,0, 0); \
|
||||
|
|
@ -38,7 +40,9 @@
|
|||
} \
|
||||
else \
|
||||
{ \
|
||||
uint8_t dst = geteab(); if (cpu_state.abrt) return 1; \
|
||||
uint8_t dst; \
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||
dst = geteab(); if (cpu_state.abrt) return 1; \
|
||||
uint8_t src = getr8(cpu_reg); \
|
||||
seteab(operation); if (cpu_state.abrt) return 1; \
|
||||
setflags ## 8 flagops; \
|
||||
|
|
@ -63,7 +67,9 @@
|
|||
} \
|
||||
else \
|
||||
{ \
|
||||
uint16_t dst = geteaw(); if (cpu_state.abrt) return 1; \
|
||||
uint16_t dst; \
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||
dst = geteaw(); if (cpu_state.abrt) return 1; \
|
||||
uint16_t src = cpu_state.regs[cpu_reg].w; \
|
||||
seteaw(operation); if (cpu_state.abrt) return 1; \
|
||||
setflags ## 16 flagops; \
|
||||
|
|
@ -87,7 +93,9 @@
|
|||
} \
|
||||
else \
|
||||
{ \
|
||||
uint16_t dst = geteaw(); if (cpu_state.abrt) return 1; \
|
||||
uint16_t dst; \
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||
dst = geteaw(); if (cpu_state.abrt) return 1; \
|
||||
uint16_t src = cpu_state.regs[cpu_reg].w; \
|
||||
seteaw(operation); if (cpu_state.abrt) return 1; \
|
||||
setflags ## 16 flagops; \
|
||||
|
|
@ -112,7 +120,9 @@
|
|||
} \
|
||||
else \
|
||||
{ \
|
||||
uint32_t dst = geteal(); if (cpu_state.abrt) return 1; \
|
||||
uint32_t dst; \
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||
dst = geteal(); if (cpu_state.abrt) return 1; \
|
||||
uint32_t src = cpu_state.regs[cpu_reg].l; \
|
||||
seteal(operation); if (cpu_state.abrt) return 1; \
|
||||
setflags ## 32 flagops; \
|
||||
|
|
@ -136,7 +146,9 @@
|
|||
} \
|
||||
else \
|
||||
{ \
|
||||
uint32_t dst = geteal(); if (cpu_state.abrt) return 1; \
|
||||
uint32_t dst; \
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||
dst = geteal(); if (cpu_state.abrt) return 1; \
|
||||
uint32_t src = cpu_state.regs[cpu_reg].l; \
|
||||
seteal(operation); if (cpu_state.abrt) return 1; \
|
||||
setflags ## 32 flagops; \
|
||||
|
|
@ -151,6 +163,8 @@
|
|||
uint8_t dst, src; \
|
||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
||||
fetch_ea_16(fetchdat); \
|
||||
if (cpu_mod != 3) \
|
||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||
dst = getr8(cpu_reg); \
|
||||
src = geteab(); if (cpu_state.abrt) return 1; \
|
||||
setflags ## 8 flagops; \
|
||||
|
|
@ -164,6 +178,8 @@
|
|||
uint8_t dst, src; \
|
||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
||||
fetch_ea_32(fetchdat); \
|
||||
if (cpu_mod != 3) \
|
||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||
dst = getr8(cpu_reg); \
|
||||
src = geteab(); if (cpu_state.abrt) return 1; \
|
||||
setflags ## 8 flagops; \
|
||||
|
|
@ -178,6 +194,8 @@
|
|||
uint16_t dst, src; \
|
||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
||||
fetch_ea_16(fetchdat); \
|
||||
if (cpu_mod != 3) \
|
||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||
dst = cpu_state.regs[cpu_reg].w; \
|
||||
src = geteaw(); if (cpu_state.abrt) return 1; \
|
||||
setflags ## 16 flagops; \
|
||||
|
|
@ -191,6 +209,8 @@
|
|||
uint16_t dst, src; \
|
||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
||||
fetch_ea_32(fetchdat); \
|
||||
if (cpu_mod != 3) \
|
||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||
dst = cpu_state.regs[cpu_reg].w; \
|
||||
src = geteaw(); if (cpu_state.abrt) return 1; \
|
||||
setflags ## 16 flagops; \
|
||||
|
|
@ -205,6 +225,8 @@
|
|||
uint32_t dst, src; \
|
||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
||||
fetch_ea_16(fetchdat); \
|
||||
if (cpu_mod != 3) \
|
||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||
dst = cpu_state.regs[cpu_reg].l; \
|
||||
src = geteal(); if (cpu_state.abrt) return 1; \
|
||||
setflags ## 32 flagops; \
|
||||
|
|
@ -218,6 +240,8 @@
|
|||
uint32_t dst, src; \
|
||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
||||
fetch_ea_32(fetchdat); \
|
||||
if (cpu_mod != 3) \
|
||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||
dst = cpu_state.regs[cpu_reg].l; \
|
||||
src = geteal(); if (cpu_state.abrt) return 1; \
|
||||
setflags ## 32 flagops; \
|
||||
|
|
@ -275,6 +299,8 @@ static int opCMP_b_rmw_a16(uint32_t fetchdat)
|
|||
{
|
||||
uint8_t dst;
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
dst = geteab(); if (cpu_state.abrt) return 1;
|
||||
setsub8(dst, getr8(cpu_reg));
|
||||
if (is486) CLOCK_CYCLES((cpu_mod == 3) ? 1 : 2);
|
||||
|
|
@ -286,6 +312,8 @@ static int opCMP_b_rmw_a32(uint32_t fetchdat)
|
|||
{
|
||||
uint8_t dst;
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
dst = geteab(); if (cpu_state.abrt) return 1;
|
||||
setsub8(dst, getr8(cpu_reg));
|
||||
if (is486) CLOCK_CYCLES((cpu_mod == 3) ? 1 : 2);
|
||||
|
|
@ -298,6 +326,8 @@ static int opCMP_w_rmw_a16(uint32_t fetchdat)
|
|||
{
|
||||
uint16_t dst;
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
dst = geteaw(); if (cpu_state.abrt) return 1;
|
||||
setsub16(dst, cpu_state.regs[cpu_reg].w);
|
||||
if (is486) CLOCK_CYCLES((cpu_mod == 3) ? 1 : 2);
|
||||
|
|
@ -309,6 +339,8 @@ static int opCMP_w_rmw_a32(uint32_t fetchdat)
|
|||
{
|
||||
uint16_t dst;
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
dst = geteaw(); if (cpu_state.abrt) return 1;
|
||||
setsub16(dst, cpu_state.regs[cpu_reg].w);
|
||||
if (is486) CLOCK_CYCLES((cpu_mod == 3) ? 1 : 2);
|
||||
|
|
@ -321,6 +353,8 @@ static int opCMP_l_rmw_a16(uint32_t fetchdat)
|
|||
{
|
||||
uint32_t dst;
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
dst = geteal(); if (cpu_state.abrt) return 1;
|
||||
setsub32(dst, cpu_state.regs[cpu_reg].l);
|
||||
if (is486) CLOCK_CYCLES((cpu_mod == 3) ? 1 : 2);
|
||||
|
|
@ -332,6 +366,8 @@ static int opCMP_l_rmw_a32(uint32_t fetchdat)
|
|||
{
|
||||
uint32_t dst;
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
dst = geteal(); if (cpu_state.abrt) return 1;
|
||||
setsub32(dst, cpu_state.regs[cpu_reg].l);
|
||||
if (is486) CLOCK_CYCLES((cpu_mod == 3) ? 1 : 2);
|
||||
|
|
@ -344,7 +380,9 @@ static int opCMP_b_rm_a16(uint32_t fetchdat)
|
|||
{
|
||||
uint8_t src;
|
||||
fetch_ea_16(fetchdat);
|
||||
src = geteab(); if (cpu_state.abrt) return 1;
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
src = geteab(); if (cpu_state.abrt) return 1;
|
||||
setsub8(getr8(cpu_reg), src);
|
||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm);
|
||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 0);
|
||||
|
|
@ -354,7 +392,9 @@ static int opCMP_b_rm_a32(uint32_t fetchdat)
|
|||
{
|
||||
uint8_t src;
|
||||
fetch_ea_32(fetchdat);
|
||||
src = geteab(); if (cpu_state.abrt) return 1;
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
src = geteab(); if (cpu_state.abrt) return 1;
|
||||
setsub8(getr8(cpu_reg), src);
|
||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm);
|
||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 1);
|
||||
|
|
@ -365,7 +405,9 @@ static int opCMP_w_rm_a16(uint32_t fetchdat)
|
|||
{
|
||||
uint16_t src;
|
||||
fetch_ea_16(fetchdat);
|
||||
src = geteaw(); if (cpu_state.abrt) return 1;
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
src = geteaw(); if (cpu_state.abrt) return 1;
|
||||
setsub16(cpu_state.regs[cpu_reg].w, src);
|
||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm);
|
||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 0);
|
||||
|
|
@ -375,7 +417,9 @@ static int opCMP_w_rm_a32(uint32_t fetchdat)
|
|||
{
|
||||
uint16_t src;
|
||||
fetch_ea_32(fetchdat);
|
||||
src = geteaw(); if (cpu_state.abrt) return 1;
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
src = geteaw(); if (cpu_state.abrt) return 1;
|
||||
setsub16(cpu_state.regs[cpu_reg].w, src);
|
||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm);
|
||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 1);
|
||||
|
|
@ -386,7 +430,9 @@ static int opCMP_l_rm_a16(uint32_t fetchdat)
|
|||
{
|
||||
uint32_t src;
|
||||
fetch_ea_16(fetchdat);
|
||||
src = geteal(); if (cpu_state.abrt) return 1;
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
src = geteal(); if (cpu_state.abrt) return 1;
|
||||
setsub32(cpu_state.regs[cpu_reg].l, src);
|
||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rml);
|
||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1,0,0, 0);
|
||||
|
|
@ -396,7 +442,9 @@ static int opCMP_l_rm_a32(uint32_t fetchdat)
|
|||
{
|
||||
uint32_t src;
|
||||
fetch_ea_32(fetchdat);
|
||||
src = geteal(); if (cpu_state.abrt) return 1;
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
src = geteal(); if (cpu_state.abrt) return 1;
|
||||
setsub32(cpu_state.regs[cpu_reg].l, src);
|
||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rml);
|
||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1,0,0, 1);
|
||||
|
|
@ -434,6 +482,8 @@ static int opTEST_b_a16(uint32_t fetchdat)
|
|||
{
|
||||
uint8_t temp, temp2;
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
temp = geteab(); if (cpu_state.abrt) return 1;
|
||||
temp2 = getr8(cpu_reg);
|
||||
setznp8(temp & temp2);
|
||||
|
|
@ -446,6 +496,8 @@ static int opTEST_b_a32(uint32_t fetchdat)
|
|||
{
|
||||
uint8_t temp, temp2;
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
temp = geteab(); if (cpu_state.abrt) return 1;
|
||||
temp2 = getr8(cpu_reg);
|
||||
setznp8(temp & temp2);
|
||||
|
|
@ -459,6 +511,8 @@ static int opTEST_w_a16(uint32_t fetchdat)
|
|||
{
|
||||
uint16_t temp, temp2;
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
temp = geteaw(); if (cpu_state.abrt) return 1;
|
||||
temp2 = cpu_state.regs[cpu_reg].w;
|
||||
setznp16(temp & temp2);
|
||||
|
|
@ -471,6 +525,8 @@ static int opTEST_w_a32(uint32_t fetchdat)
|
|||
{
|
||||
uint16_t temp, temp2;
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
temp = geteaw(); if (cpu_state.abrt) return 1;
|
||||
temp2 = cpu_state.regs[cpu_reg].w;
|
||||
setznp16(temp & temp2);
|
||||
|
|
@ -484,6 +540,8 @@ static int opTEST_l_a16(uint32_t fetchdat)
|
|||
{
|
||||
uint32_t temp, temp2;
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
temp = geteal(); if (cpu_state.abrt) return 1;
|
||||
temp2 = cpu_state.regs[cpu_reg].l;
|
||||
setznp32(temp & temp2);
|
||||
|
|
@ -496,6 +554,8 @@ static int opTEST_l_a32(uint32_t fetchdat)
|
|||
{
|
||||
uint32_t temp, temp2;
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||
temp = geteal(); if (cpu_state.abrt) return 1;
|
||||
temp2 = cpu_state.regs[cpu_reg].l;
|
||||
setznp32(temp & temp2);
|
||||
|
|
@ -588,6 +648,8 @@ static int op80_a16(uint32_t fetchdat)
|
|||
uint8_t src, dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = getbyte(); if (cpu_state.abrt) return 1;
|
||||
ARITH_MULTI(b, 8);
|
||||
if ((rmdat & 0x38) == 0x38)
|
||||
|
|
@ -602,6 +664,8 @@ static int op80_a32(uint32_t fetchdat)
|
|||
uint8_t src, dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = getbyte(); if (cpu_state.abrt) return 1;
|
||||
ARITH_MULTI(b, 8);
|
||||
if ((rmdat & 0x38) == 0x38)
|
||||
|
|
@ -616,6 +680,8 @@ static int op81_w_a16(uint32_t fetchdat)
|
|||
uint16_t src, dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = getword(); if (cpu_state.abrt) return 1;
|
||||
ARITH_MULTI(w, 16);
|
||||
if ((rmdat & 0x38) == 0x38)
|
||||
|
|
@ -630,6 +696,8 @@ static int op81_w_a32(uint32_t fetchdat)
|
|||
uint16_t src, dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = getword(); if (cpu_state.abrt) return 1;
|
||||
ARITH_MULTI(w, 16);
|
||||
if ((rmdat & 0x38) == 0x38)
|
||||
|
|
@ -644,6 +712,8 @@ static int op81_l_a16(uint32_t fetchdat)
|
|||
uint32_t src, dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = getlong(); if (cpu_state.abrt) return 1;
|
||||
ARITH_MULTI(l, 32);
|
||||
if ((rmdat & 0x38) == 0x38)
|
||||
|
|
@ -658,6 +728,8 @@ static int op81_l_a32(uint32_t fetchdat)
|
|||
uint32_t src, dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = getlong(); if (cpu_state.abrt) return 1;
|
||||
ARITH_MULTI(l, 32);
|
||||
if ((rmdat & 0x38) == 0x38)
|
||||
|
|
@ -673,6 +745,8 @@ static int op83_w_a16(uint32_t fetchdat)
|
|||
uint16_t src, dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = getbyte(); if (cpu_state.abrt) return 1;
|
||||
if (src & 0x80) src |= 0xff00;
|
||||
ARITH_MULTI(w, 16);
|
||||
|
|
@ -688,6 +762,8 @@ static int op83_w_a32(uint32_t fetchdat)
|
|||
uint16_t src, dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = getbyte(); if (cpu_state.abrt) return 1;
|
||||
if (src & 0x80) src |= 0xff00;
|
||||
ARITH_MULTI(w, 16);
|
||||
|
|
@ -704,6 +780,8 @@ static int op83_l_a16(uint32_t fetchdat)
|
|||
uint32_t src, dst;
|
||||
|
||||
fetch_ea_16(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = getbyte(); if (cpu_state.abrt) return 1;
|
||||
if (src & 0x80) src |= 0xffffff00;
|
||||
ARITH_MULTI(l, 32);
|
||||
|
|
@ -719,6 +797,8 @@ static int op83_l_a32(uint32_t fetchdat)
|
|||
uint32_t src, dst;
|
||||
|
||||
fetch_ea_32(fetchdat);
|
||||
if (cpu_mod != 3)
|
||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||
src = getbyte(); if (cpu_state.abrt) return 1;
|
||||
if (src & 0x80) src |= 0xffffff00;
|
||||
ARITH_MULTI(l, 32);
|
||||
|
|
|
|||
Loading…
Reference in a new issue