]>
Commit | Line | Data |
---|---|---|
b1ff428c | 1 | #\r |
2 | # ConvertAsm.py: Automatically generated from CopyMem.asm\r | |
3 | #\r | |
4 | #------------------------------------------------------------------------------\r | |
5 | #\r | |
373ade0e | 6 | # Copyright (c) 2006 - 2008, Intel Corporation\r |
b1ff428c | 7 | # All rights reserved. This program and the accompanying materials\r |
8 | # are licensed and made available under the terms and conditions of the BSD License\r | |
9 | # which accompanies this distribution. The full text of the license may be found at\r | |
10 | # http://opensource.org/licenses/bsd-license.php\r | |
11 | #\r | |
12 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | #\r | |
15 | # Module Name:\r | |
16 | #\r | |
17 | # CopyMem.S\r | |
18 | #\r | |
19 | # Abstract:\r | |
20 | #\r | |
21 | # CopyMem function\r | |
22 | #\r | |
23 | # Notes:\r | |
24 | #\r | |
25 | #------------------------------------------------------------------------------\r | |
26 | \r | |
27 | \r | |
28 | #------------------------------------------------------------------------------\r | |
29 | # VOID *\r | |
30 | # EFIAPI\r | |
31 | # InternalMemCopyMem (\r | |
32 | # IN VOID *Destination,\r | |
33 | # IN VOID *Source,\r | |
34 | # IN UINTN Count\r | |
35 | # )\r | |
36 | #------------------------------------------------------------------------------\r | |
37 | .intel_syntax noprefix\r | |
38 | .globl ASM_PFX(InternalMemCopyMem)\r | |
39 | ASM_PFX(InternalMemCopyMem):\r | |
40 | push rsi\r | |
41 | push rdi\r | |
42 | mov rsi, rdx # rsi <- Source\r | |
43 | mov rdi, rcx # rdi <- Destination\r | |
44 | lea r9, [rsi + r8 - 1] # r9 <- End of Source\r | |
45 | cmp rsi, rdi\r | |
46 | mov rax, rdi # rax <- Destination as return value\r | |
47 | jae L0\r | |
48 | cmp r9, rdi\r | |
49 | jae L_CopyBackward # Copy backward if overlapped\r | |
50 | L0:\r | |
51 | mov rcx, r8\r | |
52 | and r8, 7\r | |
53 | shr rcx, 3 # rcx <- # of Qwords to copy\r | |
54 | jz L_CopyBytes\r | |
55 | movd r10, mm0 # (Save mm0 in r10)\r | |
56 | L1:\r | |
57 | movq mm0, [rsi]\r | |
58 | movntq [rdi], mm0\r | |
59 | add rsi, 8\r | |
60 | add rdi, 8\r | |
61 | loop L1\r | |
62 | mfence\r | |
63 | movd mm0, r10 # (Restore mm0)\r | |
64 | jmp L_CopyBytes\r | |
65 | L_CopyBackward:\r | |
66 | mov rsi, r9 # rsi <- End of Source\r | |
67 | lea rdi, [rdi + r8 - 1] # rdi <- End of Destination\r | |
68 | std # set direction flag\r | |
69 | L_CopyBytes:\r | |
70 | mov rcx, r8\r | |
71 | rep movsb # Copy bytes backward\r | |
72 | cld\r | |
73 | pop rdi\r | |
74 | pop rsi\r | |
75 | ret\r |