home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / WINER.ZIP / MEMCOPY.ASM < prev    next >
Assembly Source File  |  1992-05-13  |  966b  |  35 lines

  1. ;********* MEMCOPY.ASM - copies a block of memory from here to there
  2. ;
  3. ;Copyright (c) 1991 Ethan Winer
  4. ;
  5. ;
  6. ;Usage:
  7. ;
  8. ; CALL MemCopy(SEG Type1, SEG Type2, NumBytes%)
  9. ;or
  10. ; CALL MemCopy(BYVAL Seg1%, BYVAL Adr1%, BYVAL Seg2%, BYVAL Adr2%, NumBytes%)
  11.  
  12.  
  13. .Model Medium, Basic
  14. .Code
  15.  
  16. MemCopy Proc Uses DS ES SI DI, FromAdr:DWord, ToAdr:DWord, NumBytes:Word
  17.  
  18.   Cld                  ;copy in the forward direction
  19.  
  20.   Mov  SI,NumBytes     ;get the address for NumBytes%
  21.   Mov  CX,[SI]         ;put it into CX for copying below
  22.  
  23.   Les  DI,ToAdr        ;load ES:DI with the segmented destination address
  24.   Lds  SI,FromAdr      ;load DS:SI with the segmented source address
  25.  
  26.   Shr  CX,1            ;copy words instead of bytes for speed
  27.   Rep  Movsw           ;do the copy
  28.   Adc  CX,CX           ;this will set CX to either 0 or 1
  29.   Rep  Movsb           ;copy the odd byte if necessary
  30.  
  31.   Ret                  ;return to BASIC
  32.  
  33. MemCopy Endp
  34. End
  35.