if (FPU_IS_NAN(Value) || !FPU_IS_NORMALIZED(Value)
|| (UnbiasedExp < 0) || (UnbiasedExp > 63))
{
+ /* Raise an invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (State->FpuControl.Im)
{
*Result = 0LL;
}
else
{
- State->FpuStatus.Ie = TRUE;
+ Fast486FpuException(State);
return FALSE;
}
}
/* Check for underflow */
if (!FPU_IS_NORMALIZED(Value) || (UnbiasedExp < -1023))
{
+ /* Raise the underflow exception */
+ State->FpuStatus.Ue = TRUE;
+
if (State->FpuControl.Um)
{
/* The result is zero due to underflow */
}
else
{
- /* Raise the underflow exception */
- State->FpuStatus.Ue = TRUE;
+ Fast486FpuException(State);
return FALSE;
}
}
/* Check for overflow */
if (UnbiasedExp > 1023)
{
+ /* Raise the overflow exception */
+ State->FpuStatus.Oe = TRUE;
+
if (State->FpuControl.Om)
{
/* The result is infinity due to overflow */
}
else
{
- /* Raise the overflow exception */
- State->FpuStatus.Oe = TRUE;
+ Fast486FpuException(State);
return FALSE;
}
}
FAST486_FPU_DATA_REG SecondAdjusted = *SecondOperand;
FAST486_FPU_DATA_REG TempResult;
- if (!State->FpuControl.Dm
- && (!FPU_IS_NORMALIZED(FirstOperand) || !FPU_IS_NORMALIZED(SecondOperand)))
+ if ((!FPU_IS_NORMALIZED(FirstOperand) || !FPU_IS_NORMALIZED(SecondOperand)))
{
/* Raise the denormalized exception */
State->FpuStatus.De = TRUE;
- return;
+
+ if (!State->FpuControl.Dm)
+ {
+ Fast486FpuException(State);
+ return;
+ }
}
/* Find the largest exponent */
{
if (TempResult.Exponent == FPU_MAX_EXPONENT)
{
+ /* Raise the overflow exception */
+ State->FpuStatus.Oe = TRUE;
+
if (State->FpuControl.Om)
{
/* Total overflow, return infinity */
}
else
{
- /* Raise the overflow exception */
- State->FpuStatus.Oe = TRUE;
+ Fast486FpuException(State);
return;
}
}
{
FAST486_FPU_DATA_REG TempResult;
- if (!State->FpuControl.Dm
- && (!FPU_IS_NORMALIZED(FirstOperand) || !FPU_IS_NORMALIZED(SecondOperand)))
+ if ((!FPU_IS_NORMALIZED(FirstOperand) || !FPU_IS_NORMALIZED(SecondOperand)))
{
/* Raise the denormalized exception */
State->FpuStatus.De = TRUE;
- return;
+
+ if (!State->FpuControl.Dm)
+ {
+ Fast486FpuException(State);
+ return;
+ }
}
UnsignedMult128(FirstOperand->Mantissa,
|| (FPU_IS_INFINITY(FirstOperand) && FPU_IS_INFINITY(SecondOperand))
|| (FPU_IS_ZERO(FirstOperand) && FPU_IS_ZERO(SecondOperand)))
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (State->FpuControl.Im)
{
/* Return the indefinite NaN */
Result->Exponent = FPU_MAX_EXPONENT + 1;
Result->Mantissa = FPU_INDEFINITE_MANTISSA;
}
- else
- {
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
- }
+ else Fast486FpuException(State);
return;
}
if (FPU_IS_ZERO(SecondOperand) || FPU_IS_INFINITY(FirstOperand))
{
+ /* Raise the division by zero exception */
+ State->FpuStatus.Ze = TRUE;
+
if (State->FpuControl.Zm)
{
/* Return infinity */
Result->Exponent = FPU_MAX_EXPONENT + 1;
Result->Mantissa = FPU_MANTISSA_HIGH_BIT;
}
- else
- {
- /* Raise the division by zero exception */
- State->FpuStatus.Ze = TRUE;
- }
+ else Fast486FpuException(State);
return;
}
{
ULONG BitsToShift = 64 - CountLeadingZeros64(QuotientHigh);
- if (!State->FpuControl.Pm)
- {
- /* Raise the precision expection */
- State->FpuStatus.Pe = TRUE;
- return;
- }
-
TempResult.Mantissa >>= BitsToShift;
TempResult.Mantissa |= QuotientHigh << (64 - BitsToShift);
Exponent += BitsToShift;
TempResult.Mantissa >>= -(Exponent + FPU_REAL10_BIAS);
Exponent = -FPU_REAL10_BIAS;
- if ((TempResult.Mantissa == 0ULL) && !State->FpuControl.Um)
- {
- /* Raise the underflow exception */
- State->FpuStatus.Ue = TRUE;
- return;
- }
-
// TODO: Rounding
}
if (FPU_GET_TAG(0) == FPU_TAG_EMPTY)
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (State->FpuControl.Im)
{
/* Return the indefinite NaN */
FPU_SET_TAG(0, FPU_TAG_SPECIAL);
}
- else
- {
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
- }
+ else Fast486FpuException(State);
return;
}
{
if (FPU_GET_TAG(ModRegRm.SecondRegister) == FPU_TAG_EMPTY)
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (State->FpuControl.Im)
{
/* Return the indefinite NaN */
FPU_SET_TAG(0, FPU_TAG_SPECIAL);
}
- else
- {
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
- }
+ else Fast486FpuException(State);
return;
}
if (FPU_GET_TAG(0) == FPU_TAG_EMPTY)
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (State->FpuControl.Im)
{
/* Return the indefinite NaN */
FPU_SET_TAG(0, FPU_TAG_SPECIAL);
}
- else
- {
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
- }
+ else Fast486FpuException(State);
return;
}
if ((FPU_GET_TAG(0) == FPU_TAG_EMPTY)
|| (FPU_GET_TAG(ModRegRm.SecondRegister) == FPU_TAG_EMPTY))
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (State->FpuControl.Im)
{
/* Return the indefinite NaN */
FPU_SET_TAG(ModRegRm.SecondRegister, FPU_TAG_SPECIAL);
}
- else
- {
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
- }
+ else Fast486FpuException(State);
return;
}
if ((FPU_GET_TAG(0) == FPU_TAG_EMPTY) || (FPU_GET_TAG(1) == FPU_TAG_EMPTY))
{
- /* Raise the invalid operation exception, if unmasked */
- if (!State->FpuControl.Im) State->FpuStatus.Ie = TRUE;
+ /* Raise the invalid operation exception*/
+ State->FpuStatus.Ie = TRUE;
+
+ if (!State->FpuControl.Im) Fast486FpuException(State);
return;
}
if (FPU_GET_TAG(0) == FPU_TAG_EMPTY)
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (State->FpuControl.Im)
{
/* Return the indefinite NaN */
FPU_SET_TAG(0, FPU_TAG_SPECIAL);
}
- else
- {
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
- }
+ else Fast486FpuException(State);
return;
}
if ((FPU_GET_TAG(0) == FPU_TAG_EMPTY) || (FPU_GET_TAG(0) == FPU_TAG_SPECIAL))
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (!State->FpuControl.Im)
{
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
+ Fast486FpuException(State);
return;
}
}
if ((((ULONGLONG)Temp >> 31) + 1ULL) > 1ULL)
{
State->FpuStatus.Ie = TRUE;
- return;
+
+ if (State->FpuControl.Im) Temp = 0LL;
+ else
+ {
+ Fast486FpuException(State);
+ return;
+ }
}
if (!Fast486WriteModrmDwordOperands(State, &ModRegRm, FALSE, (ULONG)((LONG)Temp)))
}
else
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (State->FpuControl.Im)
{
*((PULONGLONG)Buffer) = FPU_INDEFINITE_MANTISSA;
}
else
{
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
+ Fast486FpuException(State);
return;
}
}
if (FPU_GET_TAG(0) == FPU_TAG_EMPTY)
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (!State->FpuControl.Im)
{
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
+ Fast486FpuException(State);
return;
}
}
if ((FPU_GET_TAG(0) == FPU_TAG_EMPTY)
|| FPU_GET_TAG(ModRegRm.SecondRegister) == FPU_TAG_EMPTY)
{
- if (!State->FpuControl.Im) State->FpuStatus.Ie = TRUE;
+ State->FpuStatus.Ie = TRUE;
+
+ if (!State->FpuControl.Im) Fast486FpuException(State);
break;
}
if ((FPU_GET_TAG(0) == FPU_TAG_EMPTY)
|| (FPU_GET_TAG(ModRegRm.SecondRegister) == FPU_TAG_EMPTY))
{
- if (!State->FpuControl.Im) State->FpuStatus.Ie = TRUE;
+ State->FpuStatus.Ie = TRUE;
+
+ if (!State->FpuControl.Im) Fast486FpuException(State);
return;
}
if (FPU_GET_TAG(0) == FPU_TAG_EMPTY)
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (State->FpuControl.Im)
{
/* Return the indefinite NaN */
FPU_SET_TAG(0, FPU_TAG_SPECIAL);
}
- else
- {
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
- }
+ else Fast486FpuException(State);
return;
}
|| (FPU_GET_TAG(ModRegRm.SecondRegister) == FPU_TAG_EMPTY))
{
/* Raise the invalid operation exception, if unmasked */
- if (!State->FpuControl.Im) State->FpuStatus.Ie = TRUE;
+ State->FpuStatus.Ie = TRUE;
+ if (!State->FpuControl.Im) Fast486FpuException(State);
return;
}
}
if ((FPU_GET_TAG(0) == FPU_TAG_EMPTY) || (FPU_GET_TAG(0) == FPU_TAG_SPECIAL))
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (!State->FpuControl.Im)
{
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
+ Fast486FpuException(State);
return;
}
}
/* Check if it can fit in a signed 16-bit integer */
if ((((ULONGLONG)Temp >> 15) + 1ULL) > 1ULL)
{
+ /* Raise the invalid operation exception */
State->FpuStatus.Ie = TRUE;
- return;
+
+ if (State->FpuControl.Im) Temp = 0LL;
+ else
+ {
+ Fast486FpuException(State);
+ return;
+ }
}
if (!Fast486WriteModrmWordOperands(State, &ModRegRm, FALSE, (USHORT)((SHORT)Temp)))
if (FPU_GET_TAG(0) == FPU_TAG_EMPTY)
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (!State->FpuControl.Im)
{
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
+ Fast486FpuException(State);
return;
}
}
if ((FPU_GET_TAG(0) == FPU_TAG_EMPTY) || (FPU_GET_TAG(0) == FPU_TAG_SPECIAL))
{
+ /* Raise the invalid operation exception */
+ State->FpuStatus.Ie = TRUE;
+
if (!State->FpuControl.Im)
{
- /* Raise the invalid operation exception */
- State->FpuStatus.Ie = TRUE;
+ Fast486FpuException(State);
return;
}
}
if ((FPU_GET_TAG(0) == FPU_TAG_EMPTY)
|| FPU_GET_TAG(ModRegRm.SecondRegister) == FPU_TAG_EMPTY)
{
- if (!State->FpuControl.Im) State->FpuStatus.Ie = TRUE;
+ State->FpuStatus.Ie = TRUE;
+
+ if (!State->FpuControl.Im) Fast486FpuException(State);
break;
}