acbd10d762aef2b885d84c004f0601490ea6df09
[dragonfly.git] / contrib / openbsd_libm / arch / amd64 / s_tan.S
1 /*      $OpenBSD: s_tan.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(tan)
12         XMM_ONE_ARG_DOUBLE_PROLOGUE
13         fldl    ARG_DOUBLE_ONE
14         fptan
15         fnstsw  %ax
16         andw    $0x400,%ax
17         jnz     1f
18         fstp    %st(0)
19         XMM_DOUBLE_EPILOGUE
20         ret
21 1:      fldpi
22         fadd    %st(0)
23         fxch    %st(1)
24 2:      fprem1
25         fstsw   %ax
26         andw    $0x400,%ax
27         jnz     2b
28         fstp    %st(1)
29         fptan
30         fstp    %st(0)
31         XMM_DOUBLE_EPILOGUE
32         ret