• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#------------------------------------------------------------------------------
2#
3# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
4# This program and the accompanying materials
5# are licensed and made available under the terms and conditions of the BSD License
6# which accompanies this distribution.  The full text of the license may be found at
7# http://opensource.org/licenses/bsd-license.php
8#
9# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11#
12# Module Name:
13#
14#   EfiCopyMemRep1.S
15#
16# Abstract:
17#
18#   CopyMem function
19#
20# Notes:
21#
22#------------------------------------------------------------------------------
23#include <EfiBind.h>
24
25    .code:
26
27.globl ASM_PFX(EfiCommonLibCopyMem)
28
29#------------------------------------------------------------------------------
30# VOID
31# EfiCommonLibCopyMem (
32#   OUT     VOID                      *Destination,
33#   IN      VOID                      *Source,
34#   IN      UINTN                     Count
35#   );
36#------------------------------------------------------------------------------
37ASM_PFX(EfiCommonLibCopyMem):
38      push   %rsi
39      push   %rdi
40      cmp    %rcx,%rdx
41      je     CopyMemDone
42      cmp    $0x0,%r8
43      je     CopyMemDone
44      mov    %rdx,%rsi
45      mov    %rcx,%rdi
46      lea    -1(%r8,%rsi,1),%r9
47      cmp    %rdi,%rsi
48      jae    CopyBytes
49      cmp    %rdi,%r9
50      jb     CopyBytes
51      mov    %r9,%rsi
52      lea    -1(%r8,%rdi,1),%rdi
53      std
54
55CopyBytes:
56      mov    %r8,%rcx
57      rep movsb %ds:(%rsi),%es:(%rdi)
58      cld
59
60CopyMemDone:
61      pop    %rdi
62      pop    %rsi
63      retq
64
65
66
67