OSDN Git Service

Initial revision
[pf3gnuchains/pf3gnuchains3x.git] / newlib / libc / machine / i386 / memcpy.S
1 /*
2  * ====================================================
3  * Copyright (C) 1998 by Cygnus Solutions. All rights reserved.
4  *
5  * Permission to use, copy, modify, and distribute this
6  * software is freely granted, provided that this notice
7  * is preserved.
8  * ====================================================
9  */
10
11         #include "i386mach.h"
12         
13         .global SYM (memcpy)
14
15 SYM (memcpy):
16
17         pushl ebp
18         movl esp,ebp
19         pushl esi
20         pushl edi
21         pushl ebx
22         movl 8(ebp),edi
23         movl 16(ebp),ecx
24         movl 12(ebp),esi
25         cld
26                 
27 #ifndef __OPTIMIZE_SIZE__
28                 
29         cmpl $8,ecx
30         jbe .L3
31
32 /* move any preceding bytes until destination address is long word aligned */
33                 
34         movl edi,edx    
35         movl ecx,ebx
36         andl $3,edx
37         jz .L11
38         movl $4,ecx
39         subl edx,ecx
40         andl $3,ecx
41         subl ecx,ebx
42         rep
43         movsb
44         
45         mov ebx,ecx
46
47 /* move bytes a long word at a time */
48                 
49 .L11:
50         shrl $2,ecx
51         .p2align 2
52         rep
53         movsl
54         
55         movl ebx,ecx
56         andl $3,ecx
57         
58 #endif /* !__OPTIMIZE_SIZE__ */
59
60 /* handle any remaining bytes */
61                 
62 .L3:            
63         rep
64         movsb
65 .L5:            
66         movl 8(ebp),eax
67
68         leal -12(ebp),esp
69         popl ebx
70         popl edi
71         popl esi
72         leave
73         ret