~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/gmp/mpn/sparc32/udiv_nfp.asm

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2006-05-17 02:46:26 UTC
  • Revision ID: james.westby@ubuntu.com-20060517024626-lljr08ftv9g9vefl
Tags: upstream-0.9h-20060510
ImportĀ upstreamĀ versionĀ 0.9h-20060510

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl  SPARC v7 __udiv_qrnnd division support, used from longlong.h.
 
2
dnl  This is for v7 CPUs without a floating-point unit.
 
3
 
 
4
dnl  Copyright 1993, 1994, 1996, 2000 Free Software Foundation, Inc.
 
5
 
 
6
dnl  This file is part of the GNU MP Library.
 
7
 
 
8
dnl  The GNU MP Library is free software; you can redistribute it and/or modify
 
9
dnl  it under the terms of the GNU Lesser General Public License as published
 
10
dnl  by the Free Software Foundation; either version 2.1 of the License, or (at
 
11
dnl  your option) any later version.
 
12
 
 
13
dnl  The GNU MP Library is distributed in the hope that it will be useful, but
 
14
dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
15
dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 
16
dnl  License for more details.
 
17
 
 
18
dnl  You should have received a copy of the GNU Lesser General Public License
 
19
dnl  along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
 
20
dnl  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 
21
dnl  MA 02111-1307, USA.
 
22
 
 
23
 
 
24
include(`../config.m4')
 
25
 
 
26
C INPUT PARAMETERS
 
27
C rem_ptr       o0
 
28
C n1            o1
 
29
C n0            o2
 
30
C d             o3
 
31
 
 
32
ASM_START()
 
33
PROLOGUE(mpn_udiv_qrnnd)
 
34
        tst     %o3
 
35
        bneg    L(largedivisor)
 
36
        mov     8,%g1
 
37
 
 
38
        b       L(p1)
 
39
        addxcc  %o2,%o2,%o2
 
40
 
 
41
L(plop):
 
42
        bcc     L(n1)
 
43
        addxcc  %o2,%o2,%o2
 
44
L(p1):  addx    %o1,%o1,%o1
 
45
        subcc   %o1,%o3,%o4
 
46
        bcc     L(n2)
 
47
        addxcc  %o2,%o2,%o2
 
48
L(p2):  addx    %o1,%o1,%o1
 
49
        subcc   %o1,%o3,%o4
 
50
        bcc     L(n3)
 
51
        addxcc  %o2,%o2,%o2
 
52
L(p3):  addx    %o1,%o1,%o1
 
53
        subcc   %o1,%o3,%o4
 
54
        bcc     L(n4)
 
55
        addxcc  %o2,%o2,%o2
 
56
L(p4):  addx    %o1,%o1,%o1
 
57
        addcc   %g1,-1,%g1
 
58
        bne     L(plop)
 
59
        subcc   %o1,%o3,%o4
 
60
        bcc     L(n5)
 
61
        addxcc  %o2,%o2,%o2
 
62
L(p5):  st      %o1,[%o0]
 
63
        retl
 
64
        xnor    %g0,%o2,%o0
 
65
 
 
66
L(nlop):
 
67
        bcc     L(p1)
 
68
        addxcc  %o2,%o2,%o2
 
69
L(n1):  addx    %o4,%o4,%o4
 
70
        subcc   %o4,%o3,%o1
 
71
        bcc     L(p2)
 
72
        addxcc  %o2,%o2,%o2
 
73
L(n2):  addx    %o4,%o4,%o4
 
74
        subcc   %o4,%o3,%o1
 
75
        bcc     L(p3)
 
76
        addxcc  %o2,%o2,%o2
 
77
L(n3):  addx    %o4,%o4,%o4
 
78
        subcc   %o4,%o3,%o1
 
79
        bcc     L(p4)
 
80
        addxcc  %o2,%o2,%o2
 
81
L(n4):  addx    %o4,%o4,%o4
 
82
        addcc   %g1,-1,%g1
 
83
        bne     L(nlop)
 
84
        subcc   %o4,%o3,%o1
 
85
        bcc     L(p5)
 
86
        addxcc  %o2,%o2,%o2
 
87
L(n5):  st      %o4,[%o0]
 
88
        retl
 
89
        xnor    %g0,%o2,%o0
 
90
 
 
91
L(largedivisor):
 
92
        and     %o2,1,%o5       C %o5 = n0 & 1
 
93
 
 
94
        srl     %o2,1,%o2
 
95
        sll     %o1,31,%g2
 
96
        or      %g2,%o2,%o2     C %o2 = lo(n1n0 >> 1)
 
97
        srl     %o1,1,%o1       C %o1 = hi(n1n0 >> 1)
 
98
 
 
99
        and     %o3,1,%g2
 
100
        srl     %o3,1,%g3       C %g3 = floor(d / 2)
 
101
        add     %g3,%g2,%g3     C %g3 = ceil(d / 2)
 
102
 
 
103
        b       L(Lp1)
 
104
        addxcc  %o2,%o2,%o2
 
105
 
 
106
L(Lplop):
 
107
        bcc     L(Ln1)
 
108
        addxcc  %o2,%o2,%o2
 
109
L(Lp1): addx    %o1,%o1,%o1
 
110
        subcc   %o1,%g3,%o4
 
111
        bcc     L(Ln2)
 
112
        addxcc  %o2,%o2,%o2
 
113
L(Lp2): addx    %o1,%o1,%o1
 
114
        subcc   %o1,%g3,%o4
 
115
        bcc     L(Ln3)
 
116
        addxcc  %o2,%o2,%o2
 
117
L(Lp3): addx    %o1,%o1,%o1
 
118
        subcc   %o1,%g3,%o4
 
119
        bcc     L(Ln4)
 
120
        addxcc  %o2,%o2,%o2
 
121
L(Lp4): addx    %o1,%o1,%o1
 
122
        addcc   %g1,-1,%g1
 
123
        bne     L(Lplop)
 
124
        subcc   %o1,%g3,%o4
 
125
        bcc     L(Ln5)
 
126
        addxcc  %o2,%o2,%o2
 
127
L(Lp5): add     %o1,%o1,%o1     C << 1
 
128
        tst     %g2
 
129
        bne     L(oddp)
 
130
        add     %o5,%o1,%o1
 
131
        st      %o1,[%o0]
 
132
        retl
 
133
        xnor    %g0,%o2,%o0
 
134
 
 
135
L(Lnlop):
 
136
        bcc     L(Lp1)
 
137
        addxcc  %o2,%o2,%o2
 
138
L(Ln1): addx    %o4,%o4,%o4
 
139
        subcc   %o4,%g3,%o1
 
140
        bcc     L(Lp2)
 
141
        addxcc  %o2,%o2,%o2
 
142
L(Ln2): addx    %o4,%o4,%o4
 
143
        subcc   %o4,%g3,%o1
 
144
        bcc     L(Lp3)
 
145
        addxcc  %o2,%o2,%o2
 
146
L(Ln3): addx    %o4,%o4,%o4
 
147
        subcc   %o4,%g3,%o1
 
148
        bcc     L(Lp4)
 
149
        addxcc  %o2,%o2,%o2
 
150
L(Ln4): addx    %o4,%o4,%o4
 
151
        addcc   %g1,-1,%g1
 
152
        bne     L(Lnlop)
 
153
        subcc   %o4,%g3,%o1
 
154
        bcc     L(Lp5)
 
155
        addxcc  %o2,%o2,%o2
 
156
L(Ln5): add     %o4,%o4,%o4     C << 1
 
157
        tst     %g2
 
158
        bne     L(oddn)
 
159
        add     %o5,%o4,%o4
 
160
        st      %o4,[%o0]
 
161
        retl
 
162
        xnor    %g0,%o2,%o0
 
163
 
 
164
L(oddp):
 
165
        xnor    %g0,%o2,%o2
 
166
        C q' in %o2. r' in %o1
 
167
        addcc   %o1,%o2,%o1
 
168
        bcc     L(Lp6)
 
169
        addx    %o2,0,%o2
 
170
        sub     %o1,%o3,%o1
 
171
L(Lp6): subcc   %o1,%o3,%g0
 
172
        bcs     L(Lp7)
 
173
        subx    %o2,-1,%o2
 
174
        sub     %o1,%o3,%o1
 
175
L(Lp7): st      %o1,[%o0]
 
176
        retl
 
177
        mov     %o2,%o0
 
178
 
 
179
L(oddn):
 
180
        xnor    %g0,%o2,%o2
 
181
        C q' in %o2. r' in %o4
 
182
        addcc   %o4,%o2,%o4
 
183
        bcc     L(Ln6)
 
184
        addx    %o2,0,%o2
 
185
        sub     %o4,%o3,%o4
 
186
L(Ln6): subcc   %o4,%o3,%g0
 
187
        bcs     L(Ln7)
 
188
        subx    %o2,-1,%o2
 
189
        sub     %o4,%o3,%o4
 
190
L(Ln7): st      %o4,[%o0]
 
191
        retl
 
192
        mov     %o2,%o0
 
193
EPILOGUE(mpn_udiv_qrnnd)