Charles L. Dorian | 7f11db5 | 2010-01-15 13:21:36 -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 | 7f11db5 | 2010-01-15 13:21:36 -0800 | [diff] [blame] | 7 | // func Asin(x float64) float64 |
Keith Randall | 1f79663 | 2013-08-12 10:25:18 -0700 | [diff] [blame] | 8 | TEXT ·Asin(SB),NOSPLIT,$0 |
Charles L. Dorian | 7f11db5 | 2010-01-15 13:21:36 -0800 | [diff] [blame] | 9 | FMOVD x+0(FP), F0 // F0=sin(x) |
| 10 | FMOVD F0, F1 // F0=sin(x), F1=sin(x) |
| 11 | FMULD F0, F0 // F0=sin(x)*sin(x), F1=sin(x) |
| 12 | FLD1 // F0=1, F1=sin(x)*sin(x), F2=sin(x) |
| 13 | FSUBRDP F0, F1 // F0=1-sin(x)*sin(x) (=cos(x)*cos(x)), F1=sin(x) |
| 14 | FSQRT // F0=cos(x), F1=sin(x) |
| 15 | FPATAN // F0=arcsin(sin(x))=x |
Russ Cox | 07720b6 | 2013-03-22 12:57:55 -0400 | [diff] [blame] | 16 | FMOVDP F0, ret+8(FP) |
Charles L. Dorian | 7f11db5 | 2010-01-15 13:21:36 -0800 | [diff] [blame] | 17 | RET |
| 18 | |
| 19 | // func Acos(x float64) float64 |
Keith Randall | 1f79663 | 2013-08-12 10:25:18 -0700 | [diff] [blame] | 20 | TEXT ·Acos(SB),NOSPLIT,$0 |
Charles L. Dorian | 7f11db5 | 2010-01-15 13:21:36 -0800 | [diff] [blame] | 21 | FMOVD x+0(FP), F0 // F0=cos(x) |
| 22 | FMOVD F0, F1 // F0=cos(x), F1=cos(x) |
| 23 | FMULD F0, F0 // F0=cos(x)*cos(x), F1=cos(x) |
| 24 | FLD1 // F0=1, F1=cos(x)*cos(x), F2=cos(x) |
| 25 | FSUBRDP F0, F1 // F0=1-cos(x)*cos(x) (=sin(x)*sin(x)), F1=cos(x) |
| 26 | FSQRT // F0=sin(x), F1=cos(x) |
| 27 | FXCHD F0, F1 // F0=cos(x), F1=sin(x) |
| 28 | FPATAN // F0=arccos(cos(x))=x |
Russ Cox | 07720b6 | 2013-03-22 12:57:55 -0400 | [diff] [blame] | 29 | FMOVDP F0, ret+8(FP) |
Charles L. Dorian | 7f11db5 | 2010-01-15 13:21:36 -0800 | [diff] [blame] | 30 | RET |