[AMD64]
[reactos.git] / reactos / lib / sdk / crt / math / amd64 / floorf.S
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * PURPOSE: Implementation of tan
5 * FILE: lib/sdk/crt/math/amd64/floorf.S
6 * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include <reactos/asm.h>
12 #include <ndk/amd64/asm.h>
13
14 /* FUNCTIONS ****************************************************************/
15
16 .code64
17
18 PUBLIC floorf
19 floorf:
20 /* Put parameter on the stack */
21 movss [rsp - 0x10], xmm0
22 fld dword ptr [rsp]
23
24 /* Change fpu control word to round down */
25 fstcw [rsp - 0x10]
26 mov eax, [rsp - 0x10]
27 or eax, 0x00400
28 and eax, 0x0f7ff
29 mov [rsp - 0x08], eax
30 fldcw [rsp - 0x08]
31
32 /* Round to integer */
33 frndint
34
35 /* Restore fpu control word */
36 fldcw [rsp - 0x10]
37
38 fstp dword ptr [rsp - 0x10]
39 movss xmm0, [rsp - 0x10]
40 ret