1;/*++ 2; 3;Copyright (c) 2007, 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.asm 15; 16;Abstract: 17; 18; This is the code that uses rep movsb CopyMem service 19; 20;--*/ 21; 22;--------------------------------------------------------------------------- 23 .686 24 .model flat,C 25 .code 26 27;--------------------------------------------------------------------------- 28;#include "Tiano.h" 29; 30;VOID 31;EfiCommonLibCopyMem ( 32; IN VOID *Destination, 33; IN VOID *Source, 34; IN UINTN Count 35; ) 36;/*++ 37; 38;Routine Description: 39; 40; Copy Length bytes from Source to Destination. 41; 42;Arguments: 43; 44; Destination - Target of copy 45; 46; Source - Place to copy from 47; 48; Length - Number of bytes to copy 49; 50;Returns: 51; 52; None 53; 54;--*/ 55EfiCommonLibCopyMem PROC 56 push ebp 57 mov ebp, esp 58 push esi 59 push edi 60 mov esi, dword ptr[ebp + 0Ch] ; esi <- Source 61 mov edi, dword ptr[ebp + 8] ; edi <- Destination 62 mov edx, dword ptr[ebp + 10h] ; edx <- Count 63 cmp esi, edi 64 je _CopyDone 65 cmp edx, 0 66 je _CopyDone 67 lea eax, [esi + edx - 1] ; eax <- End of Source 68 cmp esi, edi 69 jae _CopyBytes 70 cmp eax, edi 71 jb _CopyBytes ; Copy backward if overlapped 72 mov esi, eax ; esi <- End of Source 73 lea edi, [edi + edx - 1] ; edi <- End of Destination 74 std 75_CopyBytes: 76 mov ecx, edx 77 rep movsb ; Copy bytes backward 78 cld 79_CopyDone: 80 pop edi 81 pop esi 82 pop ebp 83 ret 84EfiCommonLibCopyMem ENDP 85 END 86 87