Add VCS links
[debian-dgen.git] / x86_mmx_memcpy.asm
blob0f66e950fa21f5e501d9e9475878e3b98a942e44
1 bits 32
2 section .text
3 ;extern "C" int mmx_memcpy
4 ; (unsigned char *dest, unsigned char *src, int len);
6 global mmx_memcpy
8 times ($$-$) & 3 db 0
10 mmx_memcpy:
12 pushad ; save registers
13 mov edi,[esp+36] ; get 1st argument
14 mov esi,[esp+40] ; ...2nd
15 mov eax,[esp+44] ; ...3rd
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
24 mov ecx,eax
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
33 .slack:
34 pop ecx
35 rep movsb ; move 1 byte slack
37 emms ; Free up for the FPU
39 popad ; clean up
40 ret
42 ; --------------------------------------
44 %ifdef NASM_STACK_NOEXEC
45 section .note.GNU-stack noalloc noexec nowrite progbits
46 %endif