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 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
32 * C support for 64-bit modulo and division.
33 * GNU routines callable from C (though generated by the compiler).
34 * Hand-customized compiler output - see comments for details.
41 * Perform division of two unsigned 64-bit quantities, returning the
42 * quotient in %edx:%eax.
45 movl
4(%esp
), %eax
/ x
, x
46 movl
8(%esp
), %edx
/ x
, x
57 * Perform division of two unsigned 64-bit quantities, returning the
58 * remainder in %edx:%eax.
62 movl
%esp
, %ecx
/, tmp65
63 movl
16(%esp
), %eax
/ x
, x
64 movl
20(%esp
), %edx
/ x
, x
69 movl
12(%esp
), %eax
/ rem
, rem
70 movl
16(%esp
), %edx
/ rem
, rem
78 * Perform division of two signed 64-bit quantities, returning the
79 * quotient in %edx:%eax.
82 / __divdi3
(int64_t x
, int64_t y
)
101 / return
(negative ?
(int64_t
) - r
: r
);
108 movl
28(%esp
), %edx
/ x
, x
110 movl
24(%esp
), %eax
/ x
, x
111 movl
32(%esp
), %esi
/ y
, y
112 movl
36(%esp
), %edi
/ y
, y
114 xorl
%ebp
, %ebp
/ negative
116 movl
%eax
, (%esp
) / x
, xt
117 movl
%edx
, 4(%esp
) / x
, xt
118 movl
%esi
, %eax
/ y
, yt
119 movl
%edi
, %edx
/ y
, yt
124 movl
8(%esp
), %eax
/ xt
, xt
125 movl
12(%esp
), %edx
/ xt
, xt
128 testl
%ebp
, %ebp
/ negative
146 movl
%eax
, (%esp
) / x
, xt
147 movl
%edx
, 4(%esp
) / x
, xt
148 movl $
1, %ebp
/, negative
149 movl
%esi
, %eax
/ y
, yt
150 movl
%edi
, %edx
/ y
, yt
157 xorl $
1, %ebp
/, negative
164 * Perform division of two signed 64-bit quantities, returning the
165 * quotient in %edx:%eax.
168 / __moddi3
(int64_t x
, int64_t y
)
170 / uint64_t xt
, yt
, rem;
173 / xt
= -(uint64_t
) x;
178 / yt
= -(uint64_t
) y;
182 / (void
) UDivRem
(xt
, yt
, &rem
);
183 / return
(x
< 0 ?
(int64_t
) - rem
: rem
);
189 movl
36(%esp
), %ecx
/ x
,
190 movl
32(%esp
), %esi
/ x
,
191 movl
36(%esp
), %edi
/ x
,
193 movl
40(%esp
), %eax
/ y
, y
194 movl
44(%esp
), %edx
/ y
, y
195 movl
%esi
, (%esp
) /, xt
196 movl
%edi
, 4(%esp
) /, xt
199 movl
%eax
, %esi
/ y
, yt
200 movl
%edx
, %edi
/ y
, yt
203 leal
8(%esp
), %eax
/, tmp66
207 movl
12(%esp
), %eax
/ xt
, xt
208 movl
16(%esp
), %edx
/ xt
, xt
211 movl
36(%esp
), %edi
/ x
,
213 movl
8(%esp
), %eax
/ rem
, rem
214 movl
12(%esp
), %edx
/ rem
, rem
226 movl
%esi
, (%esp
) /, xt
227 movl
%edi
, 4(%esp
) /, xt
228 movl
%eax
, %esi
/ y
, yt
229 movl
%edx
, %edi
/ y
, yt