Redid the x87 merger, now the x87 interpreter is basically the same across both recompilers, and there's several newly introduced bugs less.

This commit is contained in:
OBattler
2020-04-10 14:07:25 +02:00
parent a60634b3a1
commit f29f6de245
11 changed files with 166 additions and 323 deletions

View File

@@ -4,12 +4,14 @@ static int opFADD ## name ## _a ## a_size(uint32_t fetchdat) \
optype t; \
FP_ENTER(); \
fetch_ea_ ## a_size(fetchdat); \
SEG_CHECK_READ(cpu_state.ea_seg); \
SEG_CHECK_READ(cpu_state.ea_seg); \
load_var = get(); if (cpu_state.abrt) return 1; \
x87_round_set(); \
if ((cpu_state.npxc >> 10) & 3) \
fesetround(rounding_modes[(cpu_state.npxc >> 10) & 3]); \
ST(0) += use_var; \
x87_round_restore(); \
FP_TAG(); \
if ((cpu_state.npxc >> 10) & 3) \
fesetround(FE_TONEAREST); \
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; \
CLOCK_CYCLES(8); \
return 0; \
} \
@@ -18,7 +20,7 @@ static int opFCOM ## name ## _a ## a_size(uint32_t fetchdat) \
optype t; \
FP_ENTER(); \
fetch_ea_ ## a_size(fetchdat); \
SEG_CHECK_READ(cpu_state.ea_seg); \
SEG_CHECK_READ(cpu_state.ea_seg); \
load_var = get(); if (cpu_state.abrt) return 1; \
cpu_state.npxs &= ~(C0|C2|C3); \
cpu_state.npxs |= x87_compare(ST(0), (double)use_var); \
@@ -30,7 +32,7 @@ static int opFCOMP ## name ## _a ## a_size(uint32_t fetchdat) \
optype t; \
FP_ENTER(); \
fetch_ea_ ## a_size(fetchdat); \
SEG_CHECK_READ(cpu_state.ea_seg); \
SEG_CHECK_READ(cpu_state.ea_seg); \
load_var = get(); if (cpu_state.abrt) return 1; \
cpu_state.npxs &= ~(C0|C2|C3); \
cpu_state.npxs |= x87_compare(ST(0), (double)use_var); \
@@ -43,12 +45,10 @@ static int opFDIV ## name ## _a ## a_size(uint32_t fetchdat) \
optype t; \
FP_ENTER(); \
fetch_ea_ ## a_size(fetchdat); \
SEG_CHECK_READ(cpu_state.ea_seg); \
SEG_CHECK_READ(cpu_state.ea_seg); \
load_var = get(); if (cpu_state.abrt) return 1; \
x87_round_set(); \
x87_div(ST(0), ST(0), use_var); \
x87_round_restore(); \
FP_TAG(); \
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; \
CLOCK_CYCLES(73); \
return 0; \
} \
@@ -57,12 +57,10 @@ static int opFDIVR ## name ## _a ## a_size(uint32_t fetchdat) \
optype t; \
FP_ENTER(); \
fetch_ea_ ## a_size(fetchdat); \
SEG_CHECK_READ(cpu_state.ea_seg); \
SEG_CHECK_READ(cpu_state.ea_seg); \
load_var = get(); if (cpu_state.abrt) return 1; \
x87_round_set(); \
x87_div(ST(0), use_var, ST(0)); \
x87_round_restore(); \
FP_TAG(); \
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; \
CLOCK_CYCLES(73); \
return 0; \
} \
@@ -71,12 +69,10 @@ static int opFMUL ## name ## _a ## a_size(uint32_t fetchdat) \
optype t; \
FP_ENTER(); \
fetch_ea_ ## a_size(fetchdat); \
SEG_CHECK_READ(cpu_state.ea_seg); \
SEG_CHECK_READ(cpu_state.ea_seg); \
load_var = get(); if (cpu_state.abrt) return 1; \
x87_round_set(); \
ST(0) *= use_var; \
x87_round_restore(); \
FP_TAG(); \
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; \
CLOCK_CYCLES(11); \
return 0; \
} \
@@ -85,12 +81,10 @@ static int opFSUB ## name ## _a ## a_size(uint32_t fetchdat) \
optype t; \
FP_ENTER(); \
fetch_ea_ ## a_size(fetchdat); \
SEG_CHECK_READ(cpu_state.ea_seg); \
SEG_CHECK_READ(cpu_state.ea_seg); \
load_var = get(); if (cpu_state.abrt) return 1; \
x87_round_set(); \
ST(0) -= use_var; \
x87_round_restore(); \
FP_TAG(); \
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; \
CLOCK_CYCLES(8); \
return 0; \
} \
@@ -99,12 +93,10 @@ static int opFSUBR ## name ## _a ## a_size(uint32_t fetchdat) \
optype t; \
FP_ENTER(); \
fetch_ea_ ## a_size(fetchdat); \
SEG_CHECK_READ(cpu_state.ea_seg); \
SEG_CHECK_READ(cpu_state.ea_seg); \
load_var = get(); if (cpu_state.abrt) return 1; \
x87_round_set(); \
ST(0) = use_var - ST(0); \
x87_round_restore(); \
FP_TAG(); \
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; \
CLOCK_CYCLES(8); \
return 0; \
}
@@ -129,14 +121,12 @@ opFPU(il, uint32_t, 32, t, geteal, (double)(int32_t)t)
#endif
static int opFADD(uint32_t fetchdat)
{
FP_ENTER();
cpu_state.pc++;
ST(0) = ST(0) + ST(fetchdat & 7);
FP_TAG();
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID;
CLOCK_CYCLES(8);
return 0;
}
@@ -145,7 +135,7 @@ static int opFADDr(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
ST(fetchdat & 7) = ST(fetchdat & 7) + ST(0);
FP_FTAG();
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_VALID;
CLOCK_CYCLES(8);
return 0;
}
@@ -154,7 +144,7 @@ static int opFADDP(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
ST(fetchdat & 7) = ST(fetchdat & 7) + ST(0);
FP_FTAG();
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_VALID;
x87_pop();
CLOCK_CYCLES(8);
return 0;
@@ -213,7 +203,7 @@ static int opFUCOMPP(uint32_t fetchdat)
return 0;
}
#ifdef FP_686
#if defined(DEV_BRANCH) && (defined(USE_CYRIX_6X86) || defined(USE_I686))
static int opFCOMI(uint32_t fetchdat)
{
FP_ENTER();
@@ -245,7 +235,7 @@ static int opFDIV(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
x87_div(ST(0), ST(0), ST(fetchdat & 7));
FP_TAG();
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID;
CLOCK_CYCLES(73);
return 0;
}
@@ -254,7 +244,7 @@ static int opFDIVr(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
x87_div(ST(fetchdat & 7), ST(fetchdat & 7), ST(0));
FP_FTAG();
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_VALID;
CLOCK_CYCLES(73);
return 0;
}
@@ -263,7 +253,7 @@ static int opFDIVP(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
x87_div(ST(fetchdat & 7), ST(fetchdat & 7), ST(0));
FP_FTAG();
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_VALID;
x87_pop();
CLOCK_CYCLES(73);
return 0;
@@ -274,7 +264,7 @@ static int opFDIVR(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
x87_div(ST(0), ST(fetchdat&7), ST(0));
FP_TAG();
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID;
CLOCK_CYCLES(73);
return 0;
}
@@ -283,7 +273,7 @@ static int opFDIVRr(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
x87_div(ST(fetchdat & 7), ST(0), ST(fetchdat & 7));
FP_FTAG();
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_VALID;
CLOCK_CYCLES(73);
return 0;
}
@@ -292,7 +282,7 @@ static int opFDIVRP(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
x87_div(ST(fetchdat & 7), ST(0), ST(fetchdat & 7));
FP_FTAG();
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_VALID;
x87_pop();
CLOCK_CYCLES(73);
return 0;
@@ -303,7 +293,7 @@ static int opFMUL(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
ST(0) = ST(0) * ST(fetchdat & 7);
FP_TAG();
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID;
CLOCK_CYCLES(16);
return 0;
}
@@ -312,7 +302,7 @@ static int opFMULr(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
ST(fetchdat & 7) = ST(0) * ST(fetchdat & 7);
FP_FTAG();
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_VALID;
CLOCK_CYCLES(16);
return 0;
}
@@ -321,7 +311,7 @@ static int opFMULP(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
ST(fetchdat & 7) = ST(0) * ST(fetchdat & 7);
FP_FTAG();
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_VALID;
x87_pop();
CLOCK_CYCLES(16);
return 0;
@@ -332,7 +322,7 @@ static int opFSUB(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
ST(0) = ST(0) - ST(fetchdat & 7);
FP_TAG();
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID;
CLOCK_CYCLES(8);
return 0;
}
@@ -341,7 +331,7 @@ static int opFSUBr(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
ST(fetchdat & 7) = ST(fetchdat & 7) - ST(0);
FP_FTAG();
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_VALID;
CLOCK_CYCLES(8);
return 0;
}
@@ -350,7 +340,7 @@ static int opFSUBP(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
ST(fetchdat & 7) = ST(fetchdat & 7) - ST(0);
FP_FTAG();
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_VALID;
x87_pop();
CLOCK_CYCLES(8);
return 0;
@@ -361,7 +351,7 @@ static int opFSUBR(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
ST(0) = ST(fetchdat & 7) - ST(0);
FP_TAG();
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID;
CLOCK_CYCLES(8);
return 0;
}
@@ -370,7 +360,7 @@ static int opFSUBRr(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
ST(fetchdat & 7) = ST(0) - ST(fetchdat & 7);
FP_FTAG();
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_VALID;
CLOCK_CYCLES(8);
return 0;
}
@@ -379,7 +369,7 @@ static int opFSUBRP(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
ST(fetchdat & 7) = ST(0) - ST(fetchdat & 7);
FP_FTAG();
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_VALID;
x87_pop();
CLOCK_CYCLES(8);
return 0;
@@ -407,7 +397,7 @@ static int opFUCOMP(uint32_t fetchdat)
return 0;
}
#ifdef FP_686
#if defined(DEV_BRANCH) && (defined(USE_CYRIX_6X86) || defined(USE_I686))
static int opFUCOMI(uint32_t fetchdat)
{
FP_ENTER();