forked from gbezyuk/bb-osx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctrl87.c
50 lines (41 loc) · 1.67 KB
/
ctrl87.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* ctrl87.c
* This file is part of msdos driver for XaoS
*/
#define __CONTROL87_C__
#include "ctrl87.h"
/***** _control87 *****/
unsigned short _control87(unsigned short newcw, unsigned short mask)
{
unsigned short cw;
#ifdef __GNUC__
#ifdef __i386__
asm volatile (" \n\
wait \n\
fstcw %0 "
: /* outputs */ "=m" (cw)
: /* inputs */
);
if (mask) { /* mask is not 0 */
asm volatile (" \n\
mov %2, %%ax \n\
mov %3, %%bx \n\
and %%bx, %%ax \n\
not %%bx \n\
nop \n\
wait \n\
mov %1, %%dx \n\
and %%bx, %%dx \n\
or %%ax, %%dx \n\
mov %%dx, %0 \n\
wait \n\
fldcw %1 "
: /* outputs */ "=g" (cw)
: /* inputs */ "g"(cw), "g"(newcw), "g"(mask)
: /* registers */ "ax", "bx", "dx"
);
}
return cw;
#endif
#endif
} /* _control87 */