blob: f1bdae1536bfb5b275deb2008287ebad254f24b3 [file] [log] [blame]
Charles L. Dorian7f11db52010-01-15 13:21:36 -08001// 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
Rob Pike8bca1482014-08-12 17:04:45 -07005#include "textflag.h"
Keith Randall1f796632013-08-12 10:25:18 -07006
Charles L. Dorian7f11db52010-01-15 13:21:36 -08007// func Tan(x float64) float64
Keith Randall1f796632013-08-12 10:25:18 -07008TEXT ·Tan(SB),NOSPLIT,$0
Charles L. Dorian7f11db52010-01-15 13:21:36 -08009 FMOVD x+0(FP), F0 // F0=x
10 FPTAN // F0=1, F1=tan(x) if -2**63 < x < 2**63
11 FSTSW AX // AX=status word
12 ANDW $0x0400, AX
13 JNE 4(PC) // jump if x outside range
14 FMOVDP F0, F0 // F0=tan(x)
Russ Cox07720b62013-03-22 12:57:55 -040015 FMOVDP F0, ret+8(FP)
Charles L. Dorian7f11db52010-01-15 13:21:36 -080016 RET
17 FLDPI // F0=Pi, F1=x
18 FADDD F0, F0 // F0=2*Pi, F1=x
19 FXCHD F0, F1 // F0=x, F1=2*Pi
20 FPREM1 // F0=reduced_x, F1=2*Pi
21 FSTSW AX // AX=status word
22 ANDW $0x0400, AX
23 JNE -3(PC) // jump if reduction incomplete
24 FMOVDP F0, F1 // F0=reduced_x
25 FPTAN // F0=1, F1=tan(reduced_x)
26 FMOVDP F0, F0 // F0=tan(reduced_x)
Russ Cox07720b62013-03-22 12:57:55 -040027 FMOVDP F0, ret+8(FP)
Charles L. Dorian7f11db52010-01-15 13:21:36 -080028 RET