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