]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibOptPei/X64/IsZeroBuffer.nasm
MdePkg BaseMemoryLib: Add assembly implementation of API IsZeroBuffer()
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptPei / X64 / IsZeroBuffer.nasm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2016, 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 ; IsZeroBuffer.nasm
15 ;
16 ; Abstract:
17 ;
18 ; IsZeroBuffer function
19 ;
20 ; Notes:
21 ;
22 ;------------------------------------------------------------------------------
23
24 DEFAULT REL
25 SECTION .text
26
27 ;------------------------------------------------------------------------------
28 ; BOOLEAN
29 ; EFIAPI
30 ; InternalMemIsZeroBuffer (
31 ; IN CONST VOID *Buffer,
32 ; IN UINTN Length
33 ; );
34 ;------------------------------------------------------------------------------
35 global ASM_PFX(InternalMemIsZeroBuffer)
36 ASM_PFX(InternalMemIsZeroBuffer):
37 push rdi
38 mov rdi, rcx ; rdi <- Buffer
39 mov rcx, rdx ; rcx <- Length
40 shr rcx, 3 ; rcx <- number of qwords
41 and rdx, 7 ; rdx <- number of trailing bytes
42 xor rax, rax ; rax <- 0, also set ZF
43 repe scasq
44 jnz @ReturnFalse ; ZF=0 means non-zero element found
45 mov rcx, rdx
46 repe scasb
47 jnz @ReturnFalse
48 pop rdi
49 mov rax, 1 ; return TRUE
50 ret
51 @ReturnFalse:
52 pop rdi
53 xor rax, rax
54 ret ; return FALSE
55