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

  1. /*  File   : bmove.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 23 April 1984
  4.     Defines: bmove()
  5.  
  6.     bmove(dst, src, 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.     bmove(&to, &from, sizeof from);
  11.     The standard 4.2bsd routine for this purpose is bcopy.  But as bcopy
  12.     has its first two arguments the other way around you may find this a
  13.     bit easier to get right.
  14.     No value is returned.
  15.  
  16.     Note: the "b" routines are there to exploit certain VAX order codes,
  17.     but the MOVC3 instruction will only move 65535 characters.   The asm
  18.     code is presented for your interest and amusement.
  19. */
  20.  
  21. #include "strings.h"
  22.  
  23. #if    VaxAsm
  24.  
  25. void bmove(dst, src, len)
  26.     char *dst, *src;
  27.     int len;
  28.     {
  29.     asm("movc3 12(ap),*8(ap),*4(ap)");
  30.     }
  31.  
  32. #else  ~VaxAsm
  33.  
  34. void bmove(dst, src, len)
  35.     register char *dst, *src;
  36.     register int len;
  37.     {
  38.     while (--len >= 0) *dst++ = *src++;
  39.     }
  40.  
  41. #endif    VaxAsm
  42.