coverity appeasement
[minix.git] / lib / libm / arch / i387 / s_floor.S
blob22da00aacd5389050aaaaf56115086a129a17709
1 /*
2  * Written by J.T. Conklin <jtc@NetBSD.org>.
3  * Public domain.
4  */
6 #include <machine/asm.h>
8 RCSID("$NetBSD: s_floor.S,v 1.8 2003/07/26 19:25:02 salo Exp $")
10 ENTRY(floor)
11 #ifdef __i386__
12         pushl   %ebp
13         movl    %esp,%ebp
14         subl    $8,%esp
16         fstcw   -4(%ebp)                /* store fpu control word */
17         movw    -4(%ebp),%dx
18         orw     $0x0400,%dx             /* round towards -oo */
19         andw    $0xf7ff,%dx
20         movw    %dx,-8(%ebp)
21         fldcw   -8(%ebp)                /* load modfied control word */
23         fldl    8(%ebp);                /* round */
24         frndint
26         fldcw   -4(%ebp)                /* restore original control word */
28         leave
29 #else
30         movsd   %xmm0, -8(%rsp)
31         fstcw   -12(%rsp)
32         movw    -12(%rsp),%dx
33         orw     $0x0400,%dx
34         andw    $0xf7ff,%dx
35         movw    %dx,-16(%rsp)
36         fldcw   -16(%rsp)
37         fldl    -8(%rsp)
38         frndint
39         fldcw   -12(%rsp)
40         fstpl   -8(%rsp)
41         movsd   -8(%rsp),%xmm0
42 #endif
43         ret