2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A .file "_xtoull.s"
2N/A
2N/A#include <SYS.h>
2N/A
2N/A .set cw,0
2N/A .set cw_old,2
2N/A .set two_words,4
2N/A .set four_words,8
2N/A .text
2N/A .align 4
2N/Atwo_to_63: .long 0x5f000000
2N/A
2N/A ENTRY(__xtoull) // 387-stack to unsigned long long
2N/A subl $12,%esp
2N/A fstcw cw_old(%esp)
2N/A movw cw_old(%esp),%ax
2N/A movw %ax,%cx
2N/A andw $0x0c00,%cx // save RC
2N/A orw $0x0c00,%ax
2N/A movw %ax,cw(%esp)
2N/A fldcw cw(%esp)
2N/A _prologue_
2N/A fcoms _sref_(two_to_63) // compare st to 2**63
2N/A _epilogue_
2N/A fstsw %ax // store status in %ax
2N/A // use fstsw for correct trap handling
2N/A sahf // load AH into flags
2N/A jb .donotsub // jump if st < 2**63 or is NaN
2N/A _prologue_
2N/A fsubs _sref_(two_to_63) // subtract 2**63
2N/A _epilogue_
2N/A.donotsub:
2N/A fistpll two_words(%esp)
2N/A fwait // in case fistpll causes exception
2N/A movl four_words(%esp),%edx
2N/A jb .donotadd // flags did not change
2N/A add $0x80000000,%edx // add back 2**63
2N/A.donotadd:
2N/A fstcw cw(%esp) // fetch CW in case masks changed value
2N/A movw cw(%esp),%ax
2N/A andw $0xf3ff,%ax
2N/A orw %cx,%ax // restore RC
2N/A movw %ax,cw(%esp)
2N/A fldcw cw(%esp)
2N/A movl two_words(%esp),%eax
2N/A addl $12,%esp
2N/A ret
2N/A SET_SIZE(__xtoull)