]>
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 | ||
24 | .686: | |
25 | #.MODEL flat,C | |
26 | .xmm: | |
27 | .code: | |
28 | ||
29 | #------------------------------------------------------------------------------ | |
30 | # VOID * | |
31 | # _mem_CopyMem ( | |
32 | # IN VOID *Destination, | |
33 | # IN VOID *Source, | |
34 | # IN UINTN Count | |
35 | # ) | |
36 | #------------------------------------------------------------------------------ | |
37 | .global _InternalMemCopyMem | |
38 | _InternalMemCopyMem: | |
39 | push %esi | |
40 | push %edi | |
41 | movl 16(%esp), %esi # esi <- Source | |
42 | movl 12(%esp), %edi # edi <- Destination | |
43 | movl 20(%esp), %edx # edx <- Count | |
44 | leal -1(%edi,%edx,), %eax # eax <- End of Destination | |
45 | cmpl %edi, %esi | |
46 | jae L0 | |
47 | cmpl %esi, %eax # Overlapped? | |
48 | jae @CopyBackward # Copy backward if overlapped | |
49 | L0: | |
50 | xorl %ecx, %ecx | |
51 | subl %edi, %ecx | |
52 | andl $15, %ecx # ecx + edi aligns on 16-byte boundary | |
53 | jz L1 | |
54 | cmpl %edx, %ecx | |
55 | cmova %edx, %ecx | |
56 | subl %ecx, %edx # edx <- remaining bytes to copy | |
57 | rep | |
58 | movsb | |
59 | L1: | |
60 | movl %edx, %ecx | |
61 | andl $15, %edx | |
62 | shrl $4, %ecx # ecx <- # of DQwords to copy | |
63 | jz @CopyBytes | |
64 | addl $-16, %esp | |
65 | movdqu %xmm0, (%esp) | |
66 | L2: | |
67 | movdqu (%esi), %xmm0 | |
68 | movntdq %xmm0, (%edi) | |
69 | addl $16, %esi | |
70 | addl $16, %edi | |
71 | loop L2 | |
72 | mfence | |
73 | movdqu (%esp),%xmm0 | |
74 | addl $16, %esp # stack cleanup | |
75 | jmp @CopyBytes | |
76 | @CopyBackward: | |
77 | movl %eax, %edi # edi <- Last byte in Destination | |
78 | leal -1(%esi,%edx,), %esi # esi <- Last byte in Source | |
79 | std | |
80 | @CopyBytes: | |
81 | movl %edx, %ecx | |
82 | rep | |
83 | movsb | |
84 | cld | |
85 | movl 12(%esp), %eax # eax <- Destination as return value | |
86 | pop %edi | |
87 | pop %esi | |
88 | ret |