--- /dev/null
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+; This program and the accompanying materials\r
+; are licensed and made available under the terms and conditions of the BSD License\r
+; which accompanies this distribution. The full text of the license may be found at\r
+; http://opensource.org/licenses/bsd-license.php.\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+; Module Name:\r
+;\r
+; IsZeroBuffer.nasm\r
+;\r
+; Abstract:\r
+;\r
+; IsZeroBuffer function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ DEFAULT REL\r
+ SECTION .text\r
+\r
+;------------------------------------------------------------------------------\r
+; BOOLEAN\r
+; EFIAPI\r
+; InternalMemIsZeroBuffer (\r
+; IN CONST VOID *Buffer,\r
+; IN UINTN Length\r
+; );\r
+;------------------------------------------------------------------------------\r
+global ASM_PFX(InternalMemIsZeroBuffer)\r
+ASM_PFX(InternalMemIsZeroBuffer):\r
+ push rdi\r
+ mov rdi, rcx ; rdi <- Buffer\r
+ mov rcx, rdx ; rcx <- Length\r
+ shr rcx, 3 ; rcx <- number of qwords\r
+ and rdx, 7 ; rdx <- number of trailing bytes\r
+ xor rax, rax ; rax <- 0, also set ZF\r
+ repe scasq\r
+ jnz @ReturnFalse ; ZF=0 means non-zero element found\r
+ mov rcx, rdx\r
+ repe scasb\r
+ jnz @ReturnFalse\r
+ pop rdi\r
+ mov rax, 1 ; return TRUE\r
+ ret\r
+@ReturnFalse:\r
+ pop rdi\r
+ xor rax, rax\r
+ ret ; return FALSE\r
+\r