CloverBootloader/MdePkg/Library/BaseMemoryLibOptDxe/X64/ZeroMem.nasm
2019-09-03 12:58:42 +03:00

45 lines
1.1 KiB
NASM

;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
;
; ZeroMem.Asm
;
; Abstract:
;
; ZeroMem function
;
; Notes:
;
;------------------------------------------------------------------------------
DEFAULT REL
SECTION .text
;------------------------------------------------------------------------------
; VOID *
; InternalMemZeroMem (
; IN VOID *Buffer,
; IN UINTN Count
; );
;------------------------------------------------------------------------------
global ASM_PFX(InternalMemZeroMem)
ASM_PFX(InternalMemZeroMem):
push rdi
push rcx ; push Buffer
xor rax, rax ; rax = 0
mov rdi, rcx ; rdi = Buffer
mov rcx, rdx ; rcx = Count
shr rcx, 3 ; rcx = rcx / 8
and rdx, 7 ; rdx = rdx & 7
cld
rep stosq
mov rcx, rdx ; rcx = rdx
rep stosb
pop rax ; rax = Buffer
pop rdi
ret