Charles L. Dorian | c3fa32c | 2010-02-18 23:33:15 -0800 | [diff] [blame] | 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 | |
Rob Pike | 8bca148 | 2014-08-12 17:04:45 -0700 | [diff] [blame] | 5 | #include "textflag.h" |
Keith Randall | 1f79663 | 2013-08-12 10:25:18 -0700 | [diff] [blame] | 6 | |
Charles L. Dorian | c3fa32c | 2010-02-18 23:33:15 -0800 | [diff] [blame] | 7 | // func Sincos(x float64) (sin, cos float64) |
Keith Randall | 1f79663 | 2013-08-12 10:25:18 -0700 | [diff] [blame] | 8 | TEXT ·Sincos(SB),NOSPLIT,$0 |
Charles L. Dorian | c3fa32c | 2010-02-18 23:33:15 -0800 | [diff] [blame] | 9 | FMOVD x+0(FP), F0 // F0=x |
| 10 | FSINCOS // F0=cos(x), F1=sin(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 |
Russ Cox | 8572950 | 2012-09-21 00:35:56 -0400 | [diff] [blame] | 14 | FMOVDP F0, cos+16(FP) // F0=sin(x) |
| 15 | FMOVDP F0, sin+8(FP) |
Charles L. Dorian | c3fa32c | 2010-02-18 23:33:15 -0800 | [diff] [blame] | 16 | 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 | FSINCOS // F0=cos(reduced_x), F1=sin(reduced_x) |
Russ Cox | 8572950 | 2012-09-21 00:35:56 -0400 | [diff] [blame] | 26 | FMOVDP F0, cos+16(FP) // F0=sin(reduced_x) |
| 27 | FMOVDP F0, sin+8(FP) |
Charles L. Dorian | c3fa32c | 2010-02-18 23:33:15 -0800 | [diff] [blame] | 28 | RET |