|
|
1.1 ! root 1: .file "memcpy.s" ! 2: # @(#)memcpy.s 1.5 ! 3: # Fast assembler language version of the following C-program ! 4: # memcpy ! 5: # which represents the `standard' for the C-library. ! 6: ! 7: # Copy s2 to s1, always copy n bytes. ! 8: # Return s1 ! 9: ! 10: # char * ! 11: # memcpy(s1, s2, n) ! 12: # register char *s1, *s2; ! 13: # register int n; ! 14: # { ! 15: # register char *os1 = s1; ! 16: # ! 17: # while (--n >= 0) ! 18: # *s1++ = *s2++; ! 19: # return (os1); ! 20: # } ! 21: .globl _memcpy ! 22: .text ! 23: .align 2 ! 24: _memcpy: ! 25: .word 0x0040 # uses regs. 0,1,2,3,4,5,6 ! 26: movl 12(ap),r6 # length (arg `n') ! 27: bleq L2 # n <= 0, so return now! ! 28: movq 4(ap),r3 # dest ptr s1 ! 29: movl r4,r1 # src ptr s2 ! 30: L0: ! 31: cmpl $65535,r6 # is len VERY large? ! 32: bgeq L1 # hop if not ! 33: movc3 $65535,(r1),(r3) # Move n bytes ! 34: subl2 $65535,r6 ! 35: jbr L0 # go move some more string ! 36: L1: ! 37: movc3 r6,(r1),(r3) # Move n bytes ! 38: L2: ! 39: movl 4(ap),r0 # we're done - return s1 ! 40: ret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.