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.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 52fegetround: 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 62fegetenv: 63 xor %eax,%eax 64 fnstenv (%rdi) 65 stmxcsr 28(%rdi) 66 ret 67 68.global fesetenv 69.type fesetenv,@function 70fesetenv: 71 xor %eax,%eax 72 inc %rdi 73 jz 1f 74 fldenv -1(%rdi) 75 ldmxcsr 27(%rdi) 76 ret 771: push %rax 78 push %rax 79 pushq $0xffff 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 89fetestexcept: 90 and $0x3f,%edi 91 push %rax 92 stmxcsr (%rsp) 93 pop %rsi 94 fnstsw %ax 95 or %esi,%eax 96 and %edi,%eax 97 ret 98