xref: /titanic_41/usr/src/lib/libm/i386/src/remquol.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 "remquol.s"
30*5b2ba9d3SPiotr Jasiukajtis
31*5b2ba9d3SPiotr Jasiukajtis#include "libm.h"
32*5b2ba9d3SPiotr JasiukajtisLIBM_ANSI_PRAGMA_WEAK(remquol,function)
33*5b2ba9d3SPiotr Jasiukajtis#include "libm_protos.h"
34*5b2ba9d3SPiotr Jasiukajtis
35*5b2ba9d3SPiotr Jasiukajtis	ENTRY(remquol)
36*5b2ba9d3SPiotr Jasiukajtis	fldt	16(%esp)		/ load arg y
37*5b2ba9d3SPiotr Jasiukajtis	fldt	4(%esp)			/ load arg x
38*5b2ba9d3SPiotr Jasiukajtis.Lreml_loop:
39*5b2ba9d3SPiotr Jasiukajtis	fprem1				/ partial remainder
40*5b2ba9d3SPiotr Jasiukajtis	fstsw	%ax			/ store status word
41*5b2ba9d3SPiotr Jasiukajtis	andw	$0x400,%ax		/ check whether reduction complete
42*5b2ba9d3SPiotr Jasiukajtis	jne	.Lreml_loop		/ while reduction incomplete, do fprem1
43*5b2ba9d3SPiotr Jasiukajtis	fstsw	%ax
44*5b2ba9d3SPiotr Jasiukajtis	fwait
45*5b2ba9d3SPiotr Jasiukajtis	fstp	%st(1)
46*5b2ba9d3SPiotr Jasiukajtis	movw	%ax,%dx
47*5b2ba9d3SPiotr Jasiukajtis	andw	$0x4000,%dx		/ get C3
48*5b2ba9d3SPiotr Jasiukajtis	sarw	$13,%dx
49*5b2ba9d3SPiotr Jasiukajtis	movw	%ax,%cx
50*5b2ba9d3SPiotr Jasiukajtis	andw	$0x100,%cx		/ get C0
51*5b2ba9d3SPiotr Jasiukajtis	sarw	$6,%cx
52*5b2ba9d3SPiotr Jasiukajtis	addw	%cx,%dx
53*5b2ba9d3SPiotr Jasiukajtis	andw	$0x200,%ax		/ get C1
54*5b2ba9d3SPiotr Jasiukajtis	sarw	$9,%ax
55*5b2ba9d3SPiotr Jasiukajtis	addw	%dx,%ax
56*5b2ba9d3SPiotr Jasiukajtis	cwtl
57*5b2ba9d3SPiotr Jasiukajtis	movl	12(%esp),%edx		/ sign and bexp of x
58*5b2ba9d3SPiotr Jasiukajtis	movl	24(%esp),%ecx		/ sign and bexp of y
59*5b2ba9d3SPiotr Jasiukajtis	andl	$0x00008000,%edx	/ edx <- sign(x)
60*5b2ba9d3SPiotr Jasiukajtis	andl	$0x00008000,%ecx	/ ecx <- sign(y)
61*5b2ba9d3SPiotr Jasiukajtis	cmpl	%edx,%ecx
62*5b2ba9d3SPiotr Jasiukajtis	je	.pos
63*5b2ba9d3SPiotr Jasiukajtis	negl	%eax			/ negative n
64*5b2ba9d3SPiotr Jasiukajtis.pos:
65*5b2ba9d3SPiotr Jasiukajtis	movl	28(%esp),%ecx
66*5b2ba9d3SPiotr Jasiukajtis	movl	%eax,0(%ecx)		/ last 3 significant bits of quotient
67*5b2ba9d3SPiotr Jasiukajtis	ret
68*5b2ba9d3SPiotr Jasiukajtis	.align	4
69*5b2ba9d3SPiotr Jasiukajtis	SET_SIZE(remquol)
70