blob: 3589dd807aebe4d1a6204752ba5e1f299ca4267e (
plain)
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
51
52
53
54
55
56
|
/*
* Linux 386 fpu support
* Mimic Plan9 floating point support
*/
#include "lib9.h"
void
setfcr(ulong fcr)
{
__asm__( "xorb $0x3f, %%al\n\t"
"pushw %%ax\n\t"
"fwait\n\t"
"fldcw (%%esp)\n\t"
"popw %%ax\n\t"
: /* no output */
: "al" (fcr)
);
}
ulong
getfcr(void)
{
ulong fcr = 0;
__asm__( "pushl %%eax\n\t"
"fwait\n\t"
"fstcw (%%esp)\n\t"
"popl %%eax\n\t"
"xorb $0x3f, %%al\n\t"
: "=a" (fcr)
: "eax" (fcr)
);
return fcr;
}
ulong
getfsr(void)
{
ulong fsr = -1;
__asm__( "fwait\n\t"
"fstsw (%%eax)\n\t"
"movl (%%eax), %%eax\n\t"
"andl $0xffff, %%eax\n\t"
: "=a" (fsr)
: "eax" (&fsr)
);
return fsr;
}
void
setfsr(ulong fsr)
{
__asm__("fclex\n\t");
}
|