xref: /openbsd-src/lib/libm/arch/amd64/s_tan.S (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1/*	$OpenBSD: s_tan.S,v 1.3 2016/09/12 19:47:01 guenther 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
11ENTRY(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
211:	fldpi
22	fadd	%st(0)
23	fxch	%st(1)
242:	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
33END(tan)
34