Home | History | Annotate | Download | only in X64
      1 #
      2 # ConvertAsm.py: Automatically generated from CopyMem.asm
      3 #
      4 #------------------------------------------------------------------------------
      5 #
      6 # Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
      7 # This program and the accompanying materials
      8 # are licensed and made available under the terms and conditions of the BSD License
      9 # which accompanies this distribution.  The full text of the license may be found at
     10 # http://opensource.org/licenses/bsd-license.php.
     11 #
     12 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     13 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     14 #
     15 # Module Name:
     16 #
     17 #   CopyMem.S
     18 #
     19 # Abstract:
     20 #
     21 #   CopyMem function
     22 #
     23 # Notes:
     24 #
     25 #------------------------------------------------------------------------------
     26 
     27 
     28 #------------------------------------------------------------------------------
     29 #  VOID *
     30 #  EFIAPI
     31 #  InternalMemCopyMem (
     32 #    IN VOID   *Destination,
     33 #    IN VOID   *Source,
     34 #    IN UINTN  Count
     35 #    )
     36 #------------------------------------------------------------------------------
     37 ASM_GLOBAL ASM_PFX(InternalMemCopyMem)
     38 ASM_PFX(InternalMemCopyMem):
     39     pushq   %rsi
     40     pushq   %rdi
     41     movq    %rdx, %rsi                  # rsi <- Source
     42     movq    %rcx, %rdi                  # rdi <- Destination
     43     leaq    -1(%rsi, %r8,), %r9         # r9 <- End of Source
     44     cmpq    %rdi, %rsi
     45     movq    %rdi, %rax                  # rax <- Destination as return value
     46     jae     L0
     47     cmpq    %rdi, %r9
     48     jae     L_CopyBackward               # Copy backward if overlapped
     49 L0:
     50     movq    %r8, %rcx
     51     andq    $7, %r8
     52     shrq    $3, %rcx
     53     rep     movsq                       # Copy as many Qwords as possible
     54     jmp     L_CopyBytes
     55 L_CopyBackward:
     56     movq    %r9, %rsi                   # rsi <- End of Source
     57     leaq    -1(%rdi, %r8),  %rdi        # esi <- End of Destination
     58     std                                 # set direction flag
     59 L_CopyBytes:
     60     movq    %r8, %rcx
     61     rep     movsb                       # Copy bytes backward
     62     cld
     63     popq    %rdi
     64     popq    %rsi
     65     ret
     66 
     67