summaryrefslogtreecommitdiff
path: root/src/fp.s
diff options
context:
space:
mode:
Diffstat (limited to 'src/fp.s')
-rw-r--r--src/fp.s47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/fp.s b/src/fp.s
new file mode 100644
index 0000000..b1af581
--- /dev/null
+++ b/src/fp.s
@@ -0,0 +1,47 @@
+.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