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