Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / i386 / fpu / e_hypot.S
blob36290b0b45e27437ba7f4f13524d9b4f97f90f88
1 /* Compute the hypothenuse of X and Y.
2    Copyright (C) 1998-2014 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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 <sysdep.h>
22         .text
23 ENTRY(__ieee754_hypot)
24         fldl    4(%esp)         // x
25         fxam
26         fnstsw
27         fldl    12(%esp)        // y : x
28         movb    %ah, %ch
29         fxam
30         fnstsw
31         movb    %ah, %al
32         orb     %ch, %ah
33         sahf
34         jc      1f
35         fmul    %st(0)          // y * y : x
36         fxch                    // x : y * y
37         fmul    %st(0)          // x * x : y * y
38         faddp                   // x * x + y * y
39         fsqrt
40 2:      ret
42         // We have to test whether any of the parameters is Inf.
43         // In this case the result is infinity.
44 1:      andb    $0x45, %al
45         cmpb    $5, %al
46         je      3f              // jump if y is Inf
47         andb    $0x45, %ch
48         cmpb    $5, %ch
49         jne     4f              // jump if x is not Inf
50         fxch
51 3:      fstp    %st(1)
52         fabs
53         jmp     2b
55 4:      testb   $1, %al
56         jnz     5f              // y is NaN
57         fxch
58 5:      fstp    %st(1)
59         jmp     2b
61 END(__ieee754_hypot)
62 strong_alias (__ieee754_hypot, __hypot_finite)