| 1 |
/* HP-PA __udiv_qrnnd division support, used from longlong.h. |
| 2 |
* This version runs fast on PA 7000 and later. |
| 3 |
* |
| 4 |
* Copyright (C) 1993, 1994, 1998, |
| 5 |
* 2001, 2002, 2004 Free Software Foundation, Inc. |
| 6 |
* |
| 7 |
* This file is part of Libgcrypt. |
| 8 |
* |
| 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. |
| 13 |
* |
| 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. |
| 18 |
* |
| 19 |
* You should have received a copy of the GNU Lesser General Public |
| 20 |
* License along with this program; if not, see <https://www.gnu.org/licenses/>. |
| 21 |
* SPDX-License-Identifier: LGPL-2.1-or-later |
| 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 |
*/ |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
/* INPUT PARAMETERS |
| 33 |
* rem_ptr gr26 |
| 34 |
* n1 gr25 |
| 35 |
* n0 gr24 |
| 36 |
* d gr23 |
| 37 |
*/ |
| 38 |
|
| 39 |
.level 1.1 |
| 40 |
|
| 41 |
.data |
| 42 |
.align 8 |
| 43 |
.label L$0000 |
| 44 |
.word 0x43f00000 |
| 45 |
.word 0x0 |
| 46 |
.code |
| 47 |
.export __udiv_qrnnd |
| 48 |
.label __udiv_qrnnd |
| 49 |
.proc |
| 50 |
.callinfo frame=64,no_calls |
| 51 |
.entry |
| 52 |
ldo 64(%r30),%r30 |
| 53 |
|
| 54 |
stws %r25,-16(0,%r30) ; n_hi |
| 55 |
stws %r24,-12(0,%r30) ; n_lo |
| 56 |
stw %r19,-32(%r30) |
| 57 |
addil LT%L$0000,%r19 |
| 58 |
ldw RT%L$0000(%r1),%r1 |
| 59 |
fldds -16(0,%r30),%fr5 |
| 60 |
stws %r23,-12(0,%r30) |
| 61 |
comib,<= 0,%r25,L$1 |
| 62 |
fcnvxf,dbl,dbl %fr5,%fr5 |
| 63 |
fldds 0(0,%r1),%fr4 |
| 64 |
fadd,dbl %fr4,%fr5,%fr5 |
| 65 |
.label L$1 |
| 66 |
fcpy,sgl %fr0,%fr6L |
| 67 |
fldws -12(0,%r30),%fr6R |
| 68 |
fcnvxf,dbl,dbl %fr6,%fr4 |
| 69 |
|
| 70 |
fdiv,dbl %fr5,%fr4,%fr5 |
| 71 |
|
| 72 |
fcnvfx,dbl,dbl %fr5,%fr4 |
| 73 |
fstws %fr4R,-16(%r30) |
| 74 |
xmpyu %fr4R,%fr6R,%fr6 |
| 75 |
ldws -16(%r30),%r28 |
| 76 |
fstds %fr6,-16(0,%r30) |
| 77 |
ldws -12(0,%r30),%r21 |
| 78 |
ldws -16(0,%r30),%r20 |
| 79 |
sub %r24,%r21,%r22 |
| 80 |
subb %r25,%r20,%r1 |
| 81 |
comib,= 0,%r1,L$2 |
| 82 |
ldo -64(%r30),%r30 |
| 83 |
|
| 84 |
add %r22,%r23,%r22 |
| 85 |
ldo -1(%r28),%r28 |
| 86 |
.label L$2 |
| 87 |
bv 0(%r2) |
| 88 |
stws %r22,0(0,%r26) |
| 89 |
|
| 90 |
.exit |
| 91 |
.procend |
| 92 |
|