Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / lib / libm / arch / i387 / s_cos.S
blobc802deecf7aa6256cef82e09c0147d2ffb05a95c
1 /*
2  * Written by J.T. Conklin <jtc@NetBSD.org>.
3  * Public domain.
4  */
6 #include <machine/asm.h>
8 #include "abi.h"
10 RCSID("$NetBSD: s_cos.S,v 1.7 2001/06/19 00:26:30 fvdl Exp $")
12 ENTRY(cos)
13         XMM_ONE_ARG_DOUBLE_PROLOGUE
14         fldl    ARG_DOUBLE_ONE
15         fcos
16         fnstsw  %ax
17         andw    $0x400,%ax
18         jnz     1f
19         XMM_DOUBLE_EPILOGUE
20         ret
21 1:      fldpi
22         fadd    %st(0)
23         fxch    %st(1)
24 2:      fprem1
25         fnstsw  %ax
26         andw    $0x400,%ax
27         jnz     2b
28         fstp    %st(1)
29         fcos
30         XMM_DOUBLE_EPILOGUE
31         ret