.global init_fp init_fp: call init_sse push %eax call init_x87 pop %ebx or %ebx, %eax ret init_sse: mov $0x1, %eax cpuid test %edx, 1<<25 jz no_sse mov %cr0, %eax and %ax, 0xFFFB or %ax, 0x2 mov %eax, %cr0 mov %cr4, %eax or %ax, 3<<9 mov %eax, %cr4 xor %eax, %eax ret no_sse: mov $1, %eax ret init_x87: mov %cr0, %eax and %eax, (-1) - ((1 << 3) + (1 << 4)) mov %eax, %cr0 fninit fnstsw (test) cmpw $0, (test) xor %eax, %eax ret no_x87: mov $2, %eax ret test: .word 0x55AA