eec073b23761f85bac54dd8312bf9ce4c3d7f496
[reactos.git] / lib / sdk / crt / math / i386 / floorf.S
1 /*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 *
5 * Changes for long double by Ulrich Drepper <drepper@cygnus.com>
6 *
7 * Removed header file dependency for use in libmingwex.a by
8 * Danny Smith <dannysmith@users.sourceforge.net>
9 */
10 #include <_mingw_mac.h>
11
12 .file "floorf.S"
13 .text
14 #ifdef _WIN64
15 .align 8
16 #else
17 .align 4
18 #endif
19 .globl __MINGW_USYMBOL(floorf)
20 .def __MINGW_USYMBOL(floorf); .scl 2; .type 32; .endef
21 __MINGW_USYMBOL(floorf):
22 #ifdef _WIN64
23 subq $24,%rsp
24 movss %xmm0,8(%rsp)
25 flds 8(%rsp)
26
27 fstcw 4(%rsp) /* store fpu control word */
28 movl $0x400,%edx /* round towards -oo */
29 orl 4(%rsp),%edx
30 andl $0xf7ff,%edx
31 movl %edx,(%rsp)
32 fldcw (%rsp) /* load modified control word */
33
34 frndint /* round */
35
36 fldcw 4(%rsp) /* restore original control word */
37
38 fstps 8(%rsp)
39 movss 8(%rsp),%xmm0
40 addq $24,%rsp
41 ret
42 #else
43 flds 4(%esp)
44 subl $8,%esp
45
46 fstcw 4(%esp) /* store fpu control word */
47
48 /* We use here %edx although only the low 1 bits are defined.
49 But none of the operations should care and they are faster
50 than the 16 bit operations. */
51 movl $0x400,%edx /* round towards -oo */
52 orl 4(%esp),%edx
53 andl $0xf7ff,%edx
54 movl %edx,(%esp)
55 fldcw (%esp) /* load modified control word */
56
57 frndint /* round */
58
59 fldcw 4(%esp) /* restore original control word */
60
61 addl $8,%esp
62 ret
63 #endif