xref: /titanic_50/usr/src/cmd/sgs/rtld.4.x/zero.s (revision a237e38e9161f0acd6451439d4a7dd597e66291d)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 *	Copyright (c) 1990, 1991 Sun Microsystems, Inc.
24 */
25
26#ident	"%Z%%M%	%I%	%E% SMI"
27
28/*
29 * Routine to zero out a section of memory (the tail end of the data segment
30 * upto a page boundary).  First nibble off any bytes up to the first double
31 * aligned word, and then clear doubles until the byte count is zero.  Note,
32 * this assumes the count specified has been rounded to end on a double word
33 * boundary.
34 *
35 *	%o0 = addr, %o1 = len
36 */
37
38	.seg	"text"
39	.global	__zero
40__zero:
41	tst	%o1		! Have we any count at all?
42	ba	3f		! Go find out,
43	clr	%g1		!   but prepare for long loop
44
45! Byte clearing loop
46
470:
48	inc	%o0		! Bump address
49	deccc	%o1		! Decrement count
503:
51	bz	1f		! If no count left, exit
52	andcc	%o0, 7, %g0	! Is the address less than double-word aligned?
53	bnz,a	0b		! Branch if so
54	clrb	[%o0]		!   but clear the current byte anyway
55
56! Double clearing loop
57
582:
59	std	%g0, [%o0]	! Clear next 8 bytes
60	subcc	%o1, 8, %o1	! Decrement count
61	bnz	2b		! Branch if any left
62	inc	8, %o0		!   but always increment address by 8
631:
64	retl			! Go home
65	nop
66