exp2.s revision ddc0e0b53c661f6e439e3b7072b3ef353eadb4af
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore/*
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * CDDL HEADER START
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore *
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * The contents of this file are subject to the terms of the
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * Common Development and Distribution License (the "License").
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * You may not use this file except in compliance with the License.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore *
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * or http://www.opensolaris.org/os/licensing.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * See the License for the specific language governing permissions
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * and limitations under the License.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore *
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * When distributing Covered Code, include this CDDL HEADER in each
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * If applicable, add the following below this CDDL HEADER, with the
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * fields enclosed by brackets "[]" replaced with your own identifying
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * information: Portions Copyright [yyyy] [name of copyright owner]
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore *
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * CDDL HEADER END
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore */
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore/*
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore */
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore/*
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore * Use is subject to license terms.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore */
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore .file "exp2.s"
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#include "libm.h"
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'AmoreLIBM_ANSI_PRAGMA_WEAK(exp2,function)
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore ENTRY(exp2)
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore movl 8(%esp),%ecx / ecx <-- hi_32(x)
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore andl $0x7fffffff,%ecx / ecx <-- hi_32(|x|)
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore cmpl $0x3ff00000,%ecx / Is |x| < 1?
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore jb .shortcut / If so, take a shortcut.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore je .check_tail / |x| may be only slightly < ln(2)
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore cmpl $0x7ff00000,%ecx / hi_32(|x|) >= hi_32(INF)?
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore jae .not_finite / if so, x is not finite
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore.finite_non_special: / Here, 1 < |x| < INF
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fldl 4(%esp) / push arg
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fld %st(0) / duplicate stack top
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore frndint / [x],x
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fucom / x integral?
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fstsw %ax
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore sahf
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore je .x_integral / branch if x integral
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fxch / x, [x]
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fsub %st(1),%st / x-[x], [x]
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore f2xm1 / 2**(x-[x])-1, [x]
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fld1 / 1,2**(x-[x])-1, [x]
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore faddp %st,%st(1) / 2**(x-[x]), [x]
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fscale / 2**x = 2**(arg), [x]
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fstp %st(1)
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore ret
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore.x_integral:
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fstp %st(0) / ,x
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fld1 / 1 = 2**0, x
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fscale / 2**(0 + x) = 2**x, x
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fstp %st(1) / 2**x
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore ret
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore.check_tail:
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore movl 4(%esp),%edx / edx <-- lo_32(x)
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore cmpl $0x00000000,%edx / Is |x| slightly > 1?
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore ja .finite_non_special / branch if |x| slightly > 1
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore.shortcut:
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore / Here, |x| <= 1,
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore / whence x is in f2xm1's domain.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fldl 4(%esp) / push x
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore f2xm1 / 2**x - 1
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fld1 / 1,2**x - 1
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore faddp %st,%st(1) / 2**x
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore ret
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore.not_finite:
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore cmpl $0x7ff00000,%ecx / hi_32(|x|) > hi_32(INF)?
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore ja .NaN_or_pinf / if so, x is NaN
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore movl 4(%esp),%edx / edx <-- lo_32(x)
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore cmpl $0,%edx / lo_32(x) = 0?
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore jne .NaN_or_pinf / if not, x is NaN
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore movl 8(%esp),%eax / eax <-- hi_32(x)
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore andl $0x80000000,%eax / here, x is infinite, but +/-?
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore jz .NaN_or_pinf / branch if x = +INF
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore fldz / Here, x = -inf, so return 0
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore ret
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore.NaN_or_pinf:
/ Here, x = NaN or +inf, so load x and return immediately.
fldl 4(%esp)
fwait
ret
.align 4
SET_SIZE(exp2)