]>
Commit | Line | Data |
---|---|---|
c7f33ca4 | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2007, 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 | EfiCopyMemRep1.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | This is the code that uses rep movsb CopyMem service\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #include "Tiano.h"\r | |
23 | \r | |
24 | VOID\r | |
25 | EfiCommonLibCopyMem (\r | |
26 | IN VOID *Destination,\r | |
27 | IN VOID *Source,\r | |
28 | IN UINTN Count\r | |
29 | )\r | |
30 | /*++\r | |
31 | \r | |
32 | Routine Description:\r | |
33 | \r | |
34 | Copy Length bytes from Source to Destination.\r | |
35 | \r | |
36 | Arguments:\r | |
37 | \r | |
38 | Destination - Target of copy\r | |
39 | \r | |
40 | Source - Place to copy from\r | |
41 | \r | |
42 | Length - Number of bytes to copy\r | |
43 | \r | |
44 | Returns:\r | |
45 | \r | |
46 | None\r | |
47 | \r | |
48 | --*/\r | |
49 | {\r | |
50 | __asm {\r | |
51 | mov esi, Source ; esi <- Source\r | |
52 | mov edi, Destination ; edi <- Destination\r | |
53 | mov edx, Count ; edx <- Count\r | |
54 | cmp esi, edi\r | |
55 | je _CopyDone\r | |
56 | cmp edx, 0\r | |
57 | je _CopyDone\r | |
58 | lea eax, [esi + edx - 1] ; eax <- End of Source\r | |
59 | cmp esi, edi\r | |
60 | jae _CopyBytes\r | |
61 | cmp eax, edi\r | |
62 | jb _CopyBytes ; Copy backward if overlapped\r | |
63 | mov esi, eax ; esi <- End of Source\r | |
64 | lea edi, [edi + edx - 1] ; edi <- End of Destination\r | |
65 | std\r | |
66 | _CopyBytes:\r | |
67 | mov ecx, edx\r | |
68 | rep movsb ; Copy bytes backward\r | |
69 | cld\r | |
70 | _CopyDone:\r | |
71 | }\r | |
72 | }\r | |
73 | \r |