Update.
[glibc.git] / sysdeps / sparc / udiv_qrnnd.S
blob74b932d34b2251016d89db24fbfad47136182953
1 ! SPARC  __udiv_qrnnd division support, used from longlong.h.
3 ! Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc.
5 ! This file is part of the GNU MP Library.
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
22 ! Added PIC support - May/96, Miguel de Icaza
24 ! INPUT PARAMETERS
25 ! rem_ptr       i0
26 ! n1            i1
27 ! n0            i2
28 ! d             i3
30 #include "sysdep.h"
31 #undef ret      /* Kludge for glibc */
33         .text
34         .align  8
35 LC0:    .double 0r4294967296
36 LC1:    .double 0r2147483648
38         .align  4
39         .global __udiv_qrnnd
40         .type   __udiv_qrnnd,@function
41 ENTRY(__udiv_qrnnd)
42         !#PROLOGUE# 0
43         save    %sp,-104,%sp
44         !#PROLOGUE# 1
45         st      %i1,[%fp-8]
46         ld      [%fp-8],%f10
47 #ifdef __PIC__
48 ._XL11:
49         call    ._XL1
50         fitod   %f10,%f4
51 ._XL1:
52         sub     %o7,(._XL11-LC0),%o7
53         ldd     [%o7],%f8
54 #else
55         sethi   %hi(LC0),%o7
56         fitod   %f10,%f4
57         ldd     [%o7+%lo(LC0)],%f8
58 #endif
59         cmp     %i1,0
60         bge     L248
61         mov     %i0,%i5
62         faddd   %f4,%f8,%f4
63 L248:
64         st      %i2,[%fp-8]
65         ld      [%fp-8],%f10
66         fmuld   %f4,%f8,%f6
67         cmp     %i2,0
68         bge     L249
69         fitod   %f10,%f2
70         faddd   %f2,%f8,%f2
71 L249:
72         st      %i3,[%fp-8]
73         faddd   %f6,%f2,%f2
74         ld      [%fp-8],%f10
75         cmp     %i3,0
76         bge     L250
77         fitod   %f10,%f4
78         faddd   %f4,%f8,%f4
79 L250:
80         fdivd   %f2,%f4,%f2
81 #ifdef __PIC__
82 ._XL22:
83         call    ._XL2
84         nop
85 ._XL2:
86         sub     %o7,(._XL22-LC1),%o7
87         ldd     [%o7],%f4
88 #else
89         sethi   %hi(LC1),%o7
90         ldd     [%o7+%lo(LC1)],%f4
91 #endif
92         fcmped  %f2,%f4
93         nop
94         fbge,a  L251
95         fsubd   %f2,%f4,%f2
96         fdtoi   %f2,%f2
97         st      %f2,[%fp-8]
98         b       L252
99         ld      [%fp-8],%i4
100 L251:
101         fdtoi   %f2,%f2
102         st      %f2,[%fp-8]
103         ld      [%fp-8],%i4
104         sethi   %hi(-2147483648),%g2
105         xor     %i4,%g2,%i4
106 L252:
107         wr      %g0,%i4,%y
108         sra     %i3,31,%g2
109         and     %i4,%g2,%g2
110         andcc   %g0,0,%g1
111         mulscc  %g1,%i3,%g1
112         mulscc  %g1,%i3,%g1
113         mulscc  %g1,%i3,%g1
114         mulscc  %g1,%i3,%g1
115         mulscc  %g1,%i3,%g1
116         mulscc  %g1,%i3,%g1
117         mulscc  %g1,%i3,%g1
118         mulscc  %g1,%i3,%g1
119         mulscc  %g1,%i3,%g1
120         mulscc  %g1,%i3,%g1
121         mulscc  %g1,%i3,%g1
122         mulscc  %g1,%i3,%g1
123         mulscc  %g1,%i3,%g1
124         mulscc  %g1,%i3,%g1
125         mulscc  %g1,%i3,%g1
126         mulscc  %g1,%i3,%g1
127         mulscc  %g1,%i3,%g1
128         mulscc  %g1,%i3,%g1
129         mulscc  %g1,%i3,%g1
130         mulscc  %g1,%i3,%g1
131         mulscc  %g1,%i3,%g1
132         mulscc  %g1,%i3,%g1
133         mulscc  %g1,%i3,%g1
134         mulscc  %g1,%i3,%g1
135         mulscc  %g1,%i3,%g1
136         mulscc  %g1,%i3,%g1
137         mulscc  %g1,%i3,%g1
138         mulscc  %g1,%i3,%g1
139         mulscc  %g1,%i3,%g1
140         mulscc  %g1,%i3,%g1
141         mulscc  %g1,%i3,%g1
142         mulscc  %g1,%i3,%g1
143         mulscc  %g1,0,%g1
144         add     %g1,%g2,%i0
145         rd      %y,%g3
146         subcc   %i2,%g3,%o7
147         subxcc  %i1,%i0,%g0
148         be      L253
149         cmp     %o7,%i3
151         add     %i4,-1,%i0
152         add     %o7,%i3,%o7
153         st      %o7,[%i5]
154         ret
155         restore
156 L253:
157         blu     L246
158         mov     %i4,%i0
159         add     %i4,1,%i0
160         sub     %o7,%i3,%o7
161 L246:
162         st      %o7,[%i5]
163         ret
164         restore