xref: /csrg-svn/lib/libc/tahoe/string/strncat.s (revision 29700)
1#ifdef LIBC_SCCS
2	.asciz	"@(#)strncat.s	1.1 (Berkeley/CCI) 08/01/86"
3#endif LIBC_SCCS
4
5/*
6 * Concatenate s2 on the end of s1.  S1's space must be large enough.
7 * At most n characters are moved.
8 * Return s1.
9 *
10 * char *strncat(s1, s2, n)
11 * register char *s1, *s2;
12 * register n;
13 */
14#include "DEFS.h"
15
16ENTRY(strncat, 0)
17	tstl	12(fp)
18	jgtr	n_ok
19	movl	4(fp),r0
20	clrb	r0
21	ret
22n_ok:
23	movl	8(fp),r0
24	movl	r0,r1
25	cmps2			# r0 points at null at end of s2
26	subl3	8(fp),r0,r2	# r2 = numberof non-null chars in s2
27	cmpl	12(fp),r2
28	jgeq	r2_ok
29	movl	12(fp),r2	# r2 = min (n, length(s2))
30r2_ok:
31	movl	4(fp),r0
32	movl	r0,r1
33	cmps2			# r1 points at null at end of s1
34	movl	8(fp),r0	# source for copy
35	movs3			# actual copy
36	clrb	(r1)		# null terminated string !
37	movl	4(fp),r0
38	ret
39