bzero.S revision 85437
11849Swollman/* 21849Swollman * Copyright (c) 1993 Winning Strategies, Inc. 31849Swollman * All rights reserved. 41849Swollman * 51849Swollman * Redistribution and use in source and binary forms, with or without 61849Swollman * modification, are permitted provided that the following conditions 71849Swollman * are met: 81849Swollman * 1. Redistributions of source code must retain the above copyright 91849Swollman * notice, this list of conditions and the following disclaimer. 101849Swollman * 2. Redistributions in binary form must reproduce the above copyright 111849Swollman * notice, this list of conditions and the following disclaimer in the 121849Swollman * documentation and/or other materials provided with the distribution. 131849Swollman * 3. All advertising materials mentioning features or use of this software 141849Swollman * must display the following acknowledgement: 151849Swollman * This product includes software developed by Winning Strategies, Inc. 161849Swollman * 4. The name of the author may not be used to endorse or promote products 171849Swollman * derived from this software withough specific prior written permission 181849Swollman * 191849Swollman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 201849Swollman * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 211849Swollman * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 221849Swollman * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 231849Swollman * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 241849Swollman * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 251849Swollman * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 261849Swollman * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 271849Swollman * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 281849Swollman * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 291849Swollman */ 301849Swollman 311849Swollman#if defined(LIBC_RCS) && !defined(lint) 325790Sdg .text 3350476Speter .asciz "$FreeBSD: head/lib/libc/i386/string/bzero.S 85437 2001-10-24 20:29:14Z peter $" 341849Swollman#endif /* LIBC_RCS and not lint */ 351849Swollman 3685437Speter#include <machine/asm.h> 371849Swollman 381849Swollman/* 391849Swollman * bzero (void *b, size_t len) 401849Swollman * write len zero bytes to the string b. 411849Swollman * 421849Swollman * Written by: 431849Swollman * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. 441849Swollman */ 451849Swollman 461849SwollmanENTRY(bzero) 471849Swollman pushl %edi 481849Swollman pushl %ebx 491849Swollman movl 12(%esp),%edi 501849Swollman movl 16(%esp),%ecx 511849Swollman 521849Swollman cld /* set fill direction forward */ 531849Swollman xorl %eax,%eax /* set fill data to 0 */ 541849Swollman 551849Swollman /* 561849Swollman * if the string is too short, it's really not worth the overhead 571849Swollman * of aligning to word boundries, etc. So we jump to a plain 581849Swollman * unaligned set. 591849Swollman */ 601849Swollman cmpl $0x0f,%ecx 611849Swollman jle L1 621849Swollman 631849Swollman movl %edi,%edx /* compute misalignment */ 641849Swollman negl %edx 651849Swollman andl $3,%edx 661849Swollman movl %ecx,%ebx 671849Swollman subl %edx,%ebx 681849Swollman 691849Swollman movl %edx,%ecx /* zero until word aligned */ 701849Swollman rep 711849Swollman stosb 721849Swollman 731849Swollman movl %ebx,%ecx /* zero by words */ 741849Swollman shrl $2,%ecx 751849Swollman rep 761849Swollman stosl 771849Swollman 781849Swollman movl %ebx,%ecx 791849Swollman andl $3,%ecx /* zero remainder by bytes */ 801849SwollmanL1: rep 811849Swollman stosb 821849Swollman 831849Swollman popl %ebx 841849Swollman popl %edi 851849Swollman ret 86