2 * Written by J.T. Conklin <jtc@acorntoolworks.com>
6 #include <machine/asm.h>
9 RCSID("$NetBSD: strcpy.S,v 1.1 2005/12/20 19:28:51 christos Exp $")
13 * This strcpy implementation copies a byte at a time until the
14 * source pointer is aligned to a word boundary, it then copies by
15 * words until it finds a word containing a zero byte, and finally
16 * copies by bytes until the end of the string is reached.
18 * While this may result in unaligned stores if the source and
19 * destination pointers are unaligned with respect to each other,
20 * it is still faster than either byte copies or the overhead of
21 * an implementation suitable for machines with strict alignment
27 movabsq $0x0101010101010101,%r8
28 movabsq $0x8080808080808080,%r9
31 * Align source to a word boundary.
32 * Consider unrolling loop?
59 * In rare cases, the above loop may exit prematurely. We must
60 * return to the loop if none of the bytes in the word equal 0.
65 testb %dl,%dl /* 1st byte == 0? */
71 testb %dl,%dl /* 2nd byte == 0? */
77 testb %dl,%dl /* 3rd byte == 0? */
83 testb %dl,%dl /* 4th byte == 0? */
89 testb %dl,%dl /* 5th byte == 0? */
95 testb %dl,%dl /* 6th byte == 0? */
101 testb %dl,%dl /* 7th byte == 0? */
107 testb %dl,%dl /* 8th byte == 0? */