|
|
1.1 root 1: .file "strcat.s"
2: # @(#)strcat.s 1.5
3: # Fast assembler language version of the following C-program
4: # strcat
5: # which represents the `standard' for the C-library.
6:
7: # Concatenate s2 on the end of s1. S1's space must be large enough.
8: # Return s1.
9:
10: # char *
11: # strcat(s1, s2)
12: # register char *s1, *s2;
13: # {
14: # register char *os1;
15: #
16: # os1 = s1;
17: # while (*s1++)
18: # ;
19: # --s1;
20: # while (*s1++ = *s2++)
21: # ;
22: # return(os1);
23: # }
24: .globl _strcat
25: .text
26: .align 2
27: _strcat:
28: .word 0x01c0 # uses regs. 0,1,2,3,4,5,6,7,8
29: movl $65535,r8 # constant used several times
30: movq 4(ap),r6 # dest. in r6, src. in r7
31: movl r6,r1 # working copy of dest.
32: L0:
33: locc $0,r8,(r1) # gotta find null in dest, so we
34: beql L0 # know where to start `copy-to'.
35: movl r1,r3 # set-up r3 for copy destination.
36: L1:
37: locc $0,r8,(r7) # try to find null in src.
38: bneq L2 # skip if null found -
39: movc3 r8,(r7),(r3) # else move a BLOCK of 65535 chars
40: movl r1,r7 # and adjust pointers to
41: jmp L1 # go back and try again
42: L2:
43: subl2 r7,r1 # length (but 1) of src.
44: incl r1 # adjust length to cover null
45: movc3 r1,(r7),(r3) # move string including null
46: movl r6,r0 # return destination ptr.
47: ret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.