1993-10-07 03:17:24 +03:00
|
|
|
/*
|
1995-04-29 02:53:59 +04:00
|
|
|
* Written by J.T. Conklin <jtc@netbsd.org>.
|
|
|
|
* Public domain.
|
1993-10-07 03:17:24 +03:00
|
|
|
*/
|
|
|
|
|
1994-03-12 04:39:55 +03:00
|
|
|
#include <machine/asm.h>
|
|
|
|
|
1993-10-21 04:39:55 +03:00
|
|
|
#if defined(LIBC_SCCS)
|
1995-04-29 02:57:54 +04:00
|
|
|
RCSID("$NetBSD: bzero.S,v 1.8 1995/04/28 22:57:58 jtc Exp $")
|
1993-10-21 04:39:55 +03:00
|
|
|
#endif
|
1993-10-07 03:17:24 +03:00
|
|
|
|
|
|
|
ENTRY(bzero)
|
|
|
|
pushl %edi
|
1995-02-05 17:58:44 +03:00
|
|
|
movl 8(%esp),%edi
|
|
|
|
movl 12(%esp),%edx
|
1993-10-07 03:17:24 +03:00
|
|
|
|
|
|
|
cld /* set fill direction forward */
|
|
|
|
xorl %eax,%eax /* set fill data to 0 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if the string is too short, it's really not worth the overhead
|
1993-10-21 04:48:14 +03:00
|
|
|
* of aligning to word boundries, etc. So we jump to a plain
|
1993-10-07 03:17:24 +03:00
|
|
|
* unaligned set.
|
|
|
|
*/
|
1995-02-05 17:58:44 +03:00
|
|
|
cmpl $16,%edx
|
|
|
|
jb L1
|
1993-10-07 03:17:24 +03:00
|
|
|
|
1995-02-05 17:58:44 +03:00
|
|
|
movl %edi,%ecx /* compute misalignment */
|
|
|
|
negl %ecx
|
|
|
|
andl $3,%ecx
|
|
|
|
subl %ecx,%edx
|
|
|
|
rep /* zero until word aligned */
|
1993-10-07 03:17:24 +03:00
|
|
|
stosb
|
|
|
|
|
1995-02-05 17:58:44 +03:00
|
|
|
movl %edx,%ecx /* zero by words */
|
1993-10-07 03:17:24 +03:00
|
|
|
shrl $2,%ecx
|
1995-02-05 17:58:44 +03:00
|
|
|
andl $3,%edx
|
1993-10-07 03:17:24 +03:00
|
|
|
rep
|
|
|
|
stosl
|
|
|
|
|
1995-02-05 17:58:44 +03:00
|
|
|
L1: movl %edx,%ecx /* zero remainder by bytes */
|
|
|
|
rep
|
1993-10-07 03:17:24 +03:00
|
|
|
stosb
|
|
|
|
|
|
|
|
popl %edi
|
|
|
|
ret
|