Import Upstream version 1.23
[debian-dgen.git] / asm_memcpy.asmu
blobaeb7489567aa01f5eee5a2d9bf3894ebdefd0224
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 ; --------------------------------------