2 * Written by J.T. Conklin <jtc@acorntoolworks.com>
5 * $NetBSD: strcpy.S,v 1.3 2004/07/19 20:04:41 drochner Exp $
6 * $FreeBSD: src/lib/libc/amd64/string/strcpy.S,v 1.3 2008/11/02 01:10:54 peter Exp $
9 #include <machine/asm.h>
12 * This strcpy implementation copies a byte at a time until the
13 * source pointer is aligned to a word boundary, it then copies by
14 * words until it finds a word containing a zero byte, and finally
15 * copies by bytes until the end of the string is reached.
17 * While this may result in unaligned stores if the source and
18 * destination pointers are unaligned with respect to each other,
19 * it is still faster than either byte copies or the overhead of
20 * an implementation suitable for machines with strict alignment
26 movabsq $0x0101010101010101,%r8
27 movabsq $0x8080808080808080,%r9
30 * Align source to a word boundary.
31 * Consider unrolling loop?
57 * In rare cases, the above loop may exit prematurely. We must
58 * return to the loop if none of the bytes in the word equal 0.
63 testb %dl,%dl /* 1st byte == 0? */
69 testb %dl,%dl /* 2nd byte == 0? */
75 testb %dl,%dl /* 3rd byte == 0? */
81 testb %dl,%dl /* 4th byte == 0? */
87 testb %dl,%dl /* 5th byte == 0? */
93 testb %dl,%dl /* 6th byte == 0? */
99 testb %dl,%dl /* 7th byte == 0? */
105 testb %dl,%dl /* 8th byte == 0? */