home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / c / string.arc / MEMCPY.C < prev    next >
Text File  |  1984-12-31  |  1KB  |  44 lines

  1. /*  File   : memcpy.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 25 May 1984
  4.     Defines: memcpy()
  5.  
  6.     memcpy(dst, src, len)
  7.     moves len bytes from src to dst.  The result is dst.  This is not
  8.     the same as strncpy or strnmov, while move a maximum of len bytes
  9.     and stop early if they hit a NUL character.  This moves len bytes
  10.     exactly, no more, no less.  See also bcopy() and bmove() which do
  11.     not return a value but otherwise do the same job.
  12.  
  13.     Note: the VAX assembly code version can only handle 0 <= len < 2^16.
  14.     It is presented for your interest and amusement.
  15. */
  16.  
  17. #include "strings.h"
  18.  
  19. #if    VaxAsm
  20.  
  21. char *memcpy(dst, src, len)
  22.     char *dst, *src;
  23.     int len;
  24.     {
  25.     asm("movc3 12(ap),*8(ap),*4(ap)");
  26.     return dst;
  27.     }
  28.  
  29. #else  ~VaxAsm
  30.  
  31. char *memcpy(dst, src, len)
  32.     char *dst;
  33.     register char *src;
  34.     register int len;
  35.     {
  36.     register char *d;
  37.  
  38.     for (d = dst; --len >= 0; *d++ = *src++) ;
  39.     return dst;
  40.     }
  41.  
  42. #endif    VaxAsm
  43.