Subversion Repositories Kolibri OS

Rev

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

  1. bits 32
  2. section .text
  3. ;extern "C" int mmx_memcpy
  4. ;  (unsigned char *dest, unsigned char *src, int len);
  5.  
  6. global mmx_memcpy
  7.  
  8. times ($$-$) & 3 db 0
  9.  
  10. mmx_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, byte 3         ; figure out how many 8 byte chunks we have
  19. and edx, byte 7         ; also figure out slack
  20. test eax, eax           ; Do we have any big chunks?
  21. push edx
  22. jz .slack               ; If not, let's just do slack
  23.  
  24. mov ecx,eax
  25.  
  26. .mmx_move:
  27.   movq mm0,qword[esi]   ; move 8 byte blocks using MMX
  28.   movq qword[edi],mm0
  29.   add esi, byte 8       ; increment pointers
  30.   add edi, byte 8
  31. loopnz .mmx_move        ; continue until CX=0
  32.  
  33. .slack:
  34. pop ecx
  35. rep movsb               ; move 1 byte slack
  36.  
  37. emms                    ; Free up for the FPU
  38.  
  39. popad                   ; clean up
  40. ret
  41.  
  42. ; --------------------------------------
  43.  
  44. %ifdef NASM_STACK_NOEXEC
  45. section .note.GNU-stack noalloc noexec nowrite progbits
  46. %endif
  47.