home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / MOVEDATA.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  1.9 KB  |  62 lines

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