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