update for HEAD-2003091401
[reactos.git] / lib / crtdll / float / cntrlfp.c
1 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
2
3 #include <msvcrt/float.h>
4
5 /*
6  * @implemented
7  */
8 unsigned int    _controlfp (unsigned int unNew, unsigned int unMask)
9 {       
10         return _control87(unNew,unMask);
11 }
12
13 /*
14  * @implemented
15  */
16 unsigned int    _control87 (unsigned int unNew, unsigned int unMask)
17 {       
18 register unsigned int __res;
19 #ifdef __GNUC__
20 __asm__ __volatile__ (
21         "pushl  %%eax \n\t"             /* make room on stack */
22         "fstcw  (%%esp) \n\t"
23         "fwait \n\t"
24         "popl   %%eax \n\t"
25         "andl   $0xffff, %%eax  \n\t"   /* OK;  we have the old value ready */
26
27         "movl   %1, %%ecx \n\t"
28         "notl   %%ecx \n\t"
29         "andl   %%eax, %%ecx \n\t"      /* the bits we want to keep */
30
31         "movl   %2, %%edx \n\t"
32         "andl   %1, %%edx \n\t" /* the bits we want to change */
33
34         "orl    %%ecx, %%edx\n\t"               /* the new value */
35         "pushl  %%edx \n\t"
36         "fldcw  (%%esp) \n\t"
37         "popl   %%edx \n\t"
38
39         :"=r" (__res):"r" (unNew),"r" (unMask): "ax", "dx", "cx");
40 #else
41 #endif /*__GNUC__*/
42         return __res;
43 }