]>
Commit | Line | Data |
---|---|---|
b341712e | 1 | #\r |
2 | # ConvertAsm.py: Automatically generated from CopyMem.asm\r | |
3 | #\r | |
4 | #------------------------------------------------------------------------------\r | |
5 | #\r | |
86345de5 | 6 | # Copyright (c) 2006 - 2009, Intel Corporation\r |
b341712e | 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 | #include <EdkIIGlueBase.h>\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 | |
b341712e | 37 | .globl ASM_PFX(InternalMemCopyMem)\r |
38 | ASM_PFX(InternalMemCopyMem):\r | |
86345de5 | 39 | pushq %rsi\r |
40 | pushq %rdi\r | |
41 | movq %rdx, %rsi # rsi <- Source\r | |
42 | movq %rcx, %rdi # rdi <- Destination\r | |
43 | leaq -1(%rsi, %r8,), %r9 # r9 <- End of Source\r | |
44 | cmpq %rdi, %rsi\r | |
45 | movq %rdi, %rax # rax <- Destination as return value\r | |
46 | jae L0\r | |
47 | cmpq %rdi, %r9\r | |
48 | jae L_CopyBackward # Copy backward if overlapped\r | |
49 | L0:\r | |
50 | movq %r8, %rcx\r | |
51 | andq $7, %r8\r | |
52 | shrq $3, %rcx\r | |
b341712e | 53 | rep movsq # Copy as many Qwords as possible\r |
86345de5 | 54 | jmp L_CopyBytes\r |
55 | L_CopyBackward:\r | |
56 | movq %r9, %rsi # rsi <- End of Source\r | |
57 | leaq -1(%rdi, %r8), %rdi # esi <- End of Destination\r | |
b341712e | 58 | std # set direction flag\r |
86345de5 | 59 | L_CopyBytes:\r |
60 | movq %r8, %rcx\r | |
b341712e | 61 | rep movsb # Copy bytes backward\r |
62 | cld\r | |
86345de5 | 63 | popq %rdi\r |
64 | popq %rsi\r | |
b341712e | 65 | ret\r |
66 | \r |