xref: /original-bsd/lib/libc/mips/string/bzero.s (revision c3e32dec)
1/*-
2 * Copyright (c) 1991, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Ralph Campbell.
7 *
8 * %sccs.include.redist.c%
9 */
10
11#include <machine/machAsmDefs.h>
12
13#if defined(LIBC_SCCS) && !defined(lint)
14	ASMSTR("@(#)bzero.s	8.1 (Berkeley) 06/04/93")
15#endif /* LIBC_SCCS and not lint */
16
17/* bzero(s1, n) */
18
19LEAF(bzero)
20	.set	noreorder
21	blt	a1, 12, smallclr	# small amount to clear?
22	subu	a3, zero, a0		# compute # bytes to word align address
23	and	a3, a3, 3
24	beq	a3, zero, 1f		# skip if word aligned
25	subu	a1, a1, a3		# subtract from remaining count
26	swr	zero, 0(a0)		# clear 1, 2, or 3 bytes to align
27	addu	a0, a0, a3
281:
29	and	v0, a1, 3		# compute number of words left
30	subu	a3, a1, v0
31	move	a1, v0
32	addu	a3, a3, a0		# compute ending address
332:
34	addu	a0, a0, 4		# clear words
35	bne	a0, a3, 2b		#   unrolling loop doesnt help
36	sw	zero, -4(a0)		#   since we are limited by memory speed
37smallclr:
38	ble	a1, zero, 2f
39	addu	a3, a1, a0		# compute ending address
401:
41	addu	a0, a0, 1		# clear bytes
42	bne	a0, a3, 1b
43	sb	zero, -1(a0)
442:
45	j	ra
46	nop
47END(bzero)
48