1 // Copyright 2010 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include "textflag.h" 6 7 // func Exp2(x float64) float64 8 TEXT Exp2(SB),NOSPLIT,$0 9 // test bits for not-finite 10 MOVL x_hi+4(FP), AX 11 ANDL $0x7ff00000, AX 12 CMPL AX, $0x7ff00000 13 JEQ not_finite 14 FMOVD x+0(FP), F0 // F0=x 15 FMOVD F0, F1 // F0=x, F1=x 16 FRNDINT // F0=int(x), F1=x 17 FSUBD F0, F1 // F0=int(x), F1=x-int(x) 18 FXCHD F0, F1 // F0=x-int(x), F1=int(x) 19 F2XM1 // F0=2**(x-int(x))-1, F1=int(x) 20 FLD1 // F0=1, F1=2**(x-int(x))-1, F2=int(x) 21 FADDDP F0, F1 // F0=2**(x-int(x)), F1=int(x) 22 FSCALE // F0=2**x, F1=int(x) 23 FMOVDP F0, F1 // F0=2**x 24 FMOVDP F0, ret+8(FP) 25 RET 26 not_finite: 27 // test bits for -Inf 28 MOVL x_hi+4(FP), BX 29 MOVL x_lo+0(FP), CX 30 CMPL BX, $0xfff00000 31 JNE not_neginf 32 CMPL CX, $0 33 JNE not_neginf 34 MOVL $0, ret_lo+8(FP) 35 MOVL $0, ret_hi+12(FP) 36 RET 37 not_neginf: 38 MOVL CX, ret_lo+8(FP) 39 MOVL BX, ret_hi+12(FP) 40 RET 41