]>
Commit | Line | Data |
---|---|---|
b6bd81d4 | 1 | #------------------------------------------------------------------------------ |
2 | # | |
3 | # Copyright (c) 2006, Intel Corporation | |
4 | # All rights reserved. This program and the accompanying materials | |
5 | # are licensed and made available under the terms and conditions of the BSD License | |
6 | # which accompanies this distribution. The full text of the license may be found at | |
7 | # http://opensource.org/licenses/bsd-license.php | |
8 | # | |
9 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | |
10 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | |
11 | # | |
12 | # Module Name: | |
13 | # | |
14 | # CopyMem.Asm | |
15 | # | |
16 | # Abstract: | |
17 | # | |
18 | # CopyMem function | |
19 | # | |
20 | # Notes: | |
21 | # | |
22 | #------------------------------------------------------------------------------ | |
23 | ||
24 | .386: | |
25 | .code: | |
26 | ||
37867477 | 27 | .global _InternalMemCopyMem |
28 | _InternalMemCopyMem: | |
b6bd81d4 | 29 | push %esi |
30 | push %edi | |
31 | movl 16(%esp),%esi # esi <- Source | |
32 | movl 12(%esp),%edi # edi <- Destination | |
33 | movl 20(%esp),%edx # edx <- Count | |
34 | leal -1(%edi,%edx),%eax # eax <- End of Destination | |
35 | cmpl %edi,%esi | |
36 | jae L0 | |
37 | cmpl %esi,%eax | |
38 | jae @CopyBackward # Copy backward if overlapped | |
39 | L0: | |
40 | movl %edx,%ecx | |
41 | andl $3,%edx | |
42 | shrl $2,%ecx | |
43 | rep | |
44 | movsl # Copy as many Dwords as possible | |
45 | jmp @CopyBytes | |
46 | @CopyBackward: | |
47 | movl %eax,%edi # edi <- End of Destination | |
48 | leal -1(%esi,%edx),%esi # esi <- End of Source | |
49 | std | |
50 | @CopyBytes: | |
51 | movl %edx,%ecx | |
52 | rep | |
53 | movsb # Copy bytes backward | |
54 | cld | |
55 | movl 12(%esp),%eax # eax <- Destination as return value | |
56 | push %edi | |
57 | push %esi | |
58 | ret |