Import OpenBSD's libm (trunk, 4 July 2015) to a new vendor branch
[dragonfly.git] / contrib / openbsd_libm / arch / amd64 / s_sin.S
1 /*      $OpenBSD: s_sin.S,v 1.2 2005/08/02 11:17:31 espie Exp $ */
2 /*
3  * Written by J.T. Conklin <jtc@NetBSD.org>.
4  * Public domain.
5  */
6
7 #include <machine/asm.h>
8
9 #include "abi.h"
10
11 ENTRY(sin)
12         XMM_ONE_ARG_DOUBLE_PROLOGUE
13         fldl    ARG_DOUBLE_ONE
14         fsin
15         fnstsw  %ax
16         andw    $0x400,%ax
17         jnz     1f
18         XMM_DOUBLE_EPILOGUE
19         ret
20 1:      fldpi
21         fadd    %st(0)
22         fxch    %st(1)
23 2:      fprem1
24         fnstsw  %ax
25         andw    $0x400,%ax
26         jnz     2b
27         fstp    %st(1)
28         fsin
29         XMM_DOUBLE_EPILOGUE
30         ret