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