/*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* strcat(s, append)33* append a copy of the null-terminated string "append" to the end34* of the null-terminated string s, then add a terminating `\0'.35*36* Written by:37* J.T. Conklin ([email protected]), Winning Strategies, Inc.38*/3940/*41* I've unrolled the loop eight times: large enough to make a42* significant difference, and small enough not to totally trash the43* cache.44*/4546ENTRY(strcat)47pushl %edi /* save edi */48movl 8(%esp),%edi /* dst address */49movl 12(%esp),%edx /* src address */50pushl %edi /* push destination address */5152cld /* set search forward */53xorl %eax,%eax /* set search for null terminator */54movl $-1,%ecx /* set search for lots of characters */55repne /* search! */56scasb5758leal -1(%edi),%ecx /* correct dst address */5960.align 2,0x9061L1: movb (%edx),%al /* unroll loop, but not too much */62movb %al,(%ecx)63testb %al,%al64je L265movb 1(%edx),%al66movb %al,1(%ecx)67testb %al,%al68je L269movb 2(%edx),%al70movb %al,2(%ecx)71testb %al,%al72je L273movb 3(%edx),%al74movb %al,3(%ecx)75testb %al,%al76je L277movb 4(%edx),%al78movb %al,4(%ecx)79testb %al,%al80je L281movb 5(%edx),%al82movb %al,5(%ecx)83testb %al,%al84je L285movb 6(%edx),%al86movb %al,6(%ecx)87testb %al,%al88je L289movb 7(%edx),%al90movb %al,7(%ecx)91addl $8,%edx92addl $8,%ecx93testb %al,%al94jne L195L2: popl %eax /* pop destination address */96popl %edi /* restore edi */97ret98END(strcat)99100.section .note.GNU-stack,"",%progbits101102103