Cleaned up x87 tag register handling.

This commit is contained in:
SarahW 2018-10-01 21:02:40 +01:00
commit dbb01ef9e2
6 changed files with 82 additions and 63 deletions

View file

@ -34,7 +34,7 @@ static int opFINIT(uint32_t fetchdat)
cpu_state.npxc = 0x37F;
cpu_state.new_npxc = (cpu_state.old_npxc & ~0xc00);
cpu_state.npxs = 0;
*(uint64_t *)cpu_state.tag = 0x0303030303030303ll;
*(uint64_t *)cpu_state.tag = 0;
cpu_state.TOP = 0;
cpu_state.ismmx = 0;
CLOCK_CYCLES(17);
@ -47,7 +47,7 @@ static int opFFREE(uint32_t fetchdat)
FP_ENTER();
cpu_state.pc++;
if (fplog) pclog("FFREE\n");
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = 3;
cpu_state.tag[(cpu_state.TOP + fetchdat) & 7] = TAG_EMPTY;
CLOCK_CYCLES(3);
return 0;
}
@ -278,7 +278,7 @@ static int FSAVE()
cpu_state.npxc = 0x37F;
cpu_state.new_npxc = (cpu_state.old_npxc & ~0xc00);
cpu_state.npxs = 0;
*(uint64_t *)cpu_state.tag = 0x0303030303030303ll;
*(uint64_t *)cpu_state.tag = 0;
cpu_state.TOP = 0;
cpu_state.ismmx = 0;
@ -369,7 +369,7 @@ static int opFCHS(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("FCHS\n");
ST(0) = -ST(0);
cpu_state.tag[cpu_state.TOP] &= ~TAG_UINT64;
cpu_state.tag[cpu_state.TOP] = TAG_VALID;
CLOCK_CYCLES(6);
return 0;
}
@ -380,7 +380,7 @@ static int opFABS(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("FABS %f\n", ST(0));
ST(0) = fabs(ST(0));
cpu_state.tag[cpu_state.TOP] &= ~TAG_UINT64;
cpu_state.tag[cpu_state.TOP] = TAG_VALID;
CLOCK_CYCLES(3);
return 0;
}
@ -403,7 +403,7 @@ static int opFXAM(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("FXAM %i %f\n", cpu_state.tag[cpu_state.TOP&7], ST(0));
cpu_state.npxs &= ~(C0|C1|C2|C3);
if (cpu_state.tag[cpu_state.TOP&7] == 3) cpu_state.npxs |= (C0|C3);
if (cpu_state.tag[cpu_state.TOP&7] == TAG_EMPTY) cpu_state.npxs |= (C0|C3);
else if (ST(0) == 0.0) cpu_state.npxs |= C3;
else cpu_state.npxs |= C2;
if (ST(0) < 0.0) cpu_state.npxs |= C1;
@ -477,7 +477,7 @@ static int opFLDZ(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("FLDZ\n");
x87_push(0.0);
cpu_state.tag[cpu_state.TOP&7] = 1;
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID;
CLOCK_CYCLES(4);
return 0;
}
@ -488,7 +488,7 @@ static int opF2XM1(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("F2XM1\n");
ST(0) = pow(2.0, ST(0)) - 1.0;
cpu_state.tag[cpu_state.TOP] &= ~TAG_UINT64;
cpu_state.tag[cpu_state.TOP] = TAG_VALID;
CLOCK_CYCLES(200);
return 0;
}
@ -499,7 +499,7 @@ static int opFYL2X(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("FYL2X\n");
ST(1) = ST(1) * (log(ST(0)) / log(2.0));
cpu_state.tag[(cpu_state.TOP + 1) & 7] &= ~TAG_UINT64;
cpu_state.tag[(cpu_state.TOP + 1) & 7] = TAG_VALID;
x87_pop();
CLOCK_CYCLES(250);
return 0;
@ -511,7 +511,7 @@ static int opFYL2XP1(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("FYL2XP1\n");
ST(1) = ST(1) * (log(ST(0)+1.0) / log(2.0));
cpu_state.tag[(cpu_state.TOP + 1) & 7] &= ~TAG_UINT64;
cpu_state.tag[(cpu_state.TOP + 1) & 7] = TAG_VALID;
x87_pop();
CLOCK_CYCLES(250);
return 0;
@ -523,7 +523,7 @@ static int opFPTAN(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("FPTAN\n");
ST(0) = tan(ST(0));
cpu_state.tag[cpu_state.TOP] &= ~TAG_UINT64;
cpu_state.tag[cpu_state.TOP] = TAG_VALID;
x87_push(1.0);
cpu_state.npxs &= ~C2;
CLOCK_CYCLES(235);
@ -536,7 +536,7 @@ static int opFPATAN(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("FPATAN\n");
ST(1) = atan2(ST(1), ST(0));
cpu_state.tag[(cpu_state.TOP + 1) & 7] &= ~TAG_UINT64;
cpu_state.tag[(cpu_state.TOP + 1) & 7] = TAG_VALID;
x87_pop();
CLOCK_CYCLES(250);
return 0;
@ -570,7 +570,7 @@ static int opFPREM(uint32_t fetchdat)
if (fplog) pclog("FPREM %f %f ", ST(0), ST(1));
temp64 = (int64_t)(ST(0) / ST(1));
ST(0) = ST(0) - (ST(1) * (double)temp64);
cpu_state.tag[cpu_state.TOP] &= ~TAG_UINT64;
cpu_state.tag[cpu_state.TOP] = TAG_VALID;
if (fplog) pclog("%f\n", ST(0));
cpu_state.npxs &= ~(C0|C1|C2|C3);
if (temp64 & 4) cpu_state.npxs|=C0;
@ -587,7 +587,7 @@ static int opFPREM1(uint32_t fetchdat)
if (fplog) pclog("FPREM1 %f %f ", ST(0), ST(1));
temp64 = (int64_t)(ST(0) / ST(1));
ST(0) = ST(0) - (ST(1) * (double)temp64);
cpu_state.tag[cpu_state.TOP] &= ~TAG_UINT64;
cpu_state.tag[cpu_state.TOP] = TAG_VALID;
if (fplog) pclog("%f\n", ST(0));
cpu_state.npxs &= ~(C0|C1|C2|C3);
if (temp64 & 4) cpu_state.npxs|=C0;
@ -603,7 +603,7 @@ static int opFSQRT(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("FSQRT\n");
ST(0) = sqrt(ST(0));
cpu_state.tag[cpu_state.TOP] &= ~TAG_UINT64;
cpu_state.tag[cpu_state.TOP] = TAG_VALID;
CLOCK_CYCLES(83);
return 0;
}
@ -616,7 +616,7 @@ static int opFSINCOS(uint32_t fetchdat)
if (fplog) pclog("FSINCOS\n");
td = ST(0);
ST(0) = sin(td);
cpu_state.tag[cpu_state.TOP] &= ~TAG_UINT64;
cpu_state.tag[cpu_state.TOP] = TAG_VALID;
x87_push(cos(td));
cpu_state.npxs &= ~C2;
CLOCK_CYCLES(330);
@ -629,7 +629,7 @@ static int opFRNDINT(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("FRNDINT %g ", ST(0));
ST(0) = (double)x87_fround(ST(0));
cpu_state.tag[cpu_state.TOP] &= ~TAG_UINT64;
cpu_state.tag[cpu_state.TOP] = TAG_VALID;
if (fplog) pclog("%g\n", ST(0));
CLOCK_CYCLES(21);
return 0;
@ -643,7 +643,7 @@ static int opFSCALE(uint32_t fetchdat)
if (fplog) pclog("FSCALE\n");
temp64 = (int64_t)ST(1);
ST(0) = ST(0) * pow(2.0, (double)temp64);
cpu_state.tag[cpu_state.TOP] &= ~TAG_UINT64;
cpu_state.tag[cpu_state.TOP] = TAG_VALID;
CLOCK_CYCLES(30);
return 0;
}
@ -654,7 +654,7 @@ static int opFSIN(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("FSIN\n");
ST(0) = sin(ST(0));
cpu_state.tag[cpu_state.TOP] &= ~TAG_UINT64;
cpu_state.tag[cpu_state.TOP] = TAG_VALID;
cpu_state.npxs &= ~C2;
CLOCK_CYCLES(300);
return 0;
@ -666,7 +666,7 @@ static int opFCOS(uint32_t fetchdat)
cpu_state.pc++;
if (fplog) pclog("FCOS\n");
ST(0) = cos(ST(0));
cpu_state.tag[cpu_state.TOP] &= ~TAG_UINT64;
cpu_state.tag[cpu_state.TOP] = TAG_VALID;
cpu_state.npxs &= ~C2;
CLOCK_CYCLES(300);
return 0;