]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/i386/fpu/s_frexpl.S
ff455314eebe38b341891ac6bedca233a0aca10b
[thirdparty/glibc.git] / sysdeps / i386 / fpu / s_frexpl.S
1 /* ix87 specific frexp implementation for long double.
2 Copyright (C) 1997-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20 #include <libm-alias-ldouble.h>
21 #include <machine/asm.h>
22
23 .section .rodata
24
25 .align ALIGNARG(4)
26 .type two64,@object
27 two64: .byte 0, 0, 0, 0, 0, 0, 0xf0, 0x43
28 ASM_SIZE_DIRECTIVE(two64)
29
30 #ifdef PIC
31 #define MO(op) op##@GOTOFF(%edx)
32 #else
33 #define MO(op) op
34 #endif
35
36 #define PARMS 4 /* no space for saved regs */
37 #define VAL0 PARMS
38 #define VAL1 VAL0+4
39 #define VAL2 VAL1+4
40 #define EXPP VAL2+4
41
42 .text
43 ENTRY (__frexpl)
44
45 movl VAL0(%esp), %ecx
46 movl VAL2(%esp), %eax
47 orl VAL1(%esp), %ecx
48 movl %eax, %edx
49 andl $0x7fff, %eax
50 orl %eax, %ecx
51 jz 1f
52 xorl %ecx, %ecx
53 cmpl $0x7fff, %eax
54 je 3f
55
56 cmpl $0, %eax
57 jne 2f
58
59 fldt VAL0(%esp)
60 #ifdef PIC
61 LOAD_PIC_REG (dx)
62 #endif
63
64 fmull MO(two64) /* It's not necessary to use a 80bit factor */
65 movl $-64, %ecx
66 fstpt VAL0(%esp)
67 fwait
68 movl VAL2(%esp), %eax
69 movl %eax, %edx
70 andl $0x7fff, %eax
71
72 2: andl $0x8000, %edx
73 subl $16382, %eax
74 orl $0x3ffe, %edx
75 addl %eax, %ecx
76 movl %edx, VAL2(%esp)
77
78 /* Store %ecx in the variable pointed to by the second argument,
79 get the factor from the stack and return. */
80 1: movl EXPP(%esp), %eax
81 fldt VAL0(%esp)
82 movl %ecx, (%eax)
83
84 ret
85
86 /* Infinity or NaN; ensure signaling NaNs are quieted. */
87 3: movl EXPP(%esp), %eax
88 fldt VAL0(%esp)
89 fadd %st
90 movl %ecx, (%eax)
91 ret
92 END (__frexpl)
93 libm_alias_ldouble (__frexp, frexp)