1/* Copyright (C) 2000-2022 Free Software Foundation, Inc.
2   This file is part of the GNU C Library.
3
4   The GNU C Library is free software; you can redistribute it and/or
5   modify it under the terms of the GNU Lesser General Public
6   License as published by the Free Software Foundation; either
7   version 2.1 of the License, or (at your option) any later version.
8
9   The GNU C Library is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with the GNU C Library.  If not, see
16   <https://www.gnu.org/licenses/>.  */
17
18/* Append a null-terminated string from SRC to DST.  */
19
20#include <sysdep.h>
21
22	.arch ev6
23	.set noreorder
24	.text
25
26ENTRY(strcat)
27	ldgp	gp, 0(pv)
28#ifdef PROF
29	.set noat
30	lda	AT, _mcount
31	jsr	AT, (AT), _mcount
32	.set at
33#endif
34	.prologue 1
35
36	mov	$16, $0		# E : set up return value
37	/* Find the end of the string.  */
38	ldq_u   $1, 0($16)	# L : load first quadword (a0 may be misaligned)
39	lda     $2, -1		# E :
40	insqh   $2, $16, $2	# U :
41
42	andnot  $16, 7, $16	# E :
43	or      $2, $1, $1	# E :
44	cmpbge  $31, $1, $2	# E : bits set iff byte == 0
45	bne     $2, $found	# U :
46
47$loop:	ldq     $1, 8($16)	# L :
48	addq    $16, 8, $16	# E :
49	cmpbge  $31, $1, $2	# E :
50	beq     $2, $loop	# U :
51
52$found:	cttz	$2, $3		# U0 :
53	addq	$16, $3, $16	# E :
54	/* Now do the append.  */
55	mov	$26, $23	# E :
56	jmp	$31, __stxcpy	# L0 :
57
58	END(strcat)
59libc_hidden_builtin_def (strcat)
60