Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. bits 32
  2. section .text
  3. ;extern "C" int asm_memcpy
  4. ;  (unsigned char *dest, unsigned char *src, int len);
  5.  
  6. global asm_memcpy
  7.  
  8. times ($$-$) & 3 db 0
  9.  
  10. asm_memcpy:
  11.  
  12. pushad                  ; save registers
  13. mov edi,[esp+36]        ; get 1st argument
  14. mov esi,[esp+40]        ; ...2nd
  15. mov eax,[esp+44]        ; ...3rd
  16.  
  17. mov edx, eax
  18. shr eax, 2              ; figure out how many 4 byte chunks we have
  19. and edx, 3              ; also figure out slack
  20. test eax, eax           ; Do we have any big chunks?
  21. push edx
  22. jz .slack               ; If not, just do slack
  23.  
  24. mov ecx,eax
  25.  
  26. rep movsd               ; move 4 byte chunks
  27.  
  28. .slack:
  29. pop ecx
  30. rep movsb               ; move 1 byte slack
  31.  
  32. popad                   ; clean up
  33. ret
  34.  
  35. ; --------------------------------------
  36.  
  37. %ifdef NASM_STACK_NOEXEC
  38. section .note.GNU-stack noalloc noexec nowrite progbits
  39. %endif
  40.