]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibSse2/Ia32/IsZeroBuffer.nasm
MdePkg: Remove X86 ASM and S files
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibSse2 / Ia32 / IsZeroBuffer.nasm
CommitLineData
102b4c7c
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 edx, [esp + 12] ; edx <- Length\r
39 xor ecx, ecx ; ecx <- 0\r
40 sub ecx, edi\r
41 and ecx, 15 ; ecx + edi aligns on 16-byte boundary\r
42 jz @Is16BytesZero\r
43 cmp ecx, edx\r
44 cmova ecx, edx ; bytes before the 16-byte boundary\r
45 sub edx, ecx\r
46 xor eax, eax ; eax <- 0, also set ZF\r
47 repe scasb\r
48 jnz @ReturnFalse ; ZF=0 means non-zero element found\r
49@Is16BytesZero:\r
50 mov ecx, edx\r
51 and edx, 15\r
52 shr ecx, 4\r
53 jz @IsBytesZero\r
54.0:\r
55 pxor xmm0, xmm0 ; xmm0 <- 0\r
56 pcmpeqb xmm0, [edi] ; check zero for 16 bytes\r
57 pmovmskb eax, xmm0 ; eax <- compare results\r
58 cmp eax, 0xffff\r
59 jnz @ReturnFalse\r
60 add edi, 16\r
61 loop .0\r
62@IsBytesZero:\r
63 mov ecx, edx\r
64 xor eax, eax ; eax <- 0, also set ZF\r
65 repe scasb\r
66 jnz @ReturnFalse ; ZF=0 means non-zero element found\r
67 pop edi\r
68 mov eax, 1 ; return TRUE\r
69 ret\r
70@ReturnFalse:\r
71 pop edi\r
72 xor eax, eax\r
73 ret ; return FALSE\r
74\r