1
/* SPARC v7 __udiv_qrnnd division support, used from longlong.h.
2
* This is for v7 CPUs without a floating-point unit.
4
* Copyright (C) 1993, 1994, 1996, 1998,
5
* 2001, 2002 Free Software Foundation, Inc.
7
* This file is part of Libgcrypt.
9
* Libgcrypt is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU Lesser General Public License as
11
* published by the Free Software Foundation; either version 2.1 of
12
* the License, or (at your option) any later version.
14
* Libgcrypt 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 Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
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.
41
.global C_SYMBOL_NAME(__udiv_qrnnd)
42
C_SYMBOL_NAME(__udiv_qrnnd):
99
and %o2,1,%o5 ! %o5 = n0 & 1
103
or %g2,%o2,%o2 ! %o2 = lo(n1n0 >> 1)
104
srl %o1,1,%o1 ! %o1 = hi(n1n0 >> 1)
107
srl %o3,1,%g3 ! %g3 = floor(d / 2)
108
add %g3,%g2,%g3 ! %g3 = ceil(d / 2)
115
LLp1: addx %o1,%o1,%o1
119
LLp2: addx %o1,%o1,%o1
123
LLp3: addx %o1,%o1,%o1
127
LLp4: addx %o1,%o1,%o1
133
LLp5: add %o1,%o1,%o1 ! << 1
143
LLn1: addx %o4,%o4,%o4
147
LLn2: addx %o4,%o4,%o4
151
LLn3: addx %o4,%o4,%o4
155
LLn4: addx %o4,%o4,%o4
161
LLn5: add %o4,%o4,%o4 ! << 1
169
Oddp: xnor %g0,%o2,%o2
170
! q' in %o2. r' in %o1
175
LLp6: subcc %o1,%o3,%g0
183
Oddn: xnor %g0,%o2,%o2
184
! q' in %o2. r' in %o4
189
LLn6: subcc %o4,%o3,%g0