1 ;------------------------------------------------------------------------------
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.
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.
18 ; IsZeroBuffer function
22 ;------------------------------------------------------------------------------
27 ;------------------------------------------------------------------------------
30 ; InternalMemIsZeroBuffer (
31 ; IN CONST VOID *Buffer,
34 ;------------------------------------------------------------------------------
35 global ASM_PFX(InternalMemIsZeroBuffer)
36 ASM_PFX(InternalMemIsZeroBuffer):
38 mov rdi, rcx ; rdi <- Buffer
39 xor rcx, rcx ; rcx <- 0
41 and rcx, 15 ; rcx + rdi aligns on 16-byte boundary
43 cmp rcx, rdx ; Length already in rdx
44 cmova rcx, rdx ; bytes before the 16-byte boundary
46 xor rax, rax ; rax <- 0, also set ZF
48 jnz @ReturnFalse ; ZF=0 means non-zero element found
55 pxor xmm0, xmm0 ; xmm0 <- 0
56 pcmpeqb xmm0, [rdi] ; check zero for 16 bytes
57 pmovmskb eax, xmm0 ; eax <- compare results
58 ; nasm doesn't support 64-bit destination
66 xor rax, rax ; rax <- 0, also set ZF
68 jnz @ReturnFalse ; ZF=0 means non-zero element found
70 mov rax, 1 ; return TRUE