FreeBSD/Linux Kernel Cross Reference
sys/osfmk/i386/bcopy.s
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * @OSF_COPYRIGHT@
27 */
28 /*
29 * Mach Operating System
30 * Copyright (c) 1991,1990 Carnegie Mellon University
31 * All Rights Reserved.
32 *
33 * Permission to use, copy, modify and distribute this software and its
34 * documentation is hereby granted, provided that both the copyright
35 * notice and this permission notice appear in all copies of the
36 * software, derivative works or modified versions, and any portions
37 * thereof, and that both notices appear in supporting documentation.
38 *
39 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
40 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
41 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
42 *
43 * Carnegie Mellon requests users of this software to return to
44 *
45 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
46 * School of Computer Science
47 * Carnegie Mellon University
48 * Pittsburgh PA 15213-3890
49 *
50 * any improvements or extensions that they make and grant Carnegie Mellon
51 * the rights to redistribute these changes.
52 */
53 /*
54 */
55
56 #include <i386/asm.h>
57
58 /* void *memcpy((void *) to, (const void *) from, (size_t) bcount) */
59
60 ENTRY(memcpy)
61 pushl %edi
62 pushl %esi
63 movl 8+ 4(%esp),%edi /* to */
64 movl %edi,%eax /* returns its first argument */
65 movl 8+ 8(%esp),%esi /* from */
66 memcpy_common:
67 movl 8+ 12(%esp),%edx /* number of bytes */
68 cld
69 /* move longs*/
70 movl %edx,%ecx
71 sarl $2,%ecx
72 rep
73 movsl
74 /* move bytes*/
75 movl %edx,%ecx
76 andl $3,%ecx
77 rep
78 movsb
79 popl %esi
80 popl %edi
81 ret
82
83 /* void bcopy((const char *) from, (char *) to, (unsigned int) count) */
84
85 ENTRY(bcopy_no_overwrite)
86 pushl %edi
87 pushl %esi
88 movl 8+ 8(%esp),%edi /* to */
89 movl 8+ 4(%esp),%esi /* from */
90 jmp memcpy_common
91
92 /* bcopy16(from, to, bcount) using word moves */
93
94 ENTRY(bcopy16)
95 pushl %edi
96 pushl %esi
97 movl 8+12(%esp),%edx /* 8 for the two pushes above */
98 movl 8+ 8(%esp),%edi
99 movl 8+ 4(%esp),%esi
100 /* move words */
101 0: cld
102 movl %edx,%ecx
103 sarl $1,%ecx
104 rep
105 movsw
106 /* move bytes */
107 movl %edx,%ecx
108 andl $1,%ecx
109 rep
110 movsb
111 popl %esi
112 popl %edi
113 ret
114
Cache object: 75fa0b16032a8fda5c8ba0829d7e9760
|