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