1/* 2 * Copyright (c) 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Computer Consoles Inc. 9 */ 10 11#if defined(LIBC_SCCS) && !defined(lint) 12 .asciz "@(#)strncat.s 8.1 (Berkeley) 06/04/93" 13#endif /* LIBC_SCCS and not lint */ 14 15/* 16 * Concatenate s2 on the end of s1. S1's space must be large enough. 17 * At most n characters are moved. 18 * Return s1. 19 * 20 * char *strncat(s1, s2, n) 21 * register char *s1, *s2; 22 * register n; 23 */ 24#include "DEFS.h" 25 26ENTRY(strncat, 0) 27 tstl 12(fp) 28 jgtr n_ok 29 movl 4(fp),r0 30 ret 31n_ok: 32 movl 8(fp),r0 33 movl r0,r1 34 cmps2 # r0 points at null at end of s2 35 subl3 8(fp),r0,r2 # r2 = numberof non-null chars in s2 36 cmpl 12(fp),r2 37 jgeq r2_ok 38 movl 12(fp),r2 # r2 = min (n, length(s2)) 39r2_ok: 40 movl 4(fp),r0 41 movl r0,r1 42 cmps2 # r1 points at null at end of s1 43 movl 8(fp),r0 # source for copy 44 movs3 # actual copy 45 clrb (r1) # null terminated string ! 46 movl 4(fp),r0 47 ret 48