blob: 7d9b87e11255c502294706263809af9a212266be [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/* $OpenBSD: strcpy.S,v 1.8 2005/08/07 11:30:38 espie Exp $ */
2/*
3 * Written by J.T. Conklin <jtc@netbsd.org>.
4 * Public domain.
5 */
6
7#include <machine/asm.h>
8
9#if defined(APIWARN)
10#APP
11 .section .gnu.warning.strcpy
12 .ascii "warning: strcpy() is almost always misused, please use strlcpy()"
13#NO_APP
14#endif
15
16/*
17 * NOTE: I've unrolled the loop eight times: large enough to make a
18 * significant difference, and small enough not to totally trash the
19 * cache.
20 */
21
22ENTRY(strcpy)
23 movl 4(%esp),%ecx /* dst address */
24 movl 8(%esp),%edx /* src address */
25 pushl %ecx /* push dst address */
26
27 .align 2,0x90
28L1: movb (%edx),%al /* unroll loop, but not too much */
29 movb %al,(%ecx)
30 testb %al,%al
31 jz L2
32 movb 1(%edx),%al
33 movb %al,1(%ecx)
34 testb %al,%al
35 jz L2
36 movb 2(%edx),%al
37 movb %al,2(%ecx)
38 testb %al,%al
39 jz L2
40 movb 3(%edx),%al
41 movb %al,3(%ecx)
42 testb %al,%al
43 jz L2
44 movb 4(%edx),%al
45 movb %al,4(%ecx)
46 testb %al,%al
47 jz L2
48 movb 5(%edx),%al
49 movb %al,5(%ecx)
50 testb %al,%al
51 jz L2
52 movb 6(%edx),%al
53 movb %al,6(%ecx)
54 testb %al,%al
55 jz L2
56 movb 7(%edx),%al
57 movb %al,7(%ecx)
58 addl $8,%edx
59 addl $8,%ecx
60 testb %al,%al
61 jnz L1
62L2: popl %eax /* pop dst address */
63 ret
Elliott Hughes67195002013-02-13 15:12:32 -080064END(strcpy)