1/*- 2 * Copyright (c) 1990, 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 * the Systems Programming Group of the University of Utah Computer 7 * Science Department. 8 * 9 * %sccs.include.redist.c% 10 */ 11 12#if defined(LIBC_SCCS) && !defined(lint) 13 .asciz "@(#)bzero.s 8.1 (Berkeley) 06/04/93" 14#endif /* LIBC_SCCS and not lint */ 15 16#include "DEFS.h" 17 18/* 19 * This is probably not the best we can do, but it is still much 20 * faster than the C version in the portable gen directory. 21 * 22 * Things that might help: 23 * - unroll the longword loop (might not be good for a 68020) 24 * - longword, as opposed to word, align when possible (only on the 68020) 25 * - use nested DBcc instructions or use one and limit size to 64K 26 */ 27ENTRY(bzero) 28 movl sp@(4),a0 /* destination */ 29 movl sp@(8),d0 /* count */ 30 jeq bzdone /* nothing to do */ 31 movl a0,d1 32 btst #0,d1 /* address odd? */ 33 jeq bzeven /* no, skip alignment */ 34 clrb a0@+ /* yes, clear a byte */ 35 subql #1,d0 /* adjust count */ 36 jeq bzdone /* if zero, all done */ 37bzeven: 38 movl d0,d1 39 lsrl #2,d1 /* convert to longword count */ 40 jeq bzbloop /* no longwords, skip loop */ 41bzlloop: 42 clrl a0@+ /* clear a longword */ 43 subql #1,d1 /* adjust count */ 44 jne bzlloop /* still more, keep going */ 45 andl #3,d0 /* what remains */ 46 jeq bzdone /* nothing, all done */ 47bzbloop: 48 clrb a0@+ /* clear a byte */ 49 subql #1,d0 /* adjust count */ 50 jne bzbloop /* still more, keep going */ 51bzdone: 52 rts 53