xref: /titanic_41/usr/src/lib/libm/i386/src/log.s (revision a9d3dcd5820128b4f34bf38f447e47aa95c004e8)
1*5b2ba9d3SPiotr Jasiukajtis/*
2*5b2ba9d3SPiotr Jasiukajtis * CDDL HEADER START
3*5b2ba9d3SPiotr Jasiukajtis *
4*5b2ba9d3SPiotr Jasiukajtis * The contents of this file are subject to the terms of the
5*5b2ba9d3SPiotr Jasiukajtis * Common Development and Distribution License (the "License").
6*5b2ba9d3SPiotr Jasiukajtis * You may not use this file except in compliance with the License.
7*5b2ba9d3SPiotr Jasiukajtis *
8*5b2ba9d3SPiotr Jasiukajtis * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*5b2ba9d3SPiotr Jasiukajtis * or http://www.opensolaris.org/os/licensing.
10*5b2ba9d3SPiotr Jasiukajtis * See the License for the specific language governing permissions
11*5b2ba9d3SPiotr Jasiukajtis * and limitations under the License.
12*5b2ba9d3SPiotr Jasiukajtis *
13*5b2ba9d3SPiotr Jasiukajtis * When distributing Covered Code, include this CDDL HEADER in each
14*5b2ba9d3SPiotr Jasiukajtis * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*5b2ba9d3SPiotr Jasiukajtis * If applicable, add the following below this CDDL HEADER, with the
16*5b2ba9d3SPiotr Jasiukajtis * fields enclosed by brackets "[]" replaced with your own identifying
17*5b2ba9d3SPiotr Jasiukajtis * information: Portions Copyright [yyyy] [name of copyright owner]
18*5b2ba9d3SPiotr Jasiukajtis *
19*5b2ba9d3SPiotr Jasiukajtis * CDDL HEADER END
20*5b2ba9d3SPiotr Jasiukajtis */
21*5b2ba9d3SPiotr Jasiukajtis/*
22*5b2ba9d3SPiotr Jasiukajtis * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
23*5b2ba9d3SPiotr Jasiukajtis */
24*5b2ba9d3SPiotr Jasiukajtis/*
25*5b2ba9d3SPiotr Jasiukajtis * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
26*5b2ba9d3SPiotr Jasiukajtis * Use is subject to license terms.
27*5b2ba9d3SPiotr Jasiukajtis */
28*5b2ba9d3SPiotr Jasiukajtis
29*5b2ba9d3SPiotr Jasiukajtis	.file "log.s"
30*5b2ba9d3SPiotr Jasiukajtis
31*5b2ba9d3SPiotr Jasiukajtis#include "libm.h"
32*5b2ba9d3SPiotr JasiukajtisLIBM_ANSI_PRAGMA_WEAK(log,function)
33*5b2ba9d3SPiotr Jasiukajtis#include "libm_protos.h"
34*5b2ba9d3SPiotr Jasiukajtis
35*5b2ba9d3SPiotr Jasiukajtis	ENTRY(log)
36*5b2ba9d3SPiotr Jasiukajtis	fldln2				/ loge(2)
37*5b2ba9d3SPiotr Jasiukajtis	movl	8(%esp),%eax		/ eax <-- hi_32(x)
38*5b2ba9d3SPiotr Jasiukajtis	testl	$0x80000000,%eax
39*5b2ba9d3SPiotr Jasiukajtis	jnz	.maybe_0_or_less
40*5b2ba9d3SPiotr Jasiukajtis	testl	$0x7fffffff,%eax
41*5b2ba9d3SPiotr Jasiukajtis	jz	.maybe_0
42*5b2ba9d3SPiotr Jasiukajtis	fldl	4(%esp)			/ arg, loge(2)
43*5b2ba9d3SPiotr Jasiukajtis	fyl2x				/ loge(2)*log2(arg); ln(arg)
44*5b2ba9d3SPiotr Jasiukajtis	ret
45*5b2ba9d3SPiotr Jasiukajtis
46*5b2ba9d3SPiotr Jasiukajtis.maybe_0:
47*5b2ba9d3SPiotr Jasiukajtis	movl	4(%esp),%ecx		/ ecx <-- lo_32(x)
48*5b2ba9d3SPiotr Jasiukajtis	cmpl	$0,%ecx
49*5b2ba9d3SPiotr Jasiukajtis	je	.zero			/ no branch if x is +denormal
50*5b2ba9d3SPiotr Jasiukajtis.neg_nan_reentry:
51*5b2ba9d3SPiotr Jasiukajtis	fldl	4(%esp)			/ arg, loge(2)
52*5b2ba9d3SPiotr Jasiukajtis	fyl2x				/ loge(2)*log2(arg); ln(arg)
53*5b2ba9d3SPiotr Jasiukajtis	ret
54*5b2ba9d3SPiotr Jasiukajtis
55*5b2ba9d3SPiotr Jasiukajtis.zero_or_less:
56*5b2ba9d3SPiotr Jasiukajtis	/ x =< 0
57*5b2ba9d3SPiotr Jasiukajtis	testl	$0x7fffffff,%eax
58*5b2ba9d3SPiotr Jasiukajtis	jnz	.less_than_0
59*5b2ba9d3SPiotr Jasiukajtis	movl	4(%esp),%ecx		/ ecx <-- lo_32(x)
60*5b2ba9d3SPiotr Jasiukajtis	cmpl	$0,%ecx
61*5b2ba9d3SPiotr Jasiukajtis	jne	.less_than_0		/ branch if x is -denormal
62*5b2ba9d3SPiotr Jasiukajtis.zero:
63*5b2ba9d3SPiotr Jasiukajtis	/ x = +/-0
64*5b2ba9d3SPiotr Jasiukajtis	pushl	%ebp
65*5b2ba9d3SPiotr Jasiukajtis	movl	%esp,%ebp
66*5b2ba9d3SPiotr Jasiukajtis	PIC_SETUP(1)
67*5b2ba9d3SPiotr Jasiukajtis	pushl	$16
68*5b2ba9d3SPiotr Jasiukajtis	jmp	.merge
69*5b2ba9d3SPiotr Jasiukajtis
70*5b2ba9d3SPiotr Jasiukajtis.maybe_0_or_less:
71*5b2ba9d3SPiotr Jasiukajtis	cmpl	$0xfff00000,%eax	/ -INF below hi_32(x)?
72*5b2ba9d3SPiotr Jasiukajtis	ja	.neg_nan_reentry
73*5b2ba9d3SPiotr Jasiukajtis	jb	.zero_or_less
74*5b2ba9d3SPiotr Jasiukajtis	movl	4(%esp),%ecx		/ ecx <-- lo_32(x)
75*5b2ba9d3SPiotr Jasiukajtis	cmpl	$0,%ecx			/ is x NaN or -INF?
76*5b2ba9d3SPiotr Jasiukajtis	jne	.neg_nan_reentry	/ branch if x is NaN with signbit = 1
77*5b2ba9d3SPiotr Jasiukajtis	/ x = -INF
78*5b2ba9d3SPiotr Jasiukajtis.less_than_0:
79*5b2ba9d3SPiotr Jasiukajtis	pushl	%ebp
80*5b2ba9d3SPiotr Jasiukajtis	movl	%esp,%ebp
81*5b2ba9d3SPiotr Jasiukajtis	PIC_SETUP(2)
82*5b2ba9d3SPiotr Jasiukajtis	pushl	$17
83*5b2ba9d3SPiotr Jasiukajtis.merge:
84*5b2ba9d3SPiotr Jasiukajtis	fstp	%st(0)			/ stack empty
85*5b2ba9d3SPiotr Jasiukajtis	pushl	12(%ebp)
86*5b2ba9d3SPiotr Jasiukajtis	pushl	8(%ebp)
87*5b2ba9d3SPiotr Jasiukajtis	pushl	12(%ebp)
88*5b2ba9d3SPiotr Jasiukajtis	pushl	8(%ebp)
89*5b2ba9d3SPiotr Jasiukajtis	call	PIC_F(_SVID_libm_err)
90*5b2ba9d3SPiotr Jasiukajtis	addl	$20,%esp
91*5b2ba9d3SPiotr Jasiukajtis	PIC_WRAPUP
92*5b2ba9d3SPiotr Jasiukajtis	leave
93*5b2ba9d3SPiotr Jasiukajtis	ret
94*5b2ba9d3SPiotr Jasiukajtis	.align	4
95*5b2ba9d3SPiotr Jasiukajtis	SET_SIZE(log)
96