1: /*
2: * Copyright (c) 1983 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: */
6:
7: #ifdef LIBC_SCCS
8: .asciz "@(#)strncat.s 5.3 (Berkeley) 3/9/86"
9: #endif LIBC_SCCS
10:
11: /*
12: * Concatenate string s2 on the end of s1
13: * and return the base of s1. The parameter
14: * n is the maximum length of string s2 to
15: * concatenate.
16: *
17: * char *
18: * strncat(s1, s2, n)
19: * char *s1, *s2;
20: * int n;
21: */
22: #include "DEFS.h"
23:
24: ENTRY(strncat, R6)
25: movl 12(ap),r6 # r6 = n
26: bleq done # n <= 0
27: movl 4(ap),r3 # r3 = s1
28: movl r3,r1
29: 0:
30: locc $0,$65535,(r1)
31: beql 0b
32: movl r1,r3 # r3 = index(s1, '\0');
33: movl 8(ap),r1 # r1 = s2
34: 1:
35: movzwl $65535,r2 # r2 = bytes in first chunk
36: cmpl r6,r2 # r2 = min(bytes in chunk, n);
37: jgeq 2f
38: movl r6,r2
39: 2:
40: subl2 r2,r6 # update n
41: locc $0,r2,(r1) # '\0' found?
42: jneq 3f
43: subl2 r2,r1 # back up pointer updated by locc
44: movc3 r2,(r1),(r3) # copy in next piece
45: tstl r6 # run out of space?
46: jneq 1b
47: clrb (r3) # force '\0' termination
48: jbr done
49: 3:
50: subl2 r0,r2 # r2 = number of bytes to move
51: subl2 r2,r1 # back up pointer updated by locc
52: incl r2 # copy '\0' as well
53: movc3 r2,(r1),(r3) # copy in last piece
54: done:
55: movl 4(ap),r0 # return s1
56: ret
Defined functions
done
defined in line
54; used 2 times