]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/alpha/strcat.S
update from main archive 961005
[thirdparty/glibc.git] / sysdeps / alpha / strcat.S
1 /* Copyright (C) 1996 Free Software Foundation, Inc.
2 Contributed by Richard Henderson (rth@tamu.edu)
3
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If
18 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19 Cambridge, MA 02139, USA. */
20
21 /* Append a null-terminated string from SRC to DST. */
22
23 #include <sysdep.h>
24
25 .text
26
27 ENTRY(strcat)
28 ldgp gp, 0(pv)
29 .prologue 1
30
31 mov a0, v0 # set up return value
32
33 /* Find the end of the string. */
34
35 ldq_u t0, 0(a0) # load first quadword (a0 may be misaligned)
36 lda t1, -1(zero)
37 insqh t1, a0, t1
38 andnot a0, 7, a0
39 or t1, t0, t0
40 cmpbge zero, t0, t1 # t1 <- bitmask: bit i == 1 <==> i-th byte == 0
41 bne t1, $found
42
43 $loop: ldq t0, 8(a0)
44 addq a0, 8, a0 # addr += 8
45 cmpbge zero, t0, t1
46 beq t1, $loop
47
48 $found: negq t1, t2 # clear all but least set bit
49 and t1, t2, t1
50
51 and t1, 0xf0, t2 # binary search for that set bit
52 and t1, 0xcc, t3
53 and t1, 0xaa, t4
54 cmovne t2, 4, t2
55 cmovne t3, 2, t3
56 cmovne t4, 1, t4
57 addq t2, t3, t2
58 addq a0, t4, a0
59 addq a0, t2, a0
60
61 /* Now do the append. */
62
63 jsr t9, __stxcpy
64 ret
65
66 END(strcat)