home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / MOVEDATA.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  1.7 KB  |  59 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - movedata.cas
  3.  *
  4.  * function(s)
  5.  *        movedata - copy bytes
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #pragma  inline
  18. #include <mem.h>
  19. #include <dos.h>
  20.  
  21. /*-----------------------------------------------------------------------*
  22.  
  23. Name            movedata - copy bytes
  24.  
  25. Usage           void movedata(unsigned srcseg, unsigned srcoff,
  26.                               unsigned dstseg, unsigned dstoff, size_t n);
  27.  
  28. Prototype in    mem.h & string.h
  29.  
  30. Description     Copy of  n bytes from the  source address(srcseg:secoff) to
  31.                 the destination address  (dstseg:dstoff) without checks and
  32.                 as fast as possible. If the src and dst arrays overlap, the
  33.                 effect is not defined.
  34.  
  35.                 Movedata is meant to be used to move far data in small data
  36.                 programs.  In  large  model  programs,  you  can use memcpy
  37.                 instead.
  38.  
  39. Return value    There is no return value
  40.  
  41. *------------------------------------------------------------------------*/
  42. void _FARFUNC movedata(unsigned srcseg, unsigned srcoff,
  43.               unsigned dstseg, unsigned dstoff, size_t n)
  44. {
  45. asm     cld
  46. asm     mov     cx,n
  47. asm     mov     di,dstoff
  48. asm     mov     es,dstseg
  49. asm     mov     si,srcoff
  50. asm     push    ds
  51. asm     mov     ds,srcseg
  52. asm     shr     cx,1
  53. asm     rep     movsw
  54. asm     jnc     mvd_end
  55. asm     movsb
  56. mvd_end:
  57. asm     pop     ds
  58. }
  59.