]>
Commit | Line | Data |
---|---|---|
a92599ea | 1 | /* Compute the hypothenuse of X and Y. |
f7a9f785 | 2 | Copyright (C) 1998-2016 Free Software Foundation, Inc. |
a92599ea UD |
3 | This file is part of the GNU C Library. |
4 | Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. | |
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. | |
a92599ea 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. |
a92599ea | 15 | |
41bdb6e2 | 16 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
17 | License along with the GNU C Library; if not, see |
18 | <http://www.gnu.org/licenses/>. */ | |
a92599ea UD |
19 | |
20 | #include <sysdep.h> | |
6f0f237b | 21 | #include <i386-math-asm.h> |
a92599ea | 22 | |
f6987f5a JM |
23 | DEFINE_DBL_MIN |
24 | ||
25 | #ifdef PIC | |
26 | # define MO(op) op##@GOTOFF(%edx) | |
27 | #else | |
28 | # define MO(op) op | |
29 | #endif | |
30 | ||
a92599ea UD |
31 | .text |
32 | ENTRY(__ieee754_hypot) | |
f6987f5a JM |
33 | #ifdef PIC |
34 | LOAD_PIC_REG (dx) | |
35 | #endif | |
a92599ea UD |
36 | fldl 4(%esp) // x |
37 | fxam | |
38 | fnstsw | |
39 | fldl 12(%esp) // y : x | |
40 | movb %ah, %ch | |
41 | fxam | |
42 | fnstsw | |
43 | movb %ah, %al | |
44 | orb %ch, %ah | |
45 | sahf | |
46 | jc 1f | |
47 | fmul %st(0) // y * y : x | |
48 | fxch // x : y * y | |
49 | fmul %st(0) // x * x : y * y | |
50 | faddp // x * x + y * y | |
51 | fsqrt | |
f6987f5a | 52 | DBL_NARROW_EVAL_UFLOW_NONNEG |
a92599ea UD |
53 | 2: ret |
54 | ||
55 | // We have to test whether any of the parameters is Inf. | |
56 | // In this case the result is infinity. | |
57 | 1: andb $0x45, %al | |
58 | cmpb $5, %al | |
59 | je 3f // jump if y is Inf | |
60 | andb $0x45, %ch | |
61 | cmpb $5, %ch | |
62 | jne 4f // jump if x is not Inf | |
63 | fxch | |
64 | 3: fstp %st(1) | |
65 | fabs | |
66 | jmp 2b | |
67 | ||
68 | 4: testb $1, %al | |
69 | jnz 5f // y is NaN | |
70 | fxch | |
71 | 5: fstp %st(1) | |
72 | jmp 2b | |
0ac5ae23 | 73 | |
a92599ea | 74 | END(__ieee754_hypot) |
0ac5ae23 | 75 | strong_alias (__ieee754_hypot, __hypot_finite) |