Add VCS links
[debian-dgen.git] / x86_memcpy.asm
blob9345818f12eb533877cb20c59f1d4ea5c55270ba
1 bits 32
2 section .text
3 ;extern "C" int asm_memcpy
4 ; (unsigned char *dest, unsigned char *src, int len);
6 global asm_memcpy
8 times ($$-$) & 3 db 0
10 asm_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, 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
24 mov ecx,eax
26 rep movsd ; move 4 byte chunks
28 .slack:
29 pop ecx
30 rep movsb ; move 1 byte slack
32 popad ; clean up
33 ret
35 ; --------------------------------------
37 %ifdef NASM_STACK_NOEXEC
38 section .note.GNU-stack noalloc noexec nowrite progbits
39 %endif