bf7dc70cd7ce0df55b6863fa6810087abaa13033
[ghc-hetmet.git] / ghc / rts / gmp / mpn / hppa / hppa1_1 / udiv_qrnnd.s
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 Free Software Foundation, Inc.
5
6 ; This file is part of the GNU MP Library.
7
8 ; The GNU MP Library is free software; you can redistribute it and/or modify
9 ; it under the terms of the GNU Library General Public License as published by
10 ; the Free Software Foundation; either version 2 of the License, or (at your
11 ; option) any later version.
12
13 ; The GNU MP Library is distributed in the hope that it will be useful, but
14 ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
16 ; License for more details.
17
18 ; You should have received a copy of the GNU Library General Public License
19 ; along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
20 ; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 ; MA 02111-1307, USA.
22
23
24 ; INPUT PARAMETERS
25 ; rem_ptr       gr26
26 ; n1            gr25
27 ; n0            gr24
28 ; d             gr23
29
30         .code
31 L$0000  .word           0x43f00000
32         .word           0x0
33         .export         __udiv_qrnnd
34 __udiv_qrnnd
35         .proc
36         .callinfo       frame=64,no_calls
37         .entry
38         ldo             64(%r30),%r30
39
40         stws            %r25,-16(0,%r30)        ; n_hi
41         stws            %r24,-12(0,%r30)        ; n_lo
42         ldil            L'L$0000,%r19
43         ldo             R'L$0000(%r19),%r19
44         fldds           -16(0,%r30),%fr5
45         stws            %r23,-12(0,%r30)
46         comib,<=        0,%r25,L$1
47         fcnvxf,dbl,dbl  %fr5,%fr5
48         fldds           0(0,%r19),%fr4
49         fadd,dbl        %fr4,%fr5,%fr5
50 L$1
51         fcpy,sgl        %fr0,%fr6L
52         fldws           -12(0,%r30),%fr6R
53         fcnvxf,dbl,dbl  %fr6,%fr4
54
55         fdiv,dbl        %fr5,%fr4,%fr5
56
57         fcnvfx,dbl,dbl  %fr5,%fr4
58         fstws           %fr4R,-16(%r30)
59         xmpyu           %fr4R,%fr6R,%fr6
60         ldws            -16(%r30),%r28
61         fstds           %fr6,-16(0,%r30)
62         ldws            -12(0,%r30),%r21
63         ldws            -16(0,%r30),%r20
64         sub             %r24,%r21,%r22
65         subb            %r25,%r20,%r19
66         comib,=         0,%r19,L$2
67         ldo             -64(%r30),%r30
68
69         add             %r22,%r23,%r22
70         ldo             -1(%r28),%r28
71 L$2     bv              0(%r2)
72         stws            %r22,0(0,%r26)
73
74         .exit
75         .procend