1 /* Copyright (C) 1996, 1997, 2001, 2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Richard Henderson <rth@tamu.edu>.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
59 _ITOFT2 X, $f0, 0, Y, $f1, 8
67 /* Check to see if X fit in the double as an exact value. */
73 /* If we get here, we're expecting exact results from the division.
74 Do nothing else besides convert and clean up. */
95 /* If we get here, X is large enough that we don't expect exact
96 results, and neither X nor Y got mis-translated for the fp
97 division. Our task is to take the fp result, figure out how
98 far it's off from the correct result and compute a fixup. */
100 #define Q v0 /* quotient */
101 #define R t0 /* remainder */
102 #define SY t1 /* scaled Y */
103 #define S t2 /* scalar */
104 #define QY t3 /* Q*Y */
106 /* The fixup code below can only handle unsigned values. */
137 /* The quotient that we computed was too large. We need to reduce
138 it by S such that Y*S >= R. Obviously the closer we get to the
139 correct value the better, but overshooting high is ok, as we'll
140 fix that up later. */
154 /* The quotient that we computed was too small. Divide Y by the
155 current remainder (R) and add that to the existing quotient (Q).
156 The expectation, of course, is that R is much smaller than X. */
157 /* Begin with a shift-up loop. Compute S such that Y*S >= R. We
158 already have a copy of Y in SY and the value 1 in S. */
166 /* Shift-down and subtract loop. Each iteration compares our scaled
167 Y (SY) with the remainder (R); if SY <= R then X is divisible by
168 Y's scalar (S) so add it to the quotient (Q). */
183 /* If we got here, then X|Y is negative. Need to adjust everything
184 such that we're doing unsigned division in the fixup loop. */
185 /* T5 is true if result should be negative. */
196 blbc t5, $fix_sign_in_ret1
218 weak_alias (ldiv, lldiv)