1 | # Alpha 21064 __udiv_qrnnd |
2 | |
3 | # Copyright (C) 1992-2022 Free Software Foundation, Inc. |
4 | |
5 | # This file is part of the GNU MP Library. |
6 | |
7 | # The GNU MP Library is free software; you can redistribute it and/or modify |
8 | # it under the terms of the GNU Lesser General Public License as published by |
9 | # the Free Software Foundation; either version 2.1 of the License, or (at your |
10 | # option) any later version. |
11 | |
12 | # The GNU MP Library is distributed in the hope that it will be useful, but |
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
15 | # License for more details. |
16 | |
17 | # You should have received a copy of the GNU Lesser General Public License |
18 | # along with the GNU MP Library. If not, see <https://www.gnu.org/licenses/>. |
19 | |
20 | #include <sysdep.h> |
21 | |
22 | .set noreorder |
23 | .set noat |
24 | |
25 | .text |
26 | |
27 | LEAF(__udiv_qrnnd, 0) |
28 | #ifdef PROF |
29 | ldgp gp, 0(pv) |
30 | lda AT, _mcount |
31 | jsr AT, (AT), _mcount |
32 | .prologue 1 |
33 | #else |
34 | .prologue 0 |
35 | #endif |
36 | |
37 | #define cnt $2 |
38 | #define tmp $3 |
39 | #define rem_ptr $16 |
40 | #define n1 $17 |
41 | #define n0 $18 |
42 | #define d $19 |
43 | #define qb $20 |
44 | |
45 | ldiq cnt,16 |
46 | blt d,$largedivisor |
47 | |
48 | $loop1: cmplt n0,0,tmp |
49 | addq n1,n1,n1 |
50 | bis n1,tmp,n1 |
51 | addq n0,n0,n0 |
52 | cmpule d,n1,qb |
53 | subq n1,d,tmp |
54 | cmovne qb,tmp,n1 |
55 | bis n0,qb,n0 |
56 | cmplt n0,0,tmp |
57 | addq n1,n1,n1 |
58 | bis n1,tmp,n1 |
59 | addq n0,n0,n0 |
60 | cmpule d,n1,qb |
61 | subq n1,d,tmp |
62 | cmovne qb,tmp,n1 |
63 | bis n0,qb,n0 |
64 | cmplt n0,0,tmp |
65 | addq n1,n1,n1 |
66 | bis n1,tmp,n1 |
67 | addq n0,n0,n0 |
68 | cmpule d,n1,qb |
69 | subq n1,d,tmp |
70 | cmovne qb,tmp,n1 |
71 | bis n0,qb,n0 |
72 | cmplt n0,0,tmp |
73 | addq n1,n1,n1 |
74 | bis n1,tmp,n1 |
75 | addq n0,n0,n0 |
76 | cmpule d,n1,qb |
77 | subq n1,d,tmp |
78 | cmovne qb,tmp,n1 |
79 | bis n0,qb,n0 |
80 | subq cnt,1,cnt |
81 | bgt cnt,$loop1 |
82 | stq n1,0(rem_ptr) |
83 | bis $31,n0,$0 |
84 | ret $31,($26),1 |
85 | |
86 | $largedivisor: |
87 | and n0,1,$4 |
88 | |
89 | srl n0,1,n0 |
90 | sll n1,63,tmp |
91 | or tmp,n0,n0 |
92 | srl n1,1,n1 |
93 | |
94 | and d,1,$6 |
95 | srl d,1,$5 |
96 | addq $5,$6,$5 |
97 | |
98 | $loop2: cmplt n0,0,tmp |
99 | addq n1,n1,n1 |
100 | bis n1,tmp,n1 |
101 | addq n0,n0,n0 |
102 | cmpule $5,n1,qb |
103 | subq n1,$5,tmp |
104 | cmovne qb,tmp,n1 |
105 | bis n0,qb,n0 |
106 | cmplt n0,0,tmp |
107 | addq n1,n1,n1 |
108 | bis n1,tmp,n1 |
109 | addq n0,n0,n0 |
110 | cmpule $5,n1,qb |
111 | subq n1,$5,tmp |
112 | cmovne qb,tmp,n1 |
113 | bis n0,qb,n0 |
114 | cmplt n0,0,tmp |
115 | addq n1,n1,n1 |
116 | bis n1,tmp,n1 |
117 | addq n0,n0,n0 |
118 | cmpule $5,n1,qb |
119 | subq n1,$5,tmp |
120 | cmovne qb,tmp,n1 |
121 | bis n0,qb,n0 |
122 | cmplt n0,0,tmp |
123 | addq n1,n1,n1 |
124 | bis n1,tmp,n1 |
125 | addq n0,n0,n0 |
126 | cmpule $5,n1,qb |
127 | subq n1,$5,tmp |
128 | cmovne qb,tmp,n1 |
129 | bis n0,qb,n0 |
130 | subq cnt,1,cnt |
131 | bgt cnt,$loop2 |
132 | |
133 | addq n1,n1,n1 |
134 | addq $4,n1,n1 |
135 | bne $6,$Odd |
136 | stq n1,0(rem_ptr) |
137 | bis $31,n0,$0 |
138 | ret $31,($26),1 |
139 | |
140 | $Odd: |
141 | /* q' in n0. r' in n1 */ |
142 | addq n1,n0,n1 |
143 | |
144 | cmpult n1,n0,tmp # tmp := carry from addq |
145 | subq n1,d,AT |
146 | addq n0,tmp,n0 |
147 | cmovne tmp,AT,n1 |
148 | |
149 | cmpult n1,d,tmp |
150 | addq n0,1,AT |
151 | cmoveq tmp,AT,n0 |
152 | subq n1,d,AT |
153 | cmoveq tmp,AT,n1 |
154 | |
155 | stq n1,0(rem_ptr) |
156 | bis $31,n0,$0 |
157 | ret $31,($26),1 |
158 | |
159 | .end __udiv_qrnnd |
160 | |