FreeBSD/Linux Kernel Cross Reference
sys/i386/bcopy.s
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: bcopy.s,v $
29 * Revision 2.6 93/02/04 07:55:39 danner
30 * Convert asm comment "/" over to "/ *" "* /"
31 * [93/01/27 rvb]
32 *
33 * Revision 2.5 91/05/14 16:03:58 mrt
34 * Correcting copyright
35 *
36 * Revision 2.4 91/02/05 17:10:49 mrt
37 * Changed to new Mach copyright
38 * [91/02/01 17:30:41 mrt]
39 *
40 * Revision 2.3 90/11/05 14:26:58 rpd
41 * Introduce bcopy16. For 16bit copies to bus memory
42 * [90/11/02 rvb]
43 *
44 * Revision 2.2 90/05/03 15:24:53 dbg
45 * From Bob Baron.
46 * [90/04/30 dbg]
47 *
48 */
49
50 #include <i386/asm.h>
51
52 /* bcopy(from, to, bcount) */
53
54 ENTRY(bcopy)
55 pushl %ebp
56 movl %esp,%ebp
57 pushl %edi
58 pushl %esi
59 movl B_ARG0,%esi
60 movl B_ARG1,%edi
61 bcopy_common:
62 movl B_ARG2,%edx
63 cld
64 /* move longs */
65 movl %edx,%ecx
66 sarl $2,%ecx
67 rep
68 movsl
69 /* move bytes */
70 movl %edx,%ecx
71 andl $3,%ecx
72 rep
73 movsb
74 popl %esi
75 popl %edi
76 leave
77 ret
78
79
80 /* memcpy(to, from, count) */
81
82 ENTRY(memcpy)
83 pushl %ebp
84 movl %esp,%ebp
85 pushl %edi
86 pushl %esi
87 movl B_ARG0,%edi
88 movl B_ARG1,%esi
89 jmp bcopy_common
90
91 /* bcopy16(from, to, bcount) using word moves */
92
93 ENTRY(bcopy16)
94 pushl %ebp
95 movl %esp,%ebp
96 pushl %edi
97 pushl %esi
98 /* movl 8+12(%esp),%edx / 8 for the two pushes above */
99 /* movl 8+ 8(%esp),%edi */
100 /* movl 8+ 4(%esp),%esi */
101 movl B_ARG2, %edx
102 movl B_ARG1, %edi
103 movl B_ARG0, %esi
104 /* move words */
105 0: cld
106 movl %edx,%ecx
107 sarl $1,%ecx
108 rep
109 movsw
110 /* move bytes */
111 movl %edx,%ecx
112 andl $1,%ecx
113 rep
114 movsb
115 popl %esi
116 popl %edi
117 leave
118 ret
119
Cache object: 9b31fa607e7de3bbc746173e0e94f96e
|