~ubuntu-branches/ubuntu/karmic/gnupg2/karmic-updates

« back to all changes in this revision

Viewing changes to mpi/sparc32/udiv.S

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Urlichs
  • Date: 2006-01-24 04:31:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060124043142-pbg192or6qxv3yk2
Tags: 1.9.20-1
* New Upstream version. Closes:#306890,#344530
  * Closes:#320490: gpg-protect-tool fails to decrypt PKCS-12 files 
* Depend on libopensc2-dev, not -1-. Closes:#348106

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* SPARC v7 __udiv_qrnnd division support, used from longlong.h.
 
2
 *           This is for v7 CPUs without a floating-point unit.
 
3
 *
 
4
 *      Copyright (C) 1993, 1994, 1996, 1998,
 
5
 *                    2001 Free Software Foundation, Inc.
 
6
 *       
 
7
 * This file is part of GnuPG.
 
8
 *
 
9
 * GnuPG 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
 * GnuPG 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
! INPUT PARAMETERS
 
34
! rem_ptr       o0
 
35
! n1            o1
 
36
! n0            o2
 
37
! d             o3
 
38
 
 
39
#include "sysdep.h"
 
40
 
 
41
        .text
 
42
        .align 4
 
43
        .global C_SYMBOL_NAME(__udiv_qrnnd)
 
44
C_SYMBOL_NAME(__udiv_qrnnd):
 
45
        tst     %o3
 
46
        bneg    Largedivisor
 
47
        mov     8,%g1
 
48
 
 
49
        b       Lp1
 
50
        addxcc  %o2,%o2,%o2
 
51
 
 
52
Lplop:  bcc     Ln1
 
53
        addxcc  %o2,%o2,%o2
 
54
Lp1:    addx    %o1,%o1,%o1
 
55
        subcc   %o1,%o3,%o4
 
56
        bcc     Ln2
 
57
        addxcc  %o2,%o2,%o2
 
58
Lp2:    addx    %o1,%o1,%o1
 
59
        subcc   %o1,%o3,%o4
 
60
        bcc     Ln3
 
61
        addxcc  %o2,%o2,%o2
 
62
Lp3:    addx    %o1,%o1,%o1
 
63
        subcc   %o1,%o3,%o4
 
64
        bcc     Ln4
 
65
        addxcc  %o2,%o2,%o2
 
66
Lp4:    addx    %o1,%o1,%o1
 
67
        addcc   %g1,-1,%g1
 
68
        bne     Lplop
 
69
        subcc   %o1,%o3,%o4
 
70
        bcc     Ln5
 
71
        addxcc  %o2,%o2,%o2
 
72
Lp5:    st      %o1,[%o0]
 
73
        retl
 
74
        xnor    %g0,%o2,%o0
 
75
 
 
76
Lnlop:  bcc     Lp1
 
77
        addxcc  %o2,%o2,%o2
 
78
Ln1:    addx    %o4,%o4,%o4
 
79
        subcc   %o4,%o3,%o1
 
80
        bcc     Lp2
 
81
        addxcc  %o2,%o2,%o2
 
82
Ln2:    addx    %o4,%o4,%o4
 
83
        subcc   %o4,%o3,%o1
 
84
        bcc     Lp3
 
85
        addxcc  %o2,%o2,%o2
 
86
Ln3:    addx    %o4,%o4,%o4
 
87
        subcc   %o4,%o3,%o1
 
88
        bcc     Lp4
 
89
        addxcc  %o2,%o2,%o2
 
90
Ln4:    addx    %o4,%o4,%o4
 
91
        addcc   %g1,-1,%g1
 
92
        bne     Lnlop
 
93
        subcc   %o4,%o3,%o1
 
94
        bcc     Lp5
 
95
        addxcc  %o2,%o2,%o2
 
96
Ln5:    st      %o4,[%o0]
 
97
        retl
 
98
        xnor    %g0,%o2,%o0
 
99
 
 
100
Largedivisor:
 
101
        and     %o2,1,%o5       ! %o5 = n0 & 1
 
102
 
 
103
        srl     %o2,1,%o2
 
104
        sll     %o1,31,%g2
 
105
        or      %g2,%o2,%o2     ! %o2 = lo(n1n0 >> 1)
 
106
        srl     %o1,1,%o1       ! %o1 = hi(n1n0 >> 1)
 
107
 
 
108
        and     %o3,1,%g2
 
109
        srl     %o3,1,%g3       ! %g3 = floor(d / 2)
 
110
        add     %g3,%g2,%g3     ! %g3 = ceil(d / 2)
 
111
 
 
112
        b       LLp1
 
113
        addxcc  %o2,%o2,%o2
 
114
 
 
115
LLplop: bcc     LLn1
 
116
        addxcc  %o2,%o2,%o2
 
117
LLp1:   addx    %o1,%o1,%o1
 
118
        subcc   %o1,%g3,%o4
 
119
        bcc     LLn2
 
120
        addxcc  %o2,%o2,%o2
 
121
LLp2:   addx    %o1,%o1,%o1
 
122
        subcc   %o1,%g3,%o4
 
123
        bcc     LLn3
 
124
        addxcc  %o2,%o2,%o2
 
125
LLp3:   addx    %o1,%o1,%o1
 
126
        subcc   %o1,%g3,%o4
 
127
        bcc     LLn4
 
128
        addxcc  %o2,%o2,%o2
 
129
LLp4:   addx    %o1,%o1,%o1
 
130
        addcc   %g1,-1,%g1
 
131
        bne     LLplop
 
132
        subcc   %o1,%g3,%o4
 
133
        bcc     LLn5
 
134
        addxcc  %o2,%o2,%o2
 
135
LLp5:   add     %o1,%o1,%o1     ! << 1
 
136
        tst     %g2
 
137
        bne     Oddp
 
138
        add     %o5,%o1,%o1
 
139
        st      %o1,[%o0]
 
140
        retl
 
141
        xnor    %g0,%o2,%o0
 
142
 
 
143
LLnlop: bcc     LLp1
 
144
        addxcc  %o2,%o2,%o2
 
145
LLn1:   addx    %o4,%o4,%o4
 
146
        subcc   %o4,%g3,%o1
 
147
        bcc     LLp2
 
148
        addxcc  %o2,%o2,%o2
 
149
LLn2:   addx    %o4,%o4,%o4
 
150
        subcc   %o4,%g3,%o1
 
151
        bcc     LLp3
 
152
        addxcc  %o2,%o2,%o2
 
153
LLn3:   addx    %o4,%o4,%o4
 
154
        subcc   %o4,%g3,%o1
 
155
        bcc     LLp4
 
156
        addxcc  %o2,%o2,%o2
 
157
LLn4:   addx    %o4,%o4,%o4
 
158
        addcc   %g1,-1,%g1
 
159
        bne     LLnlop
 
160
        subcc   %o4,%g3,%o1
 
161
        bcc     LLp5
 
162
        addxcc  %o2,%o2,%o2
 
163
LLn5:   add     %o4,%o4,%o4     ! << 1
 
164
        tst     %g2
 
165
        bne     Oddn
 
166
        add     %o5,%o4,%o4
 
167
        st      %o4,[%o0]
 
168
        retl
 
169
        xnor    %g0,%o2,%o0
 
170
 
 
171
Oddp:   xnor    %g0,%o2,%o2
 
172
        ! q' in %o2. r' in %o1
 
173
        addcc   %o1,%o2,%o1
 
174
        bcc     LLp6
 
175
        addx    %o2,0,%o2
 
176
        sub     %o1,%o3,%o1
 
177
LLp6:   subcc   %o1,%o3,%g0
 
178
        bcs     LLp7
 
179
        subx    %o2,-1,%o2
 
180
        sub     %o1,%o3,%o1
 
181
LLp7:   st      %o1,[%o0]
 
182
        retl
 
183
        mov     %o2,%o0
 
184
 
 
185
Oddn:   xnor    %g0,%o2,%o2
 
186
        ! q' in %o2. r' in %o4
 
187
        addcc   %o4,%o2,%o4
 
188
        bcc     LLn6
 
189
        addx    %o2,0,%o2
 
190
        sub     %o4,%o3,%o4
 
191
LLn6:   subcc   %o4,%o3,%g0
 
192
        bcs     LLn7
 
193
        subx    %o2,-1,%o2
 
194
        sub     %o4,%o3,%o4
 
195
LLn7:   st      %o4,[%o0]
 
196
        retl
 
197
        mov     %o2,%o0