]>
Commit | Line | Data |
---|---|---|
6e3b8c47 | 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 | ||
b7089db1 | 24 | .globl _InternalMemCopyMem |
6e3b8c47 | 25 | |
26 | #------------------------------------------------------------------------------ | |
27 | # VOID * | |
eb227e96 | 28 | # EFIAPI |
29 | # InternalMemCopyMem ( | |
6e3b8c47 | 30 | # IN VOID *Destination, |
31 | # IN VOID *Source, | |
32 | # IN UINTN Count | |
eb227e96 | 33 | # ); |
6e3b8c47 | 34 | #------------------------------------------------------------------------------ |
6e3b8c47 | 35 | _InternalMemCopyMem: |
36 | push %esi | |
37 | push %edi | |
38 | movl 16(%esp), %esi # esi <- Source | |
39 | movl 12(%esp), %edi # edi <- Destination | |
40 | movl 20(%esp), %edx # edx <- Count | |
eb227e96 | 41 | leal -1(%esi,%edx,), %eax # eax <- End of Source |
6e3b8c47 | 42 | cmpl %edi, %esi |
43 | jae L0 | |
eb227e96 | 44 | cmpl %edi, %eax # Overlapped? |
b7089db1 | 45 | jae L_CopyBackward # Copy backward if overlapped |
eb227e96 | 46 | L0: |
6e3b8c47 | 47 | xorl %ecx, %ecx |
48 | subl %esi, %ecx | |
49 | andl $7, %ecx # ecx + esi aligns on 8-byte boundary | |
50 | jz L1 | |
51 | cmpl %edx, %ecx | |
52 | cmova %edx, %ecx | |
53 | subl %ecx, %edx # edx <- remaining bytes to copy | |
54 | rep | |
55 | movsb | |
eb227e96 | 56 | L1: |
6e3b8c47 | 57 | movl %edx, %ecx |
58 | andl $7, %edx | |
59 | shrl $3, %ecx # ecx <- # of Qwords to copy | |
b7089db1 | 60 | jz L_CopyBytes |
6e3b8c47 | 61 | pushl %eax |
62 | pushl %eax | |
63 | movq %mm0, (%esp) # save mm0 | |
eb227e96 | 64 | L2: |
6e3b8c47 | 65 | movq (%esi), %mm0 |
eb227e96 | 66 | movq %mm0, (%edi) |
6e3b8c47 | 67 | addl $8, %esi |
68 | addl $8, %edi | |
69 | loop L2 | |
6e3b8c47 | 70 | movq (%esp), %mm0 # restore mm0 |
71 | popl %ecx # stack cleanup | |
72 | popl %ecx # stack cleanup | |
b7089db1 | 73 | jmp L_CopyBytes |
74 | L_CopyBackward: | |
eb227e96 | 75 | movl %eax, %esi # esi <- Last byte in Source |
76 | leal -1(%edi,%edx,), %edi # edi <- Last byte in Destination | |
6e3b8c47 | 77 | std |
b7089db1 | 78 | L_CopyBytes: |
6e3b8c47 | 79 | movl %edx, %ecx |
80 | rep | |
81 | movsb | |
82 | cld | |
83 | movl 12(%esp), %eax | |
f23c214d | 84 | pop %edi |
85 | pop %esi | |
6e3b8c47 | 86 | ret |