Home | History | Annotate | Line # | Download | only in string
bzero.S revision 1.11
      1  1.11  christos /*
      2  1.11  christos  * Written by J.T. Conklin <jtc (at) NetBSD.org>.
      3  1.11  christos  * Public domain.
      4  1.11  christos  */
      5   1.1       cgd 
      6  1.11  christos #include <machine/asm.h>
      7  1.11  christos 
      8  1.11  christos #if defined(LIBC_SCCS)
      9  1.11  christos 	RCSID("$NetBSD: bzero.S,v 1.11 2005/02/07 05:22:51 christos Exp $")
     10  1.11  christos #endif
     11  1.11  christos 
     12  1.11  christos ENTRY(bzero)
     13  1.11  christos 	pushl	%edi
     14  1.11  christos 	movl	8(%esp),%edi
     15  1.11  christos 	movl	12(%esp),%edx
     16  1.11  christos 
     17  1.11  christos 	cld				/* set fill direction forward */
     18  1.11  christos 	xorl	%eax,%eax		/* set fill data to 0 */
     19  1.11  christos 
     20  1.11  christos 	/*
     21  1.11  christos 	 * if the string is too short, it's really not worth the overhead
     22  1.11  christos 	 * of aligning to word boundries, etc.  So we jump to a plain
     23  1.11  christos 	 * unaligned set.
     24  1.11  christos 	 */
     25  1.11  christos 	cmpl	$16,%edx
     26  1.11  christos 	jb	L1
     27  1.11  christos 
     28  1.11  christos 	movl	%edi,%ecx		/* compute misalignment */
     29  1.11  christos 	negl	%ecx
     30  1.11  christos 	andl	$3,%ecx
     31  1.11  christos 	subl	%ecx,%edx
     32  1.11  christos 	rep				/* zero until word aligned */
     33  1.11  christos 	stosb
     34  1.11  christos 
     35  1.11  christos 	movl	%edx,%ecx		/* zero by words */
     36  1.11  christos 	shrl	$2,%ecx
     37  1.11  christos 	andl	$3,%edx
     38  1.11  christos 	rep
     39  1.11  christos 	stosl
     40  1.11  christos 
     41  1.11  christos L1:	movl	%edx,%ecx		/* zero remainder by bytes */
     42  1.11  christos 	rep
     43  1.11  christos 	stosb
     44  1.11  christos 
     45  1.11  christos 	popl	%edi
     46  1.11  christos 	ret
     47