/*1* Copyright (c) 1993 Winning Strategies, Inc.2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. All advertising materials mentioning features or use of this software13* must display the following acknowledgement:14* This product includes software developed by Winning Strategies, Inc.15* 4. The name of the author may not be used to endorse or promote products16* derived from this software without specific prior written permission17*18* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR19* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES20* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.21* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,22* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT23* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,24* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY25* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF27* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28*/2930#include <machine/asm.h>31/*32* bzero (void *b, size_t len)33* write len zero bytes to the string b.34*35* Written by:36* J.T. Conklin ([email protected]), Winning Strategies, Inc.37*/3839ENTRY(bzero)40pushl %edi41pushl %ebx42movl 12(%esp),%edi43movl 16(%esp),%ecx4445cld /* set fill direction forward */46xorl %eax,%eax /* set fill data to 0 */4748/*49* if the string is too short, it's really not worth the overhead50* of aligning to word boundries, etc. So we jump to a plain51* unaligned set.52*/53cmpl $0x0f,%ecx54jle L15556movl %edi,%edx /* compute misalignment */57negl %edx58andl $3,%edx59movl %ecx,%ebx60subl %edx,%ebx6162movl %edx,%ecx /* zero until word aligned */63rep64stosb6566movl %ebx,%ecx /* zero by words */67shrl $2,%ecx68rep69stosl7071movl %ebx,%ecx72andl $3,%ecx /* zero remainder by bytes */73L1: rep74stosb7576popl %ebx77popl %edi78ret79END(bzero)8081.section .note.GNU-stack,"",%progbits828384