Home | History | Annotate | Download | only in math
      1 // Copyright 2009 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 Cos(x float64) float64
      8 TEXT Cos(SB),NOSPLIT,$0
      9 	FMOVD   x+0(FP), F0  // F0=x
     10 	FCOS                 // F0=cos(x) if -2**63 < x < 2**63
     11 	FSTSW   AX           // AX=status word
     12 	ANDW    $0x0400, AX
     13 	JNE     3(PC)        // jump if x outside range
     14 	FMOVDP  F0, ret+8(FP)
     15 	RET
     16 	FLDPI                // F0=Pi, F1=x
     17 	FADDD   F0, F0       // F0=2*Pi, F1=x
     18 	FXCHD   F0, F1       // F0=x, F1=2*Pi
     19 	FPREM1               // F0=reduced_x, F1=2*Pi
     20 	FSTSW   AX           // AX=status word
     21 	ANDW    $0x0400, AX
     22 	JNE     -3(PC)       // jump if reduction incomplete
     23 	FMOVDP  F0, F1       // F0=reduced_x
     24 	FCOS                 // F0=cos(reduced_x)
     25 	FMOVDP  F0, ret+8(FP)
     26 	RET
     27 
     28 // func Sin(x float64) float64
     29 TEXT Sin(SB),NOSPLIT,$0
     30 	FMOVD   x+0(FP), F0  // F0=x
     31 	FSIN                 // F0=sin(x) if -2**63 < x < 2**63
     32 	FSTSW   AX           // AX=status word
     33 	ANDW    $0x0400, AX
     34 	JNE     3(PC)        // jump if x outside range
     35 	FMOVDP  F0, ret+8(FP)
     36 	RET
     37 	FLDPI                // F0=Pi, F1=x
     38 	FADDD   F0, F0       // F0=2*Pi, F1=x
     39 	FXCHD   F0, F1       // F0=x, F1=2*Pi
     40 	FPREM1               // F0=reduced_x, F1=2*Pi
     41 	FSTSW   AX           // AX=status word
     42 	ANDW    $0x0400, AX
     43 	JNE     -3(PC)       // jump if reduction incomplete
     44 	FMOVDP  F0, F1       // F0=reduced_x
     45 	FSIN                 // F0=sin(reduced_x)
     46 	FMOVDP  F0, ret+8(FP)
     47 	RET
     48