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

  1. /*  File   : bcopy.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 23 April 1984
  4.     Defines: bcopy()
  5.  
  6.     bcopy(src, dst, len) moves exactly "len" bytes from the source "src"
  7.     to the destination "dst".  It does not check for NUL characters as
  8.     strncpy() and strnmov() do.  Thus if your C compiler doesn't support
  9.     structure assignment, you can simulate it with
  10.     bcopy(&from, &to, sizeof from);
  11.     BEWARE: the first two arguments are the other way around from almost
  12.     everything else.   I'm sorry about that, but that's the way it is in
  13.     the 4.2bsd manual, though they list it as a bug.  For a version with
  14.     the arguments the right way around, use bmove().
  15.     No value is returned.
  16.  
  17.     Note: the "b" routines are there to exploit certain VAX order codes,
  18.     but the MOVC3 instruction will only move 65535 characters.   The asm
  19.     code is presented for your interest and amusement.
  20. */
  21.  
  22. #include "strings.h"
  23.  
  24. #if    VaxAsm
  25.  
  26. void bcopy(src, dst, len)
  27.     char *src, *dst;
  28.     int len;
  29.     {
  30.     asm("movc3 12(ap),*4(ap),*8(ap)");
  31.     }
  32.  
  33. #else  ~VaxAsm
  34.  
  35. void bcopy(src, dst, len)
  36.     register char *src, *dst;
  37.     register int len;
  38.     {
  39.     while (--len >= 0) *dst++ = *src++;
  40.     }
  41.  
  42. #endif    VaxAsm
  43.