Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * arch/alpha/lib/strcat.S | |
3 | * Contributed by Richard Henderson (rth@tamu.edu) | |
4 | * | |
5 | * Append a null-terminated string from SRC to DST. | |
6 | */ | |
00fc0e0d | 7 | #include <asm/export.h> |
1da177e4 LT |
8 | |
9 | .text | |
10 | ||
11 | .align 3 | |
12 | .globl strcat | |
13 | .ent strcat | |
14 | strcat: | |
15 | .frame $30, 0, $26 | |
16 | .prologue 0 | |
17 | ||
18 | mov $16, $0 # set up return value | |
19 | ||
20 | /* Find the end of the string. */ | |
21 | ||
22 | ldq_u $1, 0($16) # load first quadword (a0 may be misaligned) | |
23 | lda $2, -1 | |
24 | insqh $2, $16, $2 | |
25 | andnot $16, 7, $16 | |
26 | or $2, $1, $1 | |
27 | cmpbge $31, $1, $2 # bits set iff byte == 0 | |
28 | bne $2, $found | |
29 | ||
30 | $loop: ldq $1, 8($16) | |
31 | addq $16, 8, $16 | |
32 | cmpbge $31, $1, $2 | |
33 | beq $2, $loop | |
34 | ||
35 | $found: negq $2, $3 # clear all but least set bit | |
36 | and $2, $3, $2 | |
37 | ||
38 | and $2, 0xf0, $3 # binary search for that set bit | |
39 | and $2, 0xcc, $4 | |
40 | and $2, 0xaa, $5 | |
41 | cmovne $3, 4, $3 | |
42 | cmovne $4, 2, $4 | |
43 | cmovne $5, 1, $5 | |
44 | addq $3, $4, $3 | |
45 | addq $16, $5, $16 | |
46 | addq $16, $3, $16 | |
47 | ||
48 | /* Now do the append. */ | |
49 | ||
50 | mov $26, $23 | |
51 | br __stxcpy | |
52 | ||
53 | .end strcat | |
00fc0e0d | 54 | EXPORT_SYMBOL(strcat); |