2.9
[glibc/nacl-glibc.git] / sysdeps / alpha / div.S
blobd1a724d3758997ed800f995fba5ddf2ae82e148e
1 /* Copyright (C) 1996, 1997, 2004 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Richard Henderson <rth@tamu.edu>.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
20 #include "div_libc.h"
22 #undef FRAME
23 #ifdef __alpha_fix__
24 #define FRAME 0
25 #else
26 #define FRAME 16
27 #endif
29         .set noat
31         .align 4
32         .globl div
33         .ent div
34 div:
35         .frame sp, FRAME, ra
36 #if FRAME > 0
37         lda     sp, -FRAME(sp)
38 #endif
39 #ifdef PROF
40         .set    macro
41         ldgp    gp, 0(pv)
42         lda     AT, _mcount
43         jsr     AT, (AT), _mcount
44         .set    nomacro
45         .prologue 1
46 #else
47         .prologue 0
48 #endif
50         beq     $18, $divbyzero
51         excb
52         mf_fpcr $f10
54         _ITOFT2 $17, $f0, 0, $18, $f1, 8
56         cvtqt   $f0, $f0
57         cvtqt   $f1, $f1
58         divt/c  $f0, $f1, $f0
59         cvttq/c $f0, $f0
60         excb
61         mt_fpcr $f10
62         _FTOIT  $f0, $0, 0
64         mull    $0, $18, $1
65         subl    $17, $1, $1
67         stl     $0, 0(a0)
68         stl     $1, 4(a0)
69         mov     a0, v0
71 #if FRAME > 0
72         lda     sp, FRAME(sp)
73 #endif
74         ret
76 $divbyzero:
77         mov     a0, v0
78         lda     a0, GEN_INTDIV
79         call_pal PAL_gentrap
80         stl     zero, 0(v0)
81         stl     zero, 4(v0)
83 #if FRAME > 0
84         lda     sp, FRAME(sp)
85 #endif
86         ret
88         .end div