xref: /csrg-svn/lib/libc/hp300/string/bzero.s (revision 61123)
141810Sbostic/*-
2*61123Sbostic * Copyright (c) 1990, 1993
3*61123Sbostic *	The Regents of the University of California.  All rights reserved.
441810Sbostic *
541810Sbostic * This code is derived from software contributed to Berkeley by
641810Sbostic * the Systems Programming Group of the University of Utah Computer
741810Sbostic * Science Department.
841810Sbostic *
941810Sbostic * %sccs.include.redist.c%
1041810Sbostic */
1141810Sbostic
1241810Sbostic#if defined(LIBC_SCCS) && !defined(lint)
13*61123Sbostic	.asciz "@(#)bzero.s	8.1 (Berkeley) 06/04/93"
1441810Sbostic#endif /* LIBC_SCCS and not lint */
1541810Sbostic
1641810Sbostic#include "DEFS.h"
1741810Sbostic
1841810Sbostic/*
1941810Sbostic * This is probably not the best we can do, but it is still much
2041810Sbostic * faster than the C version in the portable gen directory.
2141810Sbostic *
2241810Sbostic * Things that might help:
2341810Sbostic *	- unroll the longword loop (might not be good for a 68020)
2441810Sbostic *	- longword, as opposed to word, align when possible (only on the 68020)
2541810Sbostic *	- use nested DBcc instructions or use one and limit size to 64K
2641810Sbostic */
2741810SbosticENTRY(bzero)
2841810Sbostic	movl	sp@(4),a0	/* destination */
2941810Sbostic	movl	sp@(8),d0	/* count */
3041810Sbostic	jeq	bzdone		/* nothing to do */
3141810Sbostic	movl	a0,d1
3241810Sbostic	btst	#0,d1		/* address odd? */
3341810Sbostic	jeq	bzeven		/* no, skip alignment */
3441810Sbostic	clrb	a0@+		/* yes, clear a byte */
3541810Sbostic	subql	#1,d0		/* adjust count */
3641810Sbostic	jeq	bzdone		/* if zero, all done */
3741810Sbosticbzeven:
3841810Sbostic	movl	d0,d1
3941810Sbostic	lsrl	#2,d1		/* convert to longword count */
4041810Sbostic	jeq	bzbloop		/* no longwords, skip loop */
4141810Sbosticbzlloop:
4241810Sbostic	clrl	a0@+		/* clear a longword */
4341810Sbostic	subql	#1,d1		/* adjust count */
4441810Sbostic	jne	bzlloop		/* still more, keep going */
4541810Sbostic	andl	#3,d0		/* what remains */
4641810Sbostic	jeq	bzdone		/* nothing, all done */
4741810Sbosticbzbloop:
4841810Sbostic	clrb	a0@+		/* clear a byte */
4941810Sbostic	subql	#1,d0		/* adjust count */
5041810Sbostic	jne	bzbloop		/* still more, keep going */
5141810Sbosticbzdone:
5241810Sbostic	rts
53