1993-10-07 03:17:24 +03:00
|
|
|
/*
|
1995-04-29 02:53:59 +04:00
|
|
|
* Written by J.T. Conklin <jtc@netbsd.org>.
|
|
|
|
* Public domain.
|
1993-10-07 03:17:24 +03:00
|
|
|
*/
|
|
|
|
|
1994-03-12 04:39:55 +03:00
|
|
|
#include <machine/asm.h>
|
|
|
|
|
1993-10-21 04:39:55 +03:00
|
|
|
#if defined(LIBC_SCCS)
|
1995-04-29 02:57:54 +04:00
|
|
|
RCSID("$NetBSD: strcat.S,v 1.8 1995/04/28 22:58:09 jtc Exp $")
|
1993-10-21 04:39:55 +03:00
|
|
|
#endif
|
1993-10-07 03:17:24 +03:00
|
|
|
|
|
|
|
/*
|
1995-04-29 02:53:59 +04:00
|
|
|
* NOTE: I've unrolled the loop eight times: large enough to make a
|
1993-10-07 03:17:24 +03:00
|
|
|
* significant difference, and small enough not to totally trash the
|
1994-02-14 20:45:16 +03:00
|
|
|
* cache.
|
1993-10-07 03:17:24 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
ENTRY(strcat)
|
|
|
|
pushl %edi /* save edi */
|
|
|
|
movl 8(%esp),%edi /* dst address */
|
|
|
|
movl 12(%esp),%edx /* src address */
|
|
|
|
pushl %edi /* push destination address */
|
|
|
|
|
|
|
|
cld /* set search forward */
|
|
|
|
xorl %eax,%eax /* set search for null terminator */
|
|
|
|
movl $-1,%ecx /* set search for lots of characters */
|
|
|
|
repne /* search! */
|
|
|
|
scasb
|
|
|
|
|
|
|
|
leal -1(%edi),%ecx /* correct dst address */
|
|
|
|
|
|
|
|
.align 2,0x90
|
|
|
|
L1: movb (%edx),%al /* unroll loop, but not too much */
|
|
|
|
movb %al,(%ecx)
|
|
|
|
testb %al,%al
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L2
|
1993-10-07 03:17:24 +03:00
|
|
|
movb 1(%edx),%al
|
|
|
|
movb %al,1(%ecx)
|
|
|
|
testb %al,%al
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L2
|
1993-10-07 03:17:24 +03:00
|
|
|
movb 2(%edx),%al
|
|
|
|
movb %al,2(%ecx)
|
|
|
|
testb %al,%al
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L2
|
1993-10-07 03:17:24 +03:00
|
|
|
movb 3(%edx),%al
|
|
|
|
movb %al,3(%ecx)
|
|
|
|
testb %al,%al
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L2
|
1993-10-07 03:17:24 +03:00
|
|
|
movb 4(%edx),%al
|
|
|
|
movb %al,4(%ecx)
|
|
|
|
testb %al,%al
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L2
|
1993-10-07 03:17:24 +03:00
|
|
|
movb 5(%edx),%al
|
|
|
|
movb %al,5(%ecx)
|
|
|
|
testb %al,%al
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L2
|
1993-10-07 03:17:24 +03:00
|
|
|
movb 6(%edx),%al
|
|
|
|
movb %al,6(%ecx)
|
|
|
|
testb %al,%al
|
1994-02-14 23:05:52 +03:00
|
|
|
jz L2
|
1993-10-07 03:17:24 +03:00
|
|
|
movb 7(%edx),%al
|
|
|
|
movb %al,7(%ecx)
|
|
|
|
addl $8,%edx
|
|
|
|
addl $8,%ecx
|
|
|
|
testb %al,%al
|
1994-02-14 23:05:52 +03:00
|
|
|
jnz L1
|
1993-10-07 03:17:24 +03:00
|
|
|
L2: popl %eax /* pop destination address */
|
|
|
|
popl %edi /* restore edi */
|
|
|
|
ret
|