|
|
1.1 ! root 1: .file "strcpy.s" ! 2: # @(#)strcpy.s 1.5 ! 3: # Fast assembler language version of the following C-program ! 4: # strcpy ! 5: # which represents the `standard' for the C-library. ! 6: ! 7: # Copy string s2 to s1. s1 must be large enough. Return s1. ! 8: ! 9: # char * ! 10: # strcpy(s1, s2) ! 11: # register char *s1, *s2; ! 12: # { ! 13: # register char *os1; ! 14: # ! 15: # os1 = s1; ! 16: # while (*s1++ = *s2++) ! 17: # ; ! 18: # return(os1); ! 19: # } ! 20: .globl _strcpy ! 21: .text ! 22: .align 2 ! 23: _strcpy: ! 24: .word 0x00c0 # use regs. 0,1,2,3,4,5,6,7 ! 25: movq 4(ap),r6 # dest. in r6, src. in r7 ! 26: movl r6,r3 # working copy of dest. in r3 ! 27: L0: ! 28: locc $0,$65535,(r7) # try to find null in src. ! 29: bneq L1 # skip if null found - ! 30: movc3 $65535,(r7),(r3) # else move BLOCK of chars ! 31: movl r1,r7 # and adjust pointers to ! 32: jmp L0 # go back and try again ! 33: L1: ! 34: subl2 r7,r1 # length (but 1) of src. ! 35: incl r1 # adjust length to cover null ! 36: movc3 r1,(r7),(r3) # move string including null ! 37: movl r6,r0 # return dest. ! 38: ret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.