]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/alpha/udiv_qrnnd.S
update from main archive 961105
[thirdparty/glibc.git] / sysdeps / alpha / udiv_qrnnd.S
1 # Alpha 21064 __udiv_qrnnd
2
3 # Copyright (C) 1992, 1994, 1995 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 Library General Public License as published by
9 # the Free Software Foundation; either version 2 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 Library General Public
15 # License for more details.
16
17 # You should have received a copy of the GNU Library General Public License
18 # along with the GNU MP Library; see the file COPYING.LIB. If not, write to
19 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 # MA 02111-1307, USA.
21
22 #include <sysdep.h>
23
24 .set noreorder
25 .set noat
26
27 .text
28
29 LEAF(__udiv_qrnnd, 0)
30 #ifdef PROF
31 ldgp gp, 0(pv)
32 lda AT, _mcount
33 jsr AT, (AT), _mcount
34 .prologue 1
35 #else
36 .prologue 0
37 #endif
38
39 #define cnt $2
40 #define tmp $3
41 #define rem_ptr $16
42 #define n1 $17
43 #define n0 $18
44 #define d $19
45 #define qb $20
46
47 ldiq cnt,16
48 blt d,$largedivisor
49
50 $loop1: cmplt n0,0,tmp
51 addq n1,n1,n1
52 bis n1,tmp,n1
53 addq n0,n0,n0
54 cmpule d,n1,qb
55 subq n1,d,tmp
56 cmovne qb,tmp,n1
57 bis n0,qb,n0
58 cmplt n0,0,tmp
59 addq n1,n1,n1
60 bis n1,tmp,n1
61 addq n0,n0,n0
62 cmpule d,n1,qb
63 subq n1,d,tmp
64 cmovne qb,tmp,n1
65 bis n0,qb,n0
66 cmplt n0,0,tmp
67 addq n1,n1,n1
68 bis n1,tmp,n1
69 addq n0,n0,n0
70 cmpule d,n1,qb
71 subq n1,d,tmp
72 cmovne qb,tmp,n1
73 bis n0,qb,n0
74 cmplt n0,0,tmp
75 addq n1,n1,n1
76 bis n1,tmp,n1
77 addq n0,n0,n0
78 cmpule d,n1,qb
79 subq n1,d,tmp
80 cmovne qb,tmp,n1
81 bis n0,qb,n0
82 subq cnt,1,cnt
83 bgt cnt,$loop1
84 stq n1,0(rem_ptr)
85 bis $31,n0,$0
86 ret $31,($26),1
87
88 $largedivisor:
89 and n0,1,$4
90
91 srl n0,1,n0
92 sll n1,63,tmp
93 or tmp,n0,n0
94 srl n1,1,n1
95
96 and d,1,$6
97 srl d,1,$5
98 addq $5,$6,$5
99
100 $loop2: cmplt n0,0,tmp
101 addq n1,n1,n1
102 bis n1,tmp,n1
103 addq n0,n0,n0
104 cmpule $5,n1,qb
105 subq n1,$5,tmp
106 cmovne qb,tmp,n1
107 bis n0,qb,n0
108 cmplt n0,0,tmp
109 addq n1,n1,n1
110 bis n1,tmp,n1
111 addq n0,n0,n0
112 cmpule $5,n1,qb
113 subq n1,$5,tmp
114 cmovne qb,tmp,n1
115 bis n0,qb,n0
116 cmplt n0,0,tmp
117 addq n1,n1,n1
118 bis n1,tmp,n1
119 addq n0,n0,n0
120 cmpule $5,n1,qb
121 subq n1,$5,tmp
122 cmovne qb,tmp,n1
123 bis n0,qb,n0
124 cmplt n0,0,tmp
125 addq n1,n1,n1
126 bis n1,tmp,n1
127 addq n0,n0,n0
128 cmpule $5,n1,qb
129 subq n1,$5,tmp
130 cmovne qb,tmp,n1
131 bis n0,qb,n0
132 subq cnt,1,cnt
133 bgt cnt,$loop2
134
135 addq n1,n1,n1
136 addq $4,n1,n1
137 bne $6,$Odd
138 stq n1,0(rem_ptr)
139 bis $31,n0,$0
140 ret $31,($26),1
141
142 $Odd:
143 /* q' in n0. r' in n1 */
144 addq n1,n0,n1
145
146 cmpult n1,n0,tmp # tmp := carry from addq
147 subq n1,d,AT
148 addq n0,tmp,n0
149 cmovne tmp,AT,n1
150
151 cmpult n1,d,tmp
152 addq n0,1,AT
153 cmoveq tmp,AT,n0
154 subq n1,d,AT
155 cmoveq tmp,AT,n1
156
157 stq n1,0(rem_ptr)
158 bis $31,n0,$0
159 ret $31,($26),1
160
161 .end __udiv_qrnnd