source: trunk/libs/newlib/src/newlib/libc/machine/i386/memcpy.S @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.2 KB
Line 
1/*
2 * ====================================================
3 * Copyright (C) 1998, 2002 by Red Hat Inc. 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       SOTYPE_FUNCTION(memcpy)
15
16SYM (memcpy):
17
18#ifdef __iamcu__
19        pushl esi
20        pushl edi
21        movl eax,edi
22        movl edx,esi
23
24        rep movsb
25
26        popl edi
27        popl esi
28#else
29        pushl ebp
30        movl esp,ebp
31        pushl esi
32        pushl edi
33        pushl ebx
34        movl 8(ebp),edi
35        movl 16(ebp),ecx
36        movl 12(ebp),esi
37        cld
38               
39#ifndef __OPTIMIZE_SIZE__
40               
41        cmpl $8,ecx
42        jbe .L3
43
44/* move any preceding bytes until destination address is long word aligned */
45               
46        movl edi,edx   
47        movl ecx,ebx
48        andl $3,edx
49        jz .L11
50        movl $4,ecx
51        subl edx,ecx
52        andl $3,ecx
53        subl ecx,ebx
54        rep
55        movsb
56       
57        mov ebx,ecx
58
59/* move bytes a long word at a time */
60               
61.L11:
62        shrl $2,ecx
63        .p2align 2
64        rep
65        movsl
66       
67        movl ebx,ecx
68        andl $3,ecx
69       
70#endif /* !__OPTIMIZE_SIZE__ */
71
72/* handle any remaining bytes */
73               
74.L3:           
75        rep
76        movsb
77.L5:           
78        movl 8(ebp),eax
79
80        leal -12(ebp),esp
81        popl ebx
82        popl edi
83        popl esi
84        leave
85#endif
86        ret
Note: See TracBrowser for help on using the repository browser.