+++ /dev/null
-;------------------------------------------------------------------------------\r
-;\r
-; Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
-; This program and the accompanying materials\r
-; are licensed and made available under the terms and conditions of the BSD License\r
-; which accompanies this distribution. The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-;\r
-; Module Name:\r
-;\r
-; memcpyRep1.asm\r
-;\r
-; Abstract:\r
-;\r
-; CopyMem function\r
-;\r
-; Notes:\r
-;\r
-;------------------------------------------------------------------------------\r
-\r
- .code\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID\r
-; memcpy (\r
-; OUT VOID *Destination,\r
-; IN VOID *Source,\r
-; IN UINTN Count\r
-; );\r
-;------------------------------------------------------------------------------\r
-memcpy PROC USES rsi rdi\r
- mov rax, rcx\r
- cmp rdx, rcx ; if Source == Destination, do nothing\r
- je @CopyMemDone\r
- cmp r8, 0 ; if Count == 0, do nothing\r
- je @CopyMemDone\r
- mov rsi, rdx ; rsi <- Source\r
- mov rdi, rcx ; rdi <- Destination\r
- lea r9, [rsi + r8 - 1] ; r9 <- End of Source\r
- cmp rsi, rdi\r
- jae @F\r
- cmp r9, rdi\r
- jb @F ; Copy backward if overlapped\r
- mov rsi, r9 ; rsi <- End of Source\r
- lea rdi, [rdi + r8 - 1] ; esi <- End of Destination\r
- std ; set direction flag\r
-@@:\r
- mov rcx, r8\r
- rep movsb ; Copy bytes backward\r
- cld\r
-@CopyMemDone:\r
- ret\r
-memcpy ENDP\r
-\r
- END\r
-\r