Commit | Line | Data |
---|---|---|
586c39b1 DF |
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 | #ifndef lint | |
7f0e38f0 | 8 | .asciz "@(#)strcat.s 5.2 (Berkeley) %G%" |
586c39b1 | 9 | #endif not lint |
3d55afdc SL |
10 | |
11 | /* | |
12 | * Concatenate string s2 to the end of s1 | |
13 | * and return the base of s1. | |
14 | * | |
15 | * char * | |
16 | * strcat(s1, s2) | |
17 | * char *s1, *s2; | |
18 | */ | |
dadab5a2 | 19 | #include "DEFS.h" |
3d55afdc | 20 | |
dadab5a2 | 21 | ENTRY(strcat, R6|R7) |
3d55afdc SL |
22 | movq 4(ap), r6 # r6 = s1; r7 = s2 |
23 | movl r6,r1 | |
24 | 0: | |
25 | locc $0,$65535,(r1) # look for '\0' | |
26 | beql 0b | |
27 | movl r1,r3 # save end of s1 | |
28 | 1: | |
29 | locc $0,$65535,(r7) # find length of s2 | |
30 | bneq 2f | |
31 | movc3 $65535,(r7),(r3)# copy full block | |
32 | movl r1,r7 | |
33 | jbr 1b | |
34 | 2: | |
35 | subl2 r7,r1 # calculate length | |
36 | incl r1 | |
37 | movc3 r1,(r7),(r3) # copy remainder | |
38 | movl r6,r0 | |
39 | ret |