.
[glibc-ports.git] / sysdeps / hppa / udiv_qrnnd.s
blob8e9c07a2058f0b3d450d8336ed88a0f0a2f93704
1 ;! HP-PA __udiv_qrnnd division support, used from longlong.h.
2 ;! This version runs fast on pre-PA7000 CPUs.
4 ;! Copyright (C) 1993, 1994 Free Software Foundation, Inc.
6 ;! This file is part of the GNU MP Library.
8 ;! The GNU MP Library is free software; you can redistribute it and/or modify
9 ;! it under the terms of the GNU Lesser General Public License as published by
10 ;! the Free Software Foundation; either version 2.1 of the License, or (at your
11 ;! option) any later version.
13 ;! The GNU MP Library is distributed in the hope that it will be useful, but
14 ;! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ;! or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 ;! License for more details.
18 ;! You should have received a copy of the GNU Lesser General Public License
19 ;! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
20 ;! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 ;! MA 02111-1307, USA.
24 ;! INPUT PARAMETERS
25 ;! rem_ptr gr26
26 ;! n1 gr25
27 ;! n0 gr24
28 ;! d gr23
30 ;! The code size is a bit excessive. We could merge the last two ds;addc
31 ;! sequences by simply moving the "bb,< Odd" instruction down. The only
32 ;! trouble is the FFFFFFFF code that would need some hacking.
34 .text
35 .export __udiv_qrnnd
36 __udiv_qrnnd:
37 .proc
38 .callinfo frame=0,no_calls
39 .entry
41 comb,< %r23,%r0,L$largedivisor
42 sub %r0,%r23,%r1 ;! clear cy as side-effect
43 ds %r0,%r1,%r0
44 addc %r24,%r24,%r24
45 ds %r25,%r23,%r25
46 addc %r24,%r24,%r24
47 ds %r25,%r23,%r25
48 addc %r24,%r24,%r24
49 ds %r25,%r23,%r25
50 addc %r24,%r24,%r24
51 ds %r25,%r23,%r25
52 addc %r24,%r24,%r24
53 ds %r25,%r23,%r25
54 addc %r24,%r24,%r24
55 ds %r25,%r23,%r25
56 addc %r24,%r24,%r24
57 ds %r25,%r23,%r25
58 addc %r24,%r24,%r24
59 ds %r25,%r23,%r25
60 addc %r24,%r24,%r24
61 ds %r25,%r23,%r25
62 addc %r24,%r24,%r24
63 ds %r25,%r23,%r25
64 addc %r24,%r24,%r24
65 ds %r25,%r23,%r25
66 addc %r24,%r24,%r24
67 ds %r25,%r23,%r25
68 addc %r24,%r24,%r24
69 ds %r25,%r23,%r25
70 addc %r24,%r24,%r24
71 ds %r25,%r23,%r25
72 addc %r24,%r24,%r24
73 ds %r25,%r23,%r25
74 addc %r24,%r24,%r24
75 ds %r25,%r23,%r25
76 addc %r24,%r24,%r24
77 ds %r25,%r23,%r25
78 addc %r24,%r24,%r24
79 ds %r25,%r23,%r25
80 addc %r24,%r24,%r24
81 ds %r25,%r23,%r25
82 addc %r24,%r24,%r24
83 ds %r25,%r23,%r25
84 addc %r24,%r24,%r24
85 ds %r25,%r23,%r25
86 addc %r24,%r24,%r24
87 ds %r25,%r23,%r25
88 addc %r24,%r24,%r24
89 ds %r25,%r23,%r25
90 addc %r24,%r24,%r24
91 ds %r25,%r23,%r25
92 addc %r24,%r24,%r24
93 ds %r25,%r23,%r25
94 addc %r24,%r24,%r24
95 ds %r25,%r23,%r25
96 addc %r24,%r24,%r24
97 ds %r25,%r23,%r25
98 addc %r24,%r24,%r24
99 ds %r25,%r23,%r25
100 addc %r24,%r24,%r24
101 ds %r25,%r23,%r25
102 addc %r24,%r24,%r24
103 ds %r25,%r23,%r25
104 addc %r24,%r24,%r24
105 ds %r25,%r23,%r25
106 addc %r24,%r24,%r28
107 ds %r25,%r23,%r25
108 comclr,>= %r25,%r0,%r0
109 addl %r25,%r23,%r25
110 stws %r25,0(%r26)
111 bv 0(%r2)
112 addc %r28,%r28,%r28
114 L$largedivisor:
115 extru %r24,31,1,%r20 ;! r20 = n0 & 1
116 bb,< %r23,31,L$odd
117 extru %r23,30,31,%r22 ;! r22 = d >> 1
118 shd %r25,%r24,1,%r24 ;! r24 = new n0
119 extru %r25,30,31,%r25 ;! r25 = new n1
120 sub %r0,%r22,%r21
121 ds %r0,%r21,%r0
122 addc %r24,%r24,%r24
123 ds %r25,%r22,%r25
124 addc %r24,%r24,%r24
125 ds %r25,%r22,%r25
126 addc %r24,%r24,%r24
127 ds %r25,%r22,%r25
128 addc %r24,%r24,%r24
129 ds %r25,%r22,%r25
130 addc %r24,%r24,%r24
131 ds %r25,%r22,%r25
132 addc %r24,%r24,%r24
133 ds %r25,%r22,%r25
134 addc %r24,%r24,%r24
135 ds %r25,%r22,%r25
136 addc %r24,%r24,%r24
137 ds %r25,%r22,%r25
138 addc %r24,%r24,%r24
139 ds %r25,%r22,%r25
140 addc %r24,%r24,%r24
141 ds %r25,%r22,%r25
142 addc %r24,%r24,%r24
143 ds %r25,%r22,%r25
144 addc %r24,%r24,%r24
145 ds %r25,%r22,%r25
146 addc %r24,%r24,%r24
147 ds %r25,%r22,%r25
148 addc %r24,%r24,%r24
149 ds %r25,%r22,%r25
150 addc %r24,%r24,%r24
151 ds %r25,%r22,%r25
152 addc %r24,%r24,%r24
153 ds %r25,%r22,%r25
154 addc %r24,%r24,%r24
155 ds %r25,%r22,%r25
156 addc %r24,%r24,%r24
157 ds %r25,%r22,%r25
158 addc %r24,%r24,%r24
159 ds %r25,%r22,%r25
160 addc %r24,%r24,%r24
161 ds %r25,%r22,%r25
162 addc %r24,%r24,%r24
163 ds %r25,%r22,%r25
164 addc %r24,%r24,%r24
165 ds %r25,%r22,%r25
166 addc %r24,%r24,%r24
167 ds %r25,%r22,%r25
168 addc %r24,%r24,%r24
169 ds %r25,%r22,%r25
170 addc %r24,%r24,%r24
171 ds %r25,%r22,%r25
172 addc %r24,%r24,%r24
173 ds %r25,%r22,%r25
174 addc %r24,%r24,%r24
175 ds %r25,%r22,%r25
176 addc %r24,%r24,%r24
177 ds %r25,%r22,%r25
178 addc %r24,%r24,%r24
179 ds %r25,%r22,%r25
180 addc %r24,%r24,%r24
181 ds %r25,%r22,%r25
182 addc %r24,%r24,%r24
183 ds %r25,%r22,%r25
184 addc %r24,%r24,%r24
185 ds %r25,%r22,%r25
186 comclr,>= %r25,%r0,%r0
187 addl %r25,%r22,%r25
188 sh1addl %r25,%r20,%r25
189 stws %r25,0(%r26)
190 bv 0(%r2)
191 addc %r24,%r24,%r28
193 L$odd: addib,sv,n 1,%r22,L$FF.. ;! r22 = (d / 2 + 1)
194 shd %r25,%r24,1,%r24 ;! r24 = new n0
195 extru %r25,30,31,%r25 ;! r25 = new n1
196 sub %r0,%r22,%r21
197 ds %r0,%r21,%r0
198 addc %r24,%r24,%r24
199 ds %r25,%r22,%r25
200 addc %r24,%r24,%r24
201 ds %r25,%r22,%r25
202 addc %r24,%r24,%r24
203 ds %r25,%r22,%r25
204 addc %r24,%r24,%r24
205 ds %r25,%r22,%r25
206 addc %r24,%r24,%r24
207 ds %r25,%r22,%r25
208 addc %r24,%r24,%r24
209 ds %r25,%r22,%r25
210 addc %r24,%r24,%r24
211 ds %r25,%r22,%r25
212 addc %r24,%r24,%r24
213 ds %r25,%r22,%r25
214 addc %r24,%r24,%r24
215 ds %r25,%r22,%r25
216 addc %r24,%r24,%r24
217 ds %r25,%r22,%r25
218 addc %r24,%r24,%r24
219 ds %r25,%r22,%r25
220 addc %r24,%r24,%r24
221 ds %r25,%r22,%r25
222 addc %r24,%r24,%r24
223 ds %r25,%r22,%r25
224 addc %r24,%r24,%r24
225 ds %r25,%r22,%r25
226 addc %r24,%r24,%r24
227 ds %r25,%r22,%r25
228 addc %r24,%r24,%r24
229 ds %r25,%r22,%r25
230 addc %r24,%r24,%r24
231 ds %r25,%r22,%r25
232 addc %r24,%r24,%r24
233 ds %r25,%r22,%r25
234 addc %r24,%r24,%r24
235 ds %r25,%r22,%r25
236 addc %r24,%r24,%r24
237 ds %r25,%r22,%r25
238 addc %r24,%r24,%r24
239 ds %r25,%r22,%r25
240 addc %r24,%r24,%r24
241 ds %r25,%r22,%r25
242 addc %r24,%r24,%r24
243 ds %r25,%r22,%r25
244 addc %r24,%r24,%r24
245 ds %r25,%r22,%r25
246 addc %r24,%r24,%r24
247 ds %r25,%r22,%r25
248 addc %r24,%r24,%r24
249 ds %r25,%r22,%r25
250 addc %r24,%r24,%r24
251 ds %r25,%r22,%r25
252 addc %r24,%r24,%r24
253 ds %r25,%r22,%r25
254 addc %r24,%r24,%r24
255 ds %r25,%r22,%r25
256 addc %r24,%r24,%r24
257 ds %r25,%r22,%r25
258 addc %r24,%r24,%r24
259 ds %r25,%r22,%r25
260 addc %r24,%r24,%r24
261 ds %r25,%r22,%r25
262 addc %r24,%r24,%r28
263 comclr,>= %r25,%r0,%r0
264 addl %r25,%r22,%r25
265 sh1addl %r25,%r20,%r25
266 ;! We have computed (n1,,n0) / (d + 1), q' = r28, r' = r25
267 add,nuv %r28,%r25,%r25
268 addl %r25,%r1,%r25
269 addc %r0,%r28,%r28
270 sub,<< %r25,%r23,%r0
271 addl %r25,%r1,%r25
272 stws %r25,0(%r26)
273 bv 0(%r2)
274 addc %r0,%r28,%r28
276 ;! This is just a special case of the code above.
277 ;! We come here when d == 0xFFFFFFFF
278 L$FF..: add,uv %r25,%r24,%r24
279 sub,<< %r24,%r23,%r0
280 ldo 1(%r24),%r24
281 stws %r24,0(%r26)
282 bv 0(%r2)
283 addc %r0,%r25,%r28
285 .exit
286 .procend