Author: aandrejevic Date: Tue May 19 02:37:17 2015 New Revision: 67827
URL: http://svn.reactos.org/svn/reactos?rev=67827&view=rev Log: [FAST486] Fix UnsignedDivMod128 (again). Fix Fast486FpuAdd to handle numbers whose difference of exponents is greater than the number of bits in the mantissa.
Modified: trunk/reactos/lib/fast486/fpu.c
Modified: trunk/reactos/lib/fast486/fpu.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/fpu.c?rev=67827... ============================================================================== --- trunk/reactos/lib/fast486/fpu.c [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/fpu.c [iso-8859-1] Tue May 19 02:37:17 2015 @@ -204,8 +204,15 @@ * divisor has more than the original divisor */ Bits = CountLeadingZeros64(Divisor); - if (CurrentHigh > 0ULL) Bits -= CountLeadingZeros64(CurrentHigh); + if (CurrentHigh > 0ULL) Bits += 64 - CountLeadingZeros64(CurrentHigh); else Bits -= CountLeadingZeros64(CurrentLow); + + if (Bits >= 64) + { + *QuotientHigh = *QuotientLow; + *QuotientLow = 0ULL; + Bits -= 64; + }
if (Bits) { @@ -635,15 +642,33 @@ /* Adjust the first operand to it... */ if (FirstAdjusted.Exponent < TempResult.Exponent) { - FirstAdjusted.Mantissa >>= (TempResult.Exponent - FirstAdjusted.Exponent); - FirstAdjusted.Exponent = TempResult.Exponent; + if ((TempResult.Exponent - FirstAdjusted.Exponent) < 64) + { + FirstAdjusted.Mantissa >>= (TempResult.Exponent - FirstAdjusted.Exponent); + FirstAdjusted.Exponent = TempResult.Exponent; + } + else + { + /* The second operand is the result */ + *Result = *SecondOperand; + return TRUE; + } }
/* ... and the second one too */ if (SecondAdjusted.Exponent < TempResult.Exponent) { - SecondAdjusted.Mantissa >>= (TempResult.Exponent - SecondAdjusted.Exponent); - SecondAdjusted.Exponent = TempResult.Exponent; + if ((TempResult.Exponent - FirstAdjusted.Exponent) < 64) + { + SecondAdjusted.Mantissa >>= (TempResult.Exponent - SecondAdjusted.Exponent); + SecondAdjusted.Exponent = TempResult.Exponent; + } + else + { + /* The first operand is the result */ + *Result = *FirstOperand; + return TRUE; + } }
if (FirstAdjusted.Sign == SecondAdjusted.Sign)