1/* $OpenBSD: bzero.S,v 1.5 2014/11/29 18:51:23 tedu 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 xorl %eax,%eax /* set fill data to 0 */ 17 18 /* 19 * if the string is too short, it's really not worth the overhead 20 * of aligning to word boundaries, etc. So we jump to a plain 21 * unaligned set. 22 */ 23 cmpl $16,%edx 24 jb L1 25 26 movl %edi,%ecx /* compute misalignment */ 27 negl %ecx 28 andl $3,%ecx 29 subl %ecx,%edx 30 rep /* zero until word aligned */ 31 stosb 32 33 movl %edx,%ecx /* zero by words */ 34 shrl $2,%ecx 35 andl $3,%edx 36 rep 37 stosl 38 39L1: movl %edx,%ecx /* zero remainder by bytes */ 40 rep 41 stosb 42 43 popl %edi 44 ret 45#endif 46