1;------------------------------------------------------------------------------ 2; 3; Copyright (c) 2006, 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; SetMem.nasm 15; 16; Abstract: 17; 18; SetMem function 19; 20; Notes: 21; 22;------------------------------------------------------------------------------ 23 24 SECTION .text 25 26;------------------------------------------------------------------------------ 27; VOID * 28; EFIAPI 29; InternalMemSetMem ( 30; IN VOID *Buffer, 31; IN UINTN Count, 32; IN UINT8 Value 33; ) 34;------------------------------------------------------------------------------ 35global ASM_PFX(InternalMemSetMem) 36ASM_PFX(InternalMemSetMem): 37 push edi 38 mov al, [esp + 16] 39 mov ah, al 40 shrd edx, eax, 16 41 shld eax, edx, 16 42 mov ecx, [esp + 12] ; ecx <- Count 43 mov edi, [esp + 8] ; edi <- Buffer 44 mov edx, ecx 45 and edx, 7 46 shr ecx, 3 ; # of Qwords to set 47 jz @SetBytes 48 add esp, -0x10 49 movq [esp], mm0 ; save mm0 50 movq [esp + 8], mm1 ; save mm1 51 movd mm0, eax 52 movd mm1, eax 53 psllq mm0, 32 54 por mm0, mm1 ; fill mm0 with 8 Value's 55.0: 56 movq [edi], mm0 57 add edi, 8 58 loop .0 59 movq mm0, [esp] ; restore mm0 60 movq mm1, [esp + 8] ; restore mm1 61 add esp, 0x10 ; stack cleanup 62@SetBytes: 63 mov ecx, edx 64 rep stosb 65 mov eax, [esp + 8] ; eax <- Buffer as return value 66 pop edi 67 ret 68 69