/*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* strcpy (dst, src)33* copy the string src to dst.34*35* Written by:36* J.T. Conklin ([email protected]), Winning Strategies, Inc.37*/3839/*40* I've unrolled the loop eight times: large enough to make a41* significant difference, and small enough not to totally trash the42* cache.43*/4445ENTRY(strcpy)46movl 4(%esp),%ecx /* dst address */47movl 8(%esp),%edx /* src address */48pushl %ecx /* push dst address */4950.align 2,0x9051L1: movb (%edx),%al /* unroll loop, but not too much */52movb %al,(%ecx)53testb %al,%al54je L255movb 1(%edx),%al56movb %al,1(%ecx)57testb %al,%al58je L259movb 2(%edx),%al60movb %al,2(%ecx)61testb %al,%al62je L263movb 3(%edx),%al64movb %al,3(%ecx)65testb %al,%al66je L267movb 4(%edx),%al68movb %al,4(%ecx)69testb %al,%al70je L271movb 5(%edx),%al72movb %al,5(%ecx)73testb %al,%al74je L275movb 6(%edx),%al76movb %al,6(%ecx)77testb %al,%al78je L279movb 7(%edx),%al80movb %al,7(%ecx)81addl $8,%edx82addl $8,%ecx83testb %al,%al84jne L185L2: popl %eax /* pop dst address */86ret87END(strcpy)8889.section .note.GNU-stack,"",%progbits909192