2 * Written by J.T. Conklin <jtc@acorntoolworks.com>
5 * $NetBSD: strcat.S,v 1.4 2004/07/26 18:51:21 drochner Exp $
6 * $FreeBSD: src/lib/libc/amd64/string/strcat.S,v 1.2 2008/11/02 01:10:54 peter Exp $
9 #include <machine/asm.h>
13 movabsq $0x0101010101010101,%r8
14 movabsq $0x8080808080808080,%r9
17 * Align destination to word boundary.
18 * Consider unrolling loop?
39 * In rare cases, the above loop may exit prematurely. We must
40 * return to the loop if none of the bytes in the word equal 0.
43 cmpb $0,-8(%rdi) /* 1st byte == 0? */
48 1: cmpb $0,-7(%rdi) /* 2nd byte == 0? */
53 1: cmpb $0,-6(%rdi) /* 3rd byte == 0? */
58 1: cmpb $0,-5(%rdi) /* 4th byte == 0? */
63 1: cmpb $0,-4(%rdi) /* 5th byte == 0? */
68 1: cmpb $0,-3(%rdi) /* 6th byte == 0? */
73 1: cmpb $0,-2(%rdi) /* 7th byte == 0? */
78 1: cmpb $0,-1(%rdi) /* 8th byte == 0? */
83 * Align source to a word boundary.
84 * Consider unrolling loop?
111 * In rare cases, the above loop may exit prematurely. We must
112 * return to the loop if none of the bytes in the word equal 0.
117 testb %dl,%dl /* 1st byte == 0? */
123 testb %dl,%dl /* 2nd byte == 0? */
129 testb %dl,%dl /* 3rd byte == 0? */
135 testb %dl,%dl /* 4th byte == 0? */
141 testb %dl,%dl /* 5th byte == 0? */
147 testb %dl,%dl /* 6th byte == 0? */
153 testb %dl,%dl /* 7th byte == 0? */
159 testb %dl,%dl /* 8th byte == 0? */