[NTOS]
[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 <ndk/amd64/asm.h>
12 #include <ndk/amd64/asmmacro.S>
13
14 .intel_syntax noprefix
15
16
17 .proc floorf
18 /* Put parameter on the stack */
19 movss [rsp - 0x10], xmm0
20 fld dword ptr [rsp]
21
22 /* Change fpu control word to round down */
23 fstcw [rsp - 0x10]
24 mov eax, [rsp - 0x10]
25 or eax, 0x00400
26 and eax, 0x0f7ff
27 mov [rsp - 0x08], eax
28 fldcw [rsp - 0x08]
29
30 /* Round to integer */
31 frndint
32
33 /* Restore fpu control word */
34 fldcw [rsp - 0x10]
35
36 fstp dword ptr [rsp - 0x10]
37 movss xmm0, [rsp - 0x10]
38 ret
39
40 .endproc