asm for hypot and hypotf
[musl] / src / math / i386 / hypot.s
diff --git a/src/math/i386/hypot.s b/src/math/i386/hypot.s
new file mode 100644 (file)
index 0000000..299c2e1
--- /dev/null
@@ -0,0 +1,45 @@
+.global hypot
+.type hypot,@function
+hypot:
+       mov 8(%esp),%eax
+       mov 16(%esp),%ecx
+       add %eax,%eax
+       add %ecx,%ecx
+       and %eax,%ecx
+       cmp $0xffe00000,%ecx
+       jae 2f
+       or 4(%esp),%eax
+       jnz 1f
+       fldl 12(%esp)
+       fabs
+       ret
+1:     mov 16(%esp),%eax
+       add %eax,%eax
+       or 12(%esp),%eax
+       jnz 1f
+       fldl 4(%esp)
+       fabs
+       ret
+1:     fldl 4(%esp)
+       fld %st(0)
+       fmulp
+       fldl 12(%esp)
+       fld %st(0)
+       fmulp
+       faddp
+       fsqrt
+       ret
+2:     sub $0xffe00000,%eax
+       or 4(%esp),%eax
+       jnz 1f
+       fldl 4(%esp)
+       fabs
+       ret
+1:     mov 16(%esp),%eax
+       add %eax,%eax
+       sub $0xffe00000,%eax
+       or 12(%esp),%eax
+       fldl 12(%esp)
+       jnz 1f
+       fabs
+1:     ret