2 * Written by J.T. Conklin <jtc@acorntoolworks.com>
6 #include <machine/asm.h>
9 RCSID("$NetBSD: strrchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
15 /* zero return value */
19 * Align to word boundary.
20 * Consider unrolling loop?
34 /* copy char to all bytes in word */
43 movabsq $0x0101010101010101,%r8
44 movabsq $0x8080808080808080,%r9
46 /* Check whether any byte in the word is equal to ch or 0. */
60 * In rare cases, the above loop may exit prematurely. We must
61 * return to the loop if none of the bytes in the word match
62 * ch or are equal to 0.
66 cmpb %cl,%dl /* 1st byte == ch? */
69 1: testb %dl,%dl /* 1st byte == 0? */
73 cmpb %cl,%dl /* 2nd byte == ch? */
76 1: testb %dl,%dl /* 2nd byte == 0? */
80 cmpb %cl,%dl /* 3rd byte == ch? */
83 1: testb %dl,%dl /* 3rd byte == 0? */
87 cmpb %cl,%dl /* 4th byte == ch? */
90 1: testb %dl,%dl /* 4th byte == 0? */
94 cmpb %cl,%dl /* 5th byte == ch? */
97 1: testb %dl,%dl /* 5th byte == 0? */
101 cmpb %cl,%dl /* 6th byte == ch? */
104 1: testb %dl,%dl /* 6th byte == 0? */
108 cmpb %cl,%dl /* 7th byte == ch? */
111 1: testb %dl,%dl /* 7th byte == 0? */
115 cmpb %cl,%dl /* 8th byte == ch? */
118 1: testb %dl,%dl /* 8th byte == 0? */
124 STRONG_ALIAS(rindex,strrchr)