fix fesetround - it was writing to status word instead of control word
[musl] / src / fenv / i386 / fenv.s
1 2:      not %ecx
2         sub $32,%esp
3         fnstenv (%esp)
4         and %ecx,4(%esp)
5         or %edx,4(%esp)
6         fldenv (%esp)
7         add $32,%esp
8         ret
9
10 .global feclearexcept
11 feclearexcept:  
12         xor %eax,%eax
13         mov 4(%esp),%ecx
14         xor %edx,%edx
15         test %ecx,%ecx
16         jnz 2b
17         ret
18
19 .global feraiseexcept
20 feraiseexcept:  
21         xor %eax,%eax
22         mov 4(%esp),%edx
23         xor %ecx,%ecx
24         test %edx,%edx
25         jnz 2b
26         ret
27
28 .global fesetround
29 fesetround:
30         mov 4(%esp),%ecx
31         xor %eax,%eax
32         sub $32,%esp
33         fnstenv (%esp)
34         andb $0xf3,1(%esp)
35         or %ecx,(%esp)
36         fldenv (%esp)
37         add $32,%esp
38         ret
39
40 .global fegetround
41 fegetround:
42         sub $28,%esp
43         fnstenv (%esp)
44         mov 4(%esp),%eax
45         add $28,%esp
46         and $0xc,%ah
47         ret
48
49 .global fegetenv
50 fegetenv:
51         mov 4(%esp),%ecx
52         xor %eax,%eax
53         fnstenv (%ecx)
54         ret
55
56 .global fesetenv
57 fesetenv:
58         mov 4(%esp),%ecx
59         xor %eax,%eax
60         test %ecx,%ecx
61         jz 1f
62         fldenv (%ecx)
63         ret
64 1:      push %eax
65         push %eax
66         push %eax
67         push %eax
68         push %eax
69         push %eax
70         pushl $0x37f
71         fldenv (%esp)
72         add $28,%esp
73         ret
74
75 .global fetestexcept
76 fetestexcept:
77         mov 4(%esp),%ecx
78         fnstsw %ax
79         and %ecx,%eax
80         ret