]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibRepStr/X64/IsZeroBuffer.nasm
MdePkg BaseMemoryLib: Add assembly implementation of API IsZeroBuffer()
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibRepStr / X64 / IsZeroBuffer.nasm
CommitLineData
02b5cf7f
HW
1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
4; This program and the accompanying materials\r
5; are licensed and made available under the terms and conditions of the BSD License\r
6; which accompanies this distribution. The full text of the license may be found at\r
7; http://opensource.org/licenses/bsd-license.php.\r
8;\r
9; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11;\r
12; Module Name:\r
13;\r
14; IsZeroBuffer.nasm\r
15;\r
16; Abstract:\r
17;\r
18; IsZeroBuffer function\r
19;\r
20; Notes:\r
21;\r
22;------------------------------------------------------------------------------\r
23\r
24 DEFAULT REL\r
25 SECTION .text\r
26\r
27;------------------------------------------------------------------------------\r
28; BOOLEAN\r
29; EFIAPI\r
30; InternalMemIsZeroBuffer (\r
31; IN CONST VOID *Buffer,\r
32; IN UINTN Length\r
33; );\r
34;------------------------------------------------------------------------------\r
35global ASM_PFX(InternalMemIsZeroBuffer)\r
36ASM_PFX(InternalMemIsZeroBuffer):\r
37 push rdi\r
38 mov rdi, rcx ; rdi <- Buffer\r
39 mov rcx, rdx ; rcx <- Length\r
40 shr rcx, 3 ; rcx <- number of qwords\r
41 and rdx, 7 ; rdx <- number of trailing bytes\r
42 xor rax, rax ; rax <- 0, also set ZF\r
43 repe scasq\r
44 jnz @ReturnFalse ; ZF=0 means non-zero element found\r
45 mov rcx, rdx\r
46 repe scasb\r
47 jnz @ReturnFalse\r
48 pop rdi\r
49 mov rax, 1 ; return TRUE\r
50 ret\r
51@ReturnFalse:\r
52 pop rdi\r
53 xor rax, rax\r
54 ret ; return FALSE\r
55\r