summaryrefslogtreecommitdiff
path: root/src/pkg/math/hypot_386.s
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/math/hypot_386.s')
-rw-r--r--src/pkg/math/hypot_386.s46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/pkg/math/hypot_386.s b/src/pkg/math/hypot_386.s
index 70ff19a17..51cd90419 100644
--- a/src/pkg/math/hypot_386.s
+++ b/src/pkg/math/hypot_386.s
@@ -2,35 +2,35 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// func Hypot(x, y float64) float64
+// func Hypot(p, q float64) float64
TEXT ·Hypot(SB),7,$0
// test bits for not-finite
- MOVL xh+4(FP), AX // high word x
+ MOVL p+4(FP), AX // high word p
ANDL $0x7ff00000, AX
CMPL AX, $0x7ff00000
JEQ not_finite
- MOVL yh+12(FP), AX // high word y
+ MOVL q+12(FP), AX // high word q
ANDL $0x7ff00000, AX
CMPL AX, $0x7ff00000
JEQ not_finite
- FMOVD x+0(FP), F0 // F0=x
- FABS // F0=|x|
- FMOVD y+8(FP), F0 // F0=y, F1=|x|
- FABS // F0=|y|, F1=|x|
+ FMOVD p+0(FP), F0 // F0=p
+ FABS // F0=|p|
+ FMOVD q+8(FP), F0 // F0=q, F1=|p|
+ FABS // F0=|q|, F1=|p|
FUCOMI F0, F1 // compare F0 to F1
JCC 2(PC) // jump if F0 >= F1
- FXCHD F0, F1 // F0=|x| (larger), F1=|y| (smaller)
+ FXCHD F0, F1 // F0=|p| (larger), F1=|q| (smaller)
FTST // compare F0 to 0
FSTSW AX
ANDW $0x4000, AX
JNE 10(PC) // jump if F0 = 0
- FXCHD F0, F1 // F0=y (smaller), F1=x (larger)
- FDIVD F1, F0 // F0=y(=y/x), F1=x
- FMULD F0, F0 // F0=y*y, F1=x
- FLD1 // F0=1, F1=y*y, F2=x
- FADDDP F0, F1 // F0=1+y*y, F1=x
- FSQRT // F0=sqrt(1+y*y), F1=x
- FMULDP F0, F1 // F0=x*sqrt(1+y*y)
+ FXCHD F0, F1 // F0=q (smaller), F1=p (larger)
+ FDIVD F1, F0 // F0=q(=q/p), F1=p
+ FMULD F0, F0 // F0=q*q, F1=p
+ FLD1 // F0=1, F1=q*q, F2=p
+ FADDDP F0, F1 // F0=1+q*q, F1=p
+ FSQRT // F0=sqrt(1+q*q), F1=p
+ FMULDP F0, F1 // F0=p*sqrt(1+q*q)
FMOVDP F0, r+16(FP)
RET
FMOVDP F0, F1 // F0=0
@@ -38,20 +38,20 @@ TEXT ·Hypot(SB),7,$0
RET
not_finite:
// test bits for -Inf or +Inf
- MOVL xh+4(FP), AX // high word x
- ORL xl+0(FP), AX // low word x
+ MOVL p+4(FP), AX // high word p
+ ORL p+0(FP), AX // low word p
ANDL $0x7fffffff, AX
CMPL AX, $0x7ff00000
JEQ is_inf
- MOVL yh+12(FP), AX // high word y
- ORL yl+8(FP), AX // low word y
+ MOVL q+12(FP), AX // high word q
+ ORL q+8(FP), AX // low word q
ANDL $0x7fffffff, AX
CMPL AX, $0x7ff00000
JEQ is_inf
- MOVL $0x7ff00000, rh+20(FP) // return NaN = 0x7FF0000000000001
- MOVL $0x00000001, rl+16(FP)
+ MOVL $0x7ff80000, r+20(FP) // return NaN = 0x7FF8000000000001
+ MOVL $0x00000001, r+16(FP)
RET
is_inf:
- MOVL AX, rh+20(FP) // return +Inf = 0x7FF0000000000000
- MOVL $0x00000000, rl+16(FP)
+ MOVL AX, r+20(FP) // return +Inf = 0x7FF0000000000000
+ MOVL $0x00000000, r+16(FP)
RET