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