Author: aandrejevic Date: Mon May 18 12:17:40 2015 New Revision: 67820
URL: http://svn.reactos.org/svn/reactos?rev=67820&view=rev Log: [FAST486] Fix several division related problems: - In UnsignedDivMod128, fix the leading zero calculation for 128-bit numbers. - In Fast486FpuDivide, there's no need to increase the exponent by 64 (adding zeros at the end of a number after the decimal point changes nothing). - FDIV/FDIVR were reversed
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=67820... ============================================================================== --- trunk/reactos/lib/fast486/fpu.c [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/fpu.c [iso-8859-1] Mon May 18 12:17:40 2015 @@ -203,9 +203,9 @@ * Calculate the number of significant bits the current * divisor has more than the original divisor */ - Bits = CountLeadingZeros64(Divisor) + 64; - Bits -= (CurrentHigh > 0ULL) ? CountLeadingZeros64(CurrentHigh) : 64; - Bits -= (CurrentLow > 0ULL) ? CountLeadingZeros64(CurrentLow) : 64; + Bits = CountLeadingZeros64(Divisor); + if (CurrentHigh > 0ULL) Bits -= CountLeadingZeros64(CurrentHigh); + else Bits -= CountLeadingZeros64(CurrentLow);
if (Bits) { @@ -923,11 +923,10 @@ }
/* Calculate the exponent of the result */ - Exponent = (LONG)FirstOperand->Exponent - (LONG)SecondOperand->Exponent - 64; + Exponent = (LONG)FirstOperand->Exponent - (LONG)SecondOperand->Exponent - 1;
/* Divide the two mantissas */ Remainder = UnsignedDivMod128(0ULL, - /* Notice the 64 above - this is the high part */ FirstOperand->Mantissa, SecondOperand->Mantissa, &QuotientLow, @@ -1169,14 +1168,14 @@ /* FDIV */ case 6: { - Fast486FpuDivide(State, DestOperand, SourceOperand, DestOperand); + Fast486FpuDivide(State, SourceOperand, DestOperand, DestOperand); break; }
/* FDIVR */ case 7: { - Fast486FpuDivide(State, SourceOperand, DestOperand, DestOperand); + Fast486FpuDivide(State, DestOperand, SourceOperand, DestOperand); break; } }