initial commit
[libm] / 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         xor %eax,%eax
36         sub $32,%rsp
37         fnstenv (%rsp)
38         andb $0xf3,1(%rsp)
39         or %edi,(%rsp)
40         fldenv (%rsp)
41         stmxcsr (%rsp)
42         shl $3,%edi
43         andb $0x9f,1(%rsp)
44         or %edi,(%rsp)
45         ldmxcsr (%rsp)
46         add $32,%rsp
47         ret
48
49 .global fegetround
50 .type fegetround,@function
51 fegetround:
52         push %rax
53         stmxcsr (%rsp)
54         pop %rax
55         shr $3,%eax
56         and $0xc,%ah
57         ret
58
59 .global fegetenv
60 .type fegetenv,@function
61 fegetenv:
62         xor %eax,%eax
63         fnstenv (%rdi)
64         stmxcsr 28(%rdi)
65         ret
66
67 .global fesetenv
68 .type fesetenv,@function
69 fesetenv:
70         xor %eax,%eax
71         inc %rdi
72         jz 1f
73         fldenv -1(%rdi)
74         ldmxcsr 27(%rdi)
75         ret
76 1:      push %rax
77         push %rax
78         push %rax
79         pushq $0x37f
80         fldenv (%rsp)
81         pushq $0x1f80
82         ldmxcsr (%rsp)
83         add $40,%rsp
84         ret
85
86 .global fetestexcept
87 .type fetestexcept,@function
88 fetestexcept:
89         push %rax
90         stmxcsr (%rsp)
91         pop %rsi
92         fnstsw %ax
93         or %esi,%eax
94         and %edi,%eax
95         ret