codekingpro/portable-devtools
114k
1// Copyright 2010 The Go Authors. All rights reserved.2// Use of this source code is governed by a BSD-style3// license that can be found in the LICENSE file.4 5#include "textflag.h"6 7// func archHypot(p, q float64) float648TEXT ·archHypot(SB),NOSPLIT,$09// test bits for not-finite10 MOVL p_hi+4(FP), AX // high word p11 ANDL $0x7ff00000, AX12 CMPL AX, $0x7ff0000013 JEQ not_finite14 MOVL q_hi+12(FP), AX // high word q15 ANDL $0x7ff00000, AX16 CMPL AX, $0x7ff0000017 JEQ not_finite18 FMOVD p+0(FP), F0 // F0=p19 FABS // F0=|p|20 FMOVD q+8(FP), F0 // F0=q, F1=|p|21 FABS // F0=|q|, F1=|p|22 FUCOMI F0, F1 // compare F0 to F123 JCC 2(PC) // jump if F0 >= F124 FXCHD F0, F1 // F0=|p| (larger), F1=|q| (smaller)25 FTST // compare F0 to 026 FSTSW AX27 ANDW $0x4000, AX28 JNE 10(PC) // jump if F0 = 029 FXCHD F0, F1 // F0=q (smaller), F1=p (larger)30 FDIVD F1, F0 // F0=q(=q/p), F1=p31 FMULD F0, F0 // F0=q*q, F1=p32 FLD1 // F0=1, F1=q*q, F2=p33 FADDDP F0, F1 // F0=1+q*q, F1=p34 FSQRT // F0=sqrt(1+q*q), F1=p35 FMULDP F0, F1 // F0=p*sqrt(1+q*q)36 FMOVDP F0, ret+16(FP)37 RET38 FMOVDP F0, F1 // F0=039 FMOVDP F0, ret+16(FP)40 RET41not_finite:42// test bits for -Inf or +Inf43 MOVL p_hi+4(FP), AX // high word p44 ORL p_lo+0(FP), AX // low word p45 ANDL $0x7fffffff, AX46 CMPL AX, $0x7ff0000047 JEQ is_inf48 MOVL q_hi+12(FP), AX // high word q49 ORL q_lo+8(FP), AX // low word q50 ANDL $0x7fffffff, AX51 CMPL AX, $0x7ff0000052 JEQ is_inf53 MOVL $0x7ff80000, ret_hi+20(FP) // return NaN = 0x7FF800000000000154 MOVL $0x00000001, ret_lo+16(FP)55 RET56is_inf:57 MOVL AX, ret_hi+20(FP) // return +Inf = 0x7FF000000000000058 MOVL $0x00000000, ret_lo+16(FP)59 RET60 