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