]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibRepStr/Ia32/IsZeroBuffer.nasm
MdePkg BaseMemoryLib: Add assembly implementation of API IsZeroBuffer()
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibRepStr / Ia32 / 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 SECTION .text\r
25\r
26;------------------------------------------------------------------------------\r
27; BOOLEAN\r
28; EFIAPI\r
29; InternalMemIsZeroBuffer (\r
30; IN CONST VOID *Buffer,\r
31; IN UINTN Length\r
32; );\r
33;------------------------------------------------------------------------------\r
34global ASM_PFX(InternalMemIsZeroBuffer)\r
35ASM_PFX(InternalMemIsZeroBuffer):\r
36 push edi\r
37 mov edi, [esp + 8] ; edi <- Buffer\r
38 mov ecx, [esp + 12] ; ecx <- Length\r
39 mov edx, ecx ; edx <- ecx\r
40 shr ecx, 2 ; ecx <- number of dwords\r
41 and edx, 3 ; edx <- number of trailing bytes\r
42 xor eax, eax ; eax <- 0, also set ZF\r
43 repe scasd\r
44 jnz @ReturnFalse ; ZF=0 means non-zero element found\r
45 mov ecx, edx\r
46 repe scasb\r
47 jnz @ReturnFalse\r
48 pop edi\r
49 mov eax, 1 ; return TRUE\r
50 ret\r
51@ReturnFalse:\r
52 pop edi\r
53 xor eax, eax\r
54 ret ; return FALSE\r
55\r