0ac9098b9a3d75905c676f6500b55ace40e4119e
[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 <asm.inc>
12 #include <ksamd64.inc>
13
14 /* FUNCTIONS ****************************************************************/
15
16 .code64
17
18 PUBLIC floorf
19 floorf:
20 sub rsp, 16
21
22 /* Put parameter on the stack */
23 movss [rsp], xmm0
24 fld dword ptr [rsp]
25
26 /* Change fpu control word to round down */
27 fstcw [rsp]
28 mov eax, [rsp]
29 or eax, 0x00400
30 and eax, 0x0f7ff
31 mov [rsp + 8], eax
32 fldcw [rsp + 8]
33
34 /* Round to integer */
35 frndint
36
37 /* Restore fpu control word */
38 fldcw [rsp]
39
40 fstp dword ptr [rsp]
41 movss xmm0, [rsp]
42 add rsp, 16
43 ret
44
45 END