Preliminary port of PCem's FPU timing emulation
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#define opFPU(name, optype, a_size, load_var, get, use_var) \
|
||||
#define opFPU(name, optype, a_size, load_var, get, use_var, cycle_postfix) \
|
||||
static int opFADD ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
{ \
|
||||
optype t; \
|
||||
@@ -12,7 +12,7 @@ static int opFADD ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
if ((cpu_state.npxc >> 10) & 3) \
|
||||
fesetround(FE_TONEAREST); \
|
||||
FP_TAG_VALID; \
|
||||
CLOCK_CYCLES(8); \
|
||||
CLOCK_CYCLES(x87_timings.fadd ## cycle_postfix); \
|
||||
return 0; \
|
||||
} \
|
||||
static int opFCOM ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
@@ -24,7 +24,7 @@ static int opFCOM ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
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); \
|
||||
CLOCK_CYCLES(4); \
|
||||
CLOCK_CYCLES(x87_timings.fcom ## cycle_postfix); \
|
||||
return 0; \
|
||||
} \
|
||||
static int opFCOMP ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
@@ -37,7 +37,7 @@ static int opFCOMP ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
cpu_state.npxs &= ~(C0|C2|C3); \
|
||||
cpu_state.npxs |= x87_compare(ST(0), (double)use_var); \
|
||||
x87_pop(); \
|
||||
CLOCK_CYCLES(4); \
|
||||
CLOCK_CYCLES(x87_timings.fcom ## cycle_postfix); \
|
||||
return 0; \
|
||||
} \
|
||||
static int opFDIV ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
@@ -49,7 +49,7 @@ static int opFDIV ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
||||
x87_div(ST(0), ST(0), use_var); \
|
||||
FP_TAG_VALID; \
|
||||
CLOCK_CYCLES(73); \
|
||||
CLOCK_CYCLES(x87_timings.fdiv ## cycle_postfix); \
|
||||
return 0; \
|
||||
} \
|
||||
static int opFDIVR ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
@@ -61,7 +61,7 @@ static int opFDIVR ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
||||
x87_div(ST(0), use_var, ST(0)); \
|
||||
FP_TAG_VALID; \
|
||||
CLOCK_CYCLES(73); \
|
||||
CLOCK_CYCLES(x87_timings.fdiv ## cycle_postfix); \
|
||||
return 0; \
|
||||
} \
|
||||
static int opFMUL ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
@@ -73,7 +73,7 @@ static int opFMUL ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
||||
ST(0) *= use_var; \
|
||||
FP_TAG_VALID; \
|
||||
CLOCK_CYCLES(11); \
|
||||
CLOCK_CYCLES(x87_timings.fmul ## cycle_postfix); \
|
||||
return 0; \
|
||||
} \
|
||||
static int opFSUB ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
@@ -85,7 +85,7 @@ static int opFSUB ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
||||
ST(0) -= use_var; \
|
||||
FP_TAG_VALID; \
|
||||
CLOCK_CYCLES(8); \
|
||||
CLOCK_CYCLES(x87_timings.fadd ## cycle_postfix); \
|
||||
return 0; \
|
||||
} \
|
||||
static int opFSUBR ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
@@ -97,27 +97,27 @@ static int opFSUBR ## name ## _a ## a_size(uint32_t fetchdat) \
|
||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
||||
ST(0) = use_var - ST(0); \
|
||||
FP_TAG_VALID; \
|
||||
CLOCK_CYCLES(8); \
|
||||
CLOCK_CYCLES(x87_timings.fadd ## cycle_postfix); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
|
||||
opFPU(s, x87_ts, 16, t.i, geteal, t.s)
|
||||
opFPU(s, x87_ts, 16, t.i, geteal, t.s, _32)
|
||||
#ifndef FPU_8087
|
||||
opFPU(s, x87_ts, 32, t.i, geteal, t.s)
|
||||
opFPU(s, x87_ts, 32, t.i, geteal, t.s, _32)
|
||||
#endif
|
||||
opFPU(d, x87_td, 16, t.i, geteaq, t.d)
|
||||
opFPU(d, x87_td, 16, t.i, geteaq, t.d, _64)
|
||||
#ifndef FPU_8087
|
||||
opFPU(d, x87_td, 32, t.i, geteaq, t.d)
|
||||
opFPU(d, x87_td, 32, t.i, geteaq, t.d, _64)
|
||||
#endif
|
||||
|
||||
opFPU(iw, uint16_t, 16, t, geteaw, (double)(int16_t)t)
|
||||
opFPU(iw, uint16_t, 16, t, geteaw, (double)(int16_t)t, _i16)
|
||||
#ifndef FPU_8087
|
||||
opFPU(iw, uint16_t, 32, t, geteaw, (double)(int16_t)t)
|
||||
opFPU(iw, uint16_t, 32, t, geteaw, (double)(int16_t)t, _i16)
|
||||
#endif
|
||||
opFPU(il, uint32_t, 16, t, geteal, (double)(int32_t)t)
|
||||
opFPU(il, uint32_t, 16, t, geteal, (double)(int32_t)t, _i32)
|
||||
#ifndef FPU_8087
|
||||
opFPU(il, uint32_t, 32, t, geteal, (double)(int32_t)t)
|
||||
opFPU(il, uint32_t, 32, t, geteal, (double)(int32_t)t, _i32)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ static int opFADD(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
ST(0) = ST(0) + ST(fetchdat & 7);
|
||||
FP_TAG_VALID;
|
||||
CLOCK_CYCLES(8);
|
||||
CLOCK_CYCLES(x87_timings.fadd);
|
||||
return 0;
|
||||
}
|
||||
static int opFADDr(uint32_t fetchdat)
|
||||
@@ -136,7 +136,7 @@ static int opFADDr(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
ST(fetchdat & 7) = ST(fetchdat & 7) + ST(0);
|
||||
FP_TAG_VALID_F;
|
||||
CLOCK_CYCLES(8);
|
||||
CLOCK_CYCLES(x87_timings.fadd);
|
||||
return 0;
|
||||
}
|
||||
static int opFADDP(uint32_t fetchdat)
|
||||
@@ -146,7 +146,7 @@ static int opFADDP(uint32_t fetchdat)
|
||||
ST(fetchdat & 7) = ST(fetchdat & 7) + ST(0);
|
||||
FP_TAG_VALID_F;
|
||||
x87_pop();
|
||||
CLOCK_CYCLES(8);
|
||||
CLOCK_CYCLES(x87_timings.fadd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ static int opFCOM(uint32_t fetchdat)
|
||||
cpu_state.npxs &= ~(C0|C2|C3);
|
||||
if (ST(0) == ST(fetchdat & 7)) cpu_state.npxs |= C3;
|
||||
else if (ST(0) < ST(fetchdat & 7)) cpu_state.npxs |= C0;
|
||||
CLOCK_CYCLES(4);
|
||||
CLOCK_CYCLES(x87_timings.fcom);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ static int opFCOMP(uint32_t fetchdat)
|
||||
cpu_state.npxs &= ~(C0|C2|C3);
|
||||
cpu_state.npxs |= x87_compare(ST(0), ST(fetchdat & 7));
|
||||
x87_pop();
|
||||
CLOCK_CYCLES(4);
|
||||
CLOCK_CYCLES(x87_timings.fcom);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ static int opFCOMPP(uint32_t fetchdat)
|
||||
|
||||
x87_pop();
|
||||
x87_pop();
|
||||
CLOCK_CYCLES(4);
|
||||
CLOCK_CYCLES(x87_timings.fcom);
|
||||
return 0;
|
||||
}
|
||||
#ifndef FPU_8087
|
||||
@@ -199,7 +199,7 @@ static int opFUCOMPP(uint32_t fetchdat)
|
||||
cpu_state.npxs |= x87_ucompare(ST(0), ST(1));
|
||||
x87_pop();
|
||||
x87_pop();
|
||||
CLOCK_CYCLES(5);
|
||||
CLOCK_CYCLES(x87_timings.fucom);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ static int opFCOMI(uint32_t fetchdat)
|
||||
cpu_state.flags &= ~(Z_FLAG | P_FLAG | C_FLAG);
|
||||
if (ST(0) == ST(fetchdat & 7)) cpu_state.flags |= Z_FLAG;
|
||||
else if (ST(0) < ST(fetchdat & 7)) cpu_state.flags |= C_FLAG;
|
||||
CLOCK_CYCLES(4);
|
||||
CLOCK_CYCLES(x87_timings.fcom);
|
||||
return 0;
|
||||
}
|
||||
static int opFCOMIP(uint32_t fetchdat)
|
||||
@@ -223,7 +223,7 @@ static int opFCOMIP(uint32_t fetchdat)
|
||||
if (ST(0) == ST(fetchdat & 7)) cpu_state.flags |= Z_FLAG;
|
||||
else if (ST(0) < ST(fetchdat & 7)) cpu_state.flags |= C_FLAG;
|
||||
x87_pop();
|
||||
CLOCK_CYCLES(4);
|
||||
CLOCK_CYCLES(x87_timings.fcom);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -234,7 +234,7 @@ static int opFDIV(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
x87_div(ST(0), ST(0), ST(fetchdat & 7));
|
||||
FP_TAG_VALID;
|
||||
CLOCK_CYCLES(73);
|
||||
CLOCK_CYCLES(x87_timings.fdiv);
|
||||
return 0;
|
||||
}
|
||||
static int opFDIVr(uint32_t fetchdat)
|
||||
@@ -243,7 +243,7 @@ static int opFDIVr(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
x87_div(ST(fetchdat & 7), ST(fetchdat & 7), ST(0));
|
||||
FP_TAG_VALID_F;
|
||||
CLOCK_CYCLES(73);
|
||||
CLOCK_CYCLES(x87_timings.fdiv);
|
||||
return 0;
|
||||
}
|
||||
static int opFDIVP(uint32_t fetchdat)
|
||||
@@ -253,7 +253,7 @@ static int opFDIVP(uint32_t fetchdat)
|
||||
x87_div(ST(fetchdat & 7), ST(fetchdat & 7), ST(0));
|
||||
FP_TAG_VALID_F;
|
||||
x87_pop();
|
||||
CLOCK_CYCLES(73);
|
||||
CLOCK_CYCLES(x87_timings.fdiv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ static int opFDIVR(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
x87_div(ST(0), ST(fetchdat&7), ST(0));
|
||||
FP_TAG_VALID;
|
||||
CLOCK_CYCLES(73);
|
||||
CLOCK_CYCLES(x87_timings.fdiv);
|
||||
return 0;
|
||||
}
|
||||
static int opFDIVRr(uint32_t fetchdat)
|
||||
@@ -272,7 +272,7 @@ static int opFDIVRr(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
x87_div(ST(fetchdat & 7), ST(0), ST(fetchdat & 7));
|
||||
FP_TAG_VALID_F;
|
||||
CLOCK_CYCLES(73);
|
||||
CLOCK_CYCLES(x87_timings.fdiv);
|
||||
return 0;
|
||||
}
|
||||
static int opFDIVRP(uint32_t fetchdat)
|
||||
@@ -282,7 +282,7 @@ static int opFDIVRP(uint32_t fetchdat)
|
||||
x87_div(ST(fetchdat & 7), ST(0), ST(fetchdat & 7));
|
||||
FP_TAG_VALID_F;
|
||||
x87_pop();
|
||||
CLOCK_CYCLES(73);
|
||||
CLOCK_CYCLES(x87_timings.fdiv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ static int opFMUL(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
ST(0) = ST(0) * ST(fetchdat & 7);
|
||||
FP_TAG_VALID;
|
||||
CLOCK_CYCLES(16);
|
||||
CLOCK_CYCLES(x87_timings.fmul);
|
||||
return 0;
|
||||
}
|
||||
static int opFMULr(uint32_t fetchdat)
|
||||
@@ -301,7 +301,7 @@ static int opFMULr(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
ST(fetchdat & 7) = ST(0) * ST(fetchdat & 7);
|
||||
FP_TAG_VALID_F;
|
||||
CLOCK_CYCLES(16);
|
||||
CLOCK_CYCLES(x87_timings.fmul);
|
||||
return 0;
|
||||
}
|
||||
static int opFMULP(uint32_t fetchdat)
|
||||
@@ -311,7 +311,7 @@ static int opFMULP(uint32_t fetchdat)
|
||||
ST(fetchdat & 7) = ST(0) * ST(fetchdat & 7);
|
||||
FP_TAG_VALID_F;
|
||||
x87_pop();
|
||||
CLOCK_CYCLES(16);
|
||||
CLOCK_CYCLES(x87_timings.fmul);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ static int opFSUB(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
ST(0) = ST(0) - ST(fetchdat & 7);
|
||||
FP_TAG_VALID;
|
||||
CLOCK_CYCLES(8);
|
||||
CLOCK_CYCLES(x87_timings.fadd);
|
||||
return 0;
|
||||
}
|
||||
static int opFSUBr(uint32_t fetchdat)
|
||||
@@ -330,7 +330,7 @@ static int opFSUBr(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
ST(fetchdat & 7) = ST(fetchdat & 7) - ST(0);
|
||||
FP_TAG_VALID_F;
|
||||
CLOCK_CYCLES(8);
|
||||
CLOCK_CYCLES(x87_timings.fadd);
|
||||
return 0;
|
||||
}
|
||||
static int opFSUBP(uint32_t fetchdat)
|
||||
@@ -340,7 +340,7 @@ static int opFSUBP(uint32_t fetchdat)
|
||||
ST(fetchdat & 7) = ST(fetchdat & 7) - ST(0);
|
||||
FP_TAG_VALID_F;
|
||||
x87_pop();
|
||||
CLOCK_CYCLES(8);
|
||||
CLOCK_CYCLES(x87_timings.fadd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ static int opFSUBR(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
ST(0) = ST(fetchdat & 7) - ST(0);
|
||||
FP_TAG_VALID;
|
||||
CLOCK_CYCLES(8);
|
||||
CLOCK_CYCLES(x87_timings.fadd);
|
||||
return 0;
|
||||
}
|
||||
static int opFSUBRr(uint32_t fetchdat)
|
||||
@@ -359,7 +359,7 @@ static int opFSUBRr(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
ST(fetchdat & 7) = ST(0) - ST(fetchdat & 7);
|
||||
FP_TAG_VALID_F;
|
||||
CLOCK_CYCLES(8);
|
||||
CLOCK_CYCLES(x87_timings.fadd);
|
||||
return 0;
|
||||
}
|
||||
static int opFSUBRP(uint32_t fetchdat)
|
||||
@@ -369,7 +369,7 @@ static int opFSUBRP(uint32_t fetchdat)
|
||||
ST(fetchdat & 7) = ST(0) - ST(fetchdat & 7);
|
||||
FP_TAG_VALID_F;
|
||||
x87_pop();
|
||||
CLOCK_CYCLES(8);
|
||||
CLOCK_CYCLES(x87_timings.fadd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ static int opFUCOM(uint32_t fetchdat)
|
||||
cpu_state.pc++;
|
||||
cpu_state.npxs &= ~(C0|C2|C3);
|
||||
cpu_state.npxs |= x87_ucompare(ST(0), ST(fetchdat & 7));
|
||||
CLOCK_CYCLES(4);
|
||||
CLOCK_CYCLES(x87_timings.fucom);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ static int opFUCOMP(uint32_t fetchdat)
|
||||
cpu_state.npxs &= ~(C0|C2|C3);
|
||||
cpu_state.npxs |= x87_ucompare(ST(0), ST(fetchdat & 7));
|
||||
x87_pop();
|
||||
CLOCK_CYCLES(4);
|
||||
CLOCK_CYCLES(x87_timings.fucom);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ static int opFUCOMI(uint32_t fetchdat)
|
||||
cpu_state.flags &= ~(Z_FLAG | P_FLAG | C_FLAG);
|
||||
if (ST(0) == ST(fetchdat & 7)) cpu_state.flags |= Z_FLAG;
|
||||
else if (ST(0) < ST(fetchdat & 7)) cpu_state.flags |= C_FLAG;
|
||||
CLOCK_CYCLES(4);
|
||||
CLOCK_CYCLES(x87_timings.fucom);
|
||||
return 0;
|
||||
}
|
||||
static int opFUCOMIP(uint32_t fetchdat)
|
||||
@@ -415,7 +415,7 @@ static int opFUCOMIP(uint32_t fetchdat)
|
||||
if (ST(0) == ST(fetchdat & 7)) cpu_state.flags |= Z_FLAG;
|
||||
else if (ST(0) < ST(fetchdat & 7)) cpu_state.flags |= C_FLAG;
|
||||
x87_pop();
|
||||
CLOCK_CYCLES(4);
|
||||
CLOCK_CYCLES(x87_timings.fucom);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user