]>
Commit | Line | Data |
---|---|---|
26dee9c4 | 1 | /* ix87 specific frexp implementation for long double. |
2b778ceb | 2 | Copyright (C) 1997-2021 Free Software Foundation, Inc. |
26dee9c4 UD |
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 | |
41bdb6e2 AJ |
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. | |
26dee9c4 UD |
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 | |
41bdb6e2 | 14 | Lesser General Public License for more details. |
26dee9c4 | 15 | |
41bdb6e2 | 16 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 17 | License along with the GNU C Library; if not, see |
5a82c748 | 18 | <https://www.gnu.org/licenses/>. */ |
26dee9c4 | 19 | |
2ce30701 | 20 | #include <libm-alias-ldouble.h> |
26dee9c4 UD |
21 | #include <machine/asm.h> |
22 | ||
26dee9c4 | 23 | .section .rodata |
26dee9c4 UD |
24 | |
25 | .align ALIGNARG(4) | |
b67e9372 | 26 | .type two64,@object |
26dee9c4 UD |
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 | ||
2366713d | 36 | #define PARMS 4 /* no space for saved regs */ |
9e25f6e2 GM |
37 | #define VAL0 PARMS |
38 | #define VAL1 VAL0+4 | |
39 | #define VAL2 VAL1+4 | |
40 | #define EXPP VAL2+4 | |
41 | ||
26dee9c4 | 42 | .text |
2366713d | 43 | ENTRY (__frexpl) |
9e25f6e2 GM |
44 | |
45 | movl VAL0(%esp), %ecx | |
46 | movl VAL2(%esp), %eax | |
47 | orl VAL1(%esp), %ecx | |
26dee9c4 UD |
48 | movl %eax, %edx |
49 | andl $0x7fff, %eax | |
50 | orl %eax, %ecx | |
51 | jz 1f | |
52 | xorl %ecx, %ecx | |
53 | cmpl $0x7fff, %eax | |
88283451 | 54 | je 3f |
26dee9c4 UD |
55 | |
56 | cmpl $0, %eax | |
601d2942 | 57 | jne 2f |
79569444 | 58 | |
9e25f6e2 | 59 | fldt VAL0(%esp) |
26dee9c4 | 60 | #ifdef PIC |
fee732e5 | 61 | LOAD_PIC_REG (dx) |
26dee9c4 | 62 | #endif |
79569444 | 63 | |
26dee9c4 UD |
64 | fmull MO(two64) /* It's not necessary to use a 80bit factor */ |
65 | movl $-64, %ecx | |
9e25f6e2 | 66 | fstpt VAL0(%esp) |
00f5fcbb | 67 | fwait |
9e25f6e2 | 68 | movl VAL2(%esp), %eax |
26dee9c4 UD |
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 | |
9e25f6e2 | 76 | movl %edx, VAL2(%esp) |
26dee9c4 UD |
77 | |
78 | /* Store %ecx in the variable pointed to by the second argument, | |
79 | get the factor from the stack and return. */ | |
9e25f6e2 | 80 | 1: movl EXPP(%esp), %eax |
9e25f6e2 | 81 | fldt VAL0(%esp) |
26dee9c4 | 82 | movl %ecx, (%eax) |
9e25f6e2 | 83 | |
26dee9c4 | 84 | ret |
88283451 JM |
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 | |
2366713d | 92 | END (__frexpl) |
2ce30701 | 93 | libm_alias_ldouble (__frexp, frexp) |