1;------------------------------------------------------------------------------ 2; 3; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> 4; SPDX-License-Identifier: BSD-2-Clause-Patent 5; 6; Module Name: 7; 8; IsZeroBuffer.nasm 9; 10; Abstract: 11; 12; IsZeroBuffer function 13; 14; Notes: 15; 16;------------------------------------------------------------------------------ 17 18 DEFAULT REL 19 SECTION .text 20 21;------------------------------------------------------------------------------ 22; BOOLEAN 23; EFIAPI 24; InternalMemIsZeroBuffer ( 25; IN CONST VOID *Buffer, 26; IN UINTN Length 27; ); 28;------------------------------------------------------------------------------ 29global ASM_PFX(InternalMemIsZeroBuffer) 30ASM_PFX(InternalMemIsZeroBuffer): 31 push rdi 32 mov rdi, rcx ; rdi <- Buffer 33 mov rcx, rdx ; rcx <- Length 34 shr rcx, 3 ; rcx <- number of qwords 35 and rdx, 7 ; rdx <- number of trailing bytes 36 xor rax, rax ; rax <- 0, also set ZF 37 repe scasq 38 jnz @ReturnFalse ; ZF=0 means non-zero element found 39 mov rcx, rdx 40 repe scasb 41 jnz @ReturnFalse 42 pop rdi 43 mov rax, 1 ; return TRUE 44 ret 45@ReturnFalse: 46 pop rdi 47 xor rax, rax 48 ret ; return FALSE 49 50