Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / i386 / fpu / s_frexpl.S
blob6c8e9c09b78bafa35563bf9d38a3fd55c41ab870
1 /* ix87 specific frexp implementation for long double.
2    Copyright (C) 1997-2015 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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.
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.
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/>.  */
20 #include <machine/asm.h>
22         .section .rodata
24         .align ALIGNARG(4)
25         .type two64,@object
26 two64:  .byte 0, 0, 0, 0, 0, 0, 0xf0, 0x43
27         ASM_SIZE_DIRECTIVE(two64)
29 #ifdef PIC
30 #define MO(op) op##@GOTOFF(%edx)
31 #else
32 #define MO(op) op
33 #endif
35 #define PARMS   4               /* no space for saved regs */
36 #define VAL0    PARMS
37 #define VAL1    VAL0+4
38 #define VAL2    VAL1+4
39 #define EXPP    VAL2+4
41         .text
42 ENTRY (__frexpl)
44         movl    VAL0(%esp), %ecx
45         movl    VAL2(%esp), %eax
46         orl     VAL1(%esp), %ecx
47         movl    %eax, %edx
48         andl    $0x7fff, %eax
49         orl     %eax, %ecx
50         jz      1f
51         xorl    %ecx, %ecx
52         cmpl    $0x7fff, %eax
53         je      1f
55         cmpl    $0, %eax
56         jne     2f
58         fldt    VAL0(%esp)
59 #ifdef  PIC
60         LOAD_PIC_REG (dx)
61 #endif
63         fmull   MO(two64)       /* It's not necessary to use a 80bit factor */
64         movl    $-64, %ecx
65         fstpt   VAL0(%esp)
66         fwait
67         movl    VAL2(%esp), %eax
68         movl    %eax, %edx
69         andl    $0x7fff, %eax
71 2:      andl    $0x8000, %edx
72         subl    $16382, %eax
73         orl     $0x3ffe, %edx
74         addl    %eax, %ecx
75         movl    %edx, VAL2(%esp)
77         /* Store %ecx in the variable pointed to by the second argument,
78            get the factor from the stack and return.  */
79 1:      movl    EXPP(%esp), %eax
80         fldt    VAL0(%esp)
81         movl    %ecx, (%eax)
83         ret
84 END (__frexpl)
85 weak_alias (__frexpl, frexpl)