]>
Commit | Line | Data |
---|---|---|
c5ecf6c1 | 1 | ;------------------------------------------------------------------------------\r |
2 | ;\r | |
3 | ; Copyright (c) 2006, Intel Corporation\r | |
4 | ; All rights reserved. This program and the accompanying materials\r | |
5 | ; are licensed and made available under the terms and conditions of the BSD License\r | |
6 | ; which accompanies this distribution. The full text of the license may be found at\r | |
7 | ; http://opensource.org/licenses/bsd-license.php\r | |
8 | ;\r | |
9 | ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | ;\r | |
12 | ; Module Name:\r | |
13 | ;\r | |
14 | ; CopyMem.asm\r | |
15 | ;\r | |
16 | ; Abstract:\r | |
17 | ;\r | |
18 | ; CopyMem function\r | |
19 | ;\r | |
20 | ; Notes:\r | |
21 | ;\r | |
22 | ;------------------------------------------------------------------------------\r | |
23 | \r | |
24 | .686\r | |
25 | .model flat,C\r | |
26 | .mmx\r | |
27 | .code\r | |
28 | \r | |
29 | ;------------------------------------------------------------------------------\r | |
30 | ; VOID *\r | |
31 | ; EFIAPI\r | |
32 | ; InternalMemCopyMem (\r | |
33 | ; IN VOID *Destination,\r | |
34 | ; IN VOID *Source,\r | |
35 | ; IN UINTN Count\r | |
36 | ; );\r | |
37 | ;------------------------------------------------------------------------------\r | |
38 | InternalMemCopyMem PROC USES esi edi\r | |
39 | mov esi, [esp + 16] ; esi <- Source\r | |
40 | mov edi, [esp + 12] ; edi <- Destination\r | |
41 | mov edx, [esp + 20] ; edx <- Count\r | |
42 | lea eax, [esi + edx - 1] ; eax <- End of Source\r | |
43 | cmp esi, edi\r | |
44 | jae @F\r | |
45 | cmp eax, edi ; Overlapped?\r | |
46 | jae @CopyBackward ; Copy backward if overlapped\r | |
47 | @@:\r | |
48 | mov ecx, edx\r | |
49 | and edx, 7\r | |
50 | shr ecx, 3 ; ecx <- # of Qwords to copy\r | |
51 | jz @CopyBytes\r | |
52 | push eax\r | |
53 | push eax\r | |
54 | movq [esp], mm0 ; save mm0\r | |
55 | @@:\r | |
56 | movq mm0, [esi]\r | |
57 | movq [edi], mm0\r | |
58 | add esi, 8\r | |
59 | add edi, 8\r | |
60 | loop @B\r | |
61 | movq mm0, [esp] ; restore mm0\r | |
62 | pop ecx ; stack cleanup\r | |
63 | pop ecx ; stack cleanup\r | |
64 | jmp @CopyBytes\r | |
65 | @CopyBackward:\r | |
66 | mov esi, eax ; esi <- Last byte in Source\r | |
67 | lea edi, [edi + edx - 1] ; edi <- Last byte in Destination\r | |
68 | std\r | |
69 | @CopyBytes:\r | |
70 | mov ecx, edx\r | |
71 | rep movsb\r | |
72 | cld\r | |
73 | mov eax, [esp + 12]\r | |
74 | ret\r | |
75 | InternalMemCopyMem ENDP\r | |
76 | \r | |
77 | END\r |