Commit | Line | Data |
---|---|---|
f15e832d KB |
1 | /* |
2 | * Copyright (c) 1988 Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
019bea33 | 5 | * %sccs.include.redist.c% |
4afb9d15 | 6 | * |
f15e832d KB |
7 | * This code is derived from software contributed to Berkeley by |
8 | * Computer Consoles Inc. | |
f15e832d KB |
9 | */ |
10 | ||
11 | #if defined(LIBC_SCCS) && !defined(lint) | |
019bea33 | 12 | .asciz "@(#)strncat.s 1.5 (Berkeley) %G%" |
f15e832d | 13 | #endif /* LIBC_SCCS and not lint */ |
a3fc73ba SL |
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 | ||
26 | ENTRY(strncat, 0) | |
27 | tstl 12(fp) | |
28 | jgtr n_ok | |
29 | movl 4(fp),r0 | |
a3fc73ba SL |
30 | ret |
31 | n_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)) | |
39 | r2_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 |