Mostly minor updates to the source tree for portcls.
[reactos.git] / reactos / lib / string / i386 / memcpy_asm.s
1 /*
2 * void *memcpy (void *to, const void *from, size_t count)
3 *
4 * Some optimization research can be found in media/doc/memcpy_optimize.txt
5 */
6
7 .globl _memcpy
8
9 _memcpy:
10 push %ebp
11 mov %esp,%ebp
12 push %esi
13 push %edi
14 mov 0x8(%ebp),%edi
15 mov 0xc(%ebp),%esi
16 mov 0x10(%ebp),%ecx
17 cld
18 cmp $16,%ecx
19 jb .L1
20 mov %ecx,%edx
21 test $3,%edi
22 je .L2
23 /*
24 * Make the destination dword aligned
25 */
26 mov %edi,%ecx
27 and $3,%ecx
28 sub $5,%ecx
29 not %ecx
30 sub %ecx,%edx
31 rep movsb
32 mov %edx,%ecx
33 .L2:
34 shr $2,%ecx
35 rep movsl
36 mov %edx,%ecx
37 and $3,%ecx
38 .L1:
39 test %ecx,%ecx
40 je .L3
41 rep movsb
42 .L3:
43 pop %edi
44 pop %esi
45 mov 0x8(%ebp),%eax
46 leave
47 ret
48