11aa3da2fa4fc55717a8ec21c64411f1d60ee59f
[musl] / src / fenv / x86_64 / fenv.s
1 2:      not %edi
2         sub $32,%rsp
3         fnstenv (%rsp)
4         and %edi,4(%rsp)
5         or %esi,4(%rsp)
6         fldenv (%rsp)
7         stmxcsr (%rsp)
8         and %edi,(%rsp)
9         ldmxcsr (%rsp)
10         add $32,%rsp
11         ret
12
13 .global feclearexcept
14 .type feclearexcept,@function
15 feclearexcept:  
16         xor %eax,%eax
17         xor %esi,%esi
18         test %edi,%edi
19         jnz 2b
20         ret
21
22 .global feraiseexcept
23 .type feraiseexcept,@function
24 feraiseexcept:  
25         xor %eax,%eax
26         mov %edi,%esi
27         xor %edi,%edi
28         test %esi,%esi
29         jnz 2b
30         ret
31
32 .global fesetround
33 .type fesetround,@function
34 fesetround:
35         push %rax
36         xor %eax,%eax
37         mov %edi,%ecx
38         fnstcw (%rsp)
39         andb $0xf3,1(%rsp)
40         or %ch,1(%rsp)
41         fldcw (%rsp)
42         stmxcsr (%rsp)
43         shl $3,%ch
44         andb $0x9f,1(%rsp)
45         or %ch,1(%rsp)
46         ldmxcsr (%rsp)
47         pop %rcx
48         ret
49
50 .global fegetround
51 .type fegetround,@function
52 fegetround:
53         push %rax
54         stmxcsr (%rsp)
55         pop %rax
56         shr $3,%eax
57         and $0xc00,%eax
58         ret
59
60 .global fegetenv
61 .type fegetenv,@function
62 fegetenv:
63         xor %eax,%eax
64         fnstenv (%rdi)
65         stmxcsr 28(%rdi)
66         ret
67
68 .global fesetenv
69 .type fesetenv,@function
70 fesetenv:
71         xor %eax,%eax
72         inc %rdi
73         jz 1f
74         fldenv -1(%rdi)
75         ldmxcsr 27(%rdi)
76         ret
77 1:      push %rax
78         push %rax
79         push %rax
80         pushq $0x37f
81         fldenv (%rsp)
82         pushq $0x1f80
83         ldmxcsr (%rsp)
84         add $40,%rsp
85         ret
86
87 .global fetestexcept
88 .type fetestexcept,@function
89 fetestexcept:
90         push %rax
91         stmxcsr (%rsp)
92         pop %rsi
93         fnstsw %ax
94         or %esi,%eax
95         and %edi,%eax
96         ret