xref: /csrg-svn/lib/libc/tahoe/string/strncat.s (revision 61190)
134438Sbostic/*
2*61190Sbostic * Copyright (c) 1988, 1993
3*61190Sbostic *	The Regents of the University of California.  All rights reserved.
434438Sbostic *
542644Sbostic * %sccs.include.redist.c%
634824Sbostic *
734438Sbostic * This code is derived from software contributed to Berkeley by
834438Sbostic * Computer Consoles Inc.
934438Sbostic */
1029700Ssam
1134438Sbostic#if defined(LIBC_SCCS) && !defined(lint)
12*61190Sbostic	.asciz "@(#)strncat.s	8.1 (Berkeley) 06/04/93"
1334438Sbostic#endif /* LIBC_SCCS and not lint */
1434438Sbostic
1529700Ssam/*
1629700Ssam * Concatenate s2 on the end of s1.  S1's space must be large enough.
1729700Ssam * At most n characters are moved.
1829700Ssam * Return s1.
1929700Ssam *
2029700Ssam * char *strncat(s1, s2, n)
2129700Ssam * register char *s1, *s2;
2229700Ssam * register n;
2329700Ssam */
2429700Ssam#include "DEFS.h"
2529700Ssam
2629700SsamENTRY(strncat, 0)
2729700Ssam	tstl	12(fp)
2829700Ssam	jgtr	n_ok
2929700Ssam	movl	4(fp),r0
3029700Ssam	ret
3129700Ssamn_ok:
3229700Ssam	movl	8(fp),r0
3329700Ssam	movl	r0,r1
3429700Ssam	cmps2			# r0 points at null at end of s2
3529700Ssam	subl3	8(fp),r0,r2	# r2 = numberof non-null chars in s2
3629700Ssam	cmpl	12(fp),r2
3729700Ssam	jgeq	r2_ok
3829700Ssam	movl	12(fp),r2	# r2 = min (n, length(s2))
3929700Ssamr2_ok:
4029700Ssam	movl	4(fp),r0
4129700Ssam	movl	r0,r1
4229700Ssam	cmps2			# r1 points at null at end of s1
4329700Ssam	movl	8(fp),r0	# source for copy
4429700Ssam	movs3			# actual copy
4529700Ssam	clrb	(r1)		# null terminated string !
4629700Ssam	movl	4(fp),r0
4729700Ssam	ret
48