4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
29 / Double long divide routine.
48 / the following code is only for compatibility with original ldivide code
49 orl
%edx
,%edx
/ force numerator positive
55 testl $
0x80000000,rop+
4(%esp
)
57 notl rop+
4(%esp
) / force denominator positive
59 sbbl $
0xffffffff,rop+
4(%esp
)
61 / end of compatibility code
63 xorl
%esi
,%esi
/ initialize remainder to
0
65 movl $
64,%ecx
/ initialize counter for
64-bits
68 rcll $
1,%esi
/ remainder
* 2
70 rcll $
1,%edx
/ numerator
* 2 (also quotient
)
71 adcl $
0,%edi
/ add in any carry from the shift
72 subl rop
(%esp
),%edi
/ subtract denominator from remainder
74 incl
%eax
/ turn on quotient bit for now
75 jnc
.inc_remainder / inc didn't affect carry flag
76 / can't subtract the denominator from the remainder, add it back
79 decl
%eax
/ turn quotient bit off
83 / at this point
, %edx
:%eax has the quotient
and %edi
:%esi has the remainder