1/* 2 * Written by J.T. Conklin <jtc@netbsd.org>. 3 * Public domain. 4 */ 5 6#include <machine/asm.h> 7 8#if defined(APIWARN) 9#APP 10 .stabs "warning: strcpy() is almost always misused, consider using strlcpy()",30,0,0,0 11 .stabs "_strcpy",1,0,0,0 12#NO_APP 13#endif 14 15#if defined(LIBC_SCCS) 16 .text 17 .asciz "$OpenBSD: strcpy.S,v 1.5 2003/07/24 01:15:42 deraadt Exp $" 18#endif 19 20/* 21 * NOTE: I've unrolled the loop eight times: large enough to make a 22 * significant difference, and small enough not to totally trash the 23 * cache. 24 */ 25 26ENTRY(strcpy) 27 movl 4(%esp),%ecx /* dst address */ 28 movl 8(%esp),%edx /* src address */ 29 pushl %ecx /* push dst address */ 30 31 .align 2,0x90 32L1: movb (%edx),%al /* unroll loop, but not too much */ 33 movb %al,(%ecx) 34 testb %al,%al 35 jz L2 36 movb 1(%edx),%al 37 movb %al,1(%ecx) 38 testb %al,%al 39 jz L2 40 movb 2(%edx),%al 41 movb %al,2(%ecx) 42 testb %al,%al 43 jz L2 44 movb 3(%edx),%al 45 movb %al,3(%ecx) 46 testb %al,%al 47 jz L2 48 movb 4(%edx),%al 49 movb %al,4(%ecx) 50 testb %al,%al 51 jz L2 52 movb 5(%edx),%al 53 movb %al,5(%ecx) 54 testb %al,%al 55 jz L2 56 movb 6(%edx),%al 57 movb %al,6(%ecx) 58 testb %al,%al 59 jz L2 60 movb 7(%edx),%al 61 movb %al,7(%ecx) 62 addl $8,%edx 63 addl $8,%ecx 64 testb %al,%al 65 jnz L1 66L2: popl %eax /* pop dst address */ 67 ret 68