home *** CD-ROM | disk | FTP | other *** search
/ Groovy Bytes: Behind the Moon / groovybytes.iso / GROOVY / SND_TOOL / FUNK108A.ZIP / DOS32V30.ZIP / PAL / VARIOUS / MEMMOVE.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-05-20  |  1.6 KB  |  53 lines

  1. ;*****************************************************************************
  2. ; Filename: MEMMOVE.ASM
  3. ;   Author: Peter Andersson
  4. ;  Version: 0.0
  5. ;  Created: 1995.April.28
  6. ;  Updated: -
  7. ;*****************************************************************************
  8. ; Copyright Peter Andersson, 1994-1995.
  9. ; All rights reserved.
  10. ;*****************************************************************************
  11. ; Function: VOID @memmove(PVOID *src,PVOID *dest,ULONG length);
  12. ;  Comment: Moves a memory block and will always correctly copy even if
  13. ;           source and destination overlap.
  14. ;    Input: Eax - pointer to destination
  15. ;           Edx - pointer to source
  16. ;           Ecx - length to copy
  17. ;  Returns: pointer of detination (Edx)
  18. ;*****************************************************************************
  19.  
  20.     Include    STDDEF.INC
  21.  
  22.     Codeseg            ; Change memory model in the STDDEF.INC
  23.  
  24. Proc    memmove  ,3
  25.                 Push    Edi Esi Eax
  26.         TestZ    Ecx
  27.         jz    @@End
  28.                 Cmp    Eax,Edx
  29.                 je      @@End
  30.                 Cld
  31.                 Mov    Edi,Eax
  32.                 Mov    Esi,Edx            
  33.                 Cmp    Edi,Esi
  34.                 Jb      @@forward
  35.                 Std
  36.                 Lea     Edi,[Edi+Ecx-1]
  37.                 Lea     Esi,[Esi+Ecx-1]
  38. @@forward:
  39. ;                Mov     Dl,Cl
  40. ;                Shr     Ecx,2
  41. ;                Jz      @@Next01
  42. ;                Rep     Movsd
  43. ;@@Next01:       And     Dl,03h
  44. ;                jz      @@End
  45. ;                Mov     Cl,Dl
  46.                 Rep     Movsb
  47. @@End:         
  48.                 Pop Eax Esi Edi
  49.                 Ret
  50. Endp
  51.  
  52.     End
  53.