]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseMemoryLibRepStr/X64/CompareMem.nasm
MdePkg BaseMemoryLibRepStr: Convert X64/CompareMem.asm to NASM
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibRepStr / X64 / CompareMem.nasm
diff --git a/MdePkg/Library/BaseMemoryLibRepStr/X64/CompareMem.nasm b/MdePkg/Library/BaseMemoryLibRepStr/X64/CompareMem.nasm
new file mode 100644 (file)
index 0000000..293a39b
--- /dev/null
@@ -0,0 +1,58 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006 - 2008, 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
+;   CompareMem.Asm\r
+;\r
+; Abstract:\r
+;\r
+;   CompareMem function\r
+;\r
+; Notes:\r
+;\r
+;   The following BaseMemoryLib instances contain the same copy of this file:\r
+;\r
+;       BaseMemoryLibRepStr\r
+;       BaseMemoryLibMmx\r
+;       BaseMemoryLibSse2\r
+;       BaseMemoryLibOptDxe\r
+;       BaseMemoryLibOptPei\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    DEFAULT REL\r
+    SECTION .text\r
+\r
+;------------------------------------------------------------------------------\r
+; INTN\r
+; EFIAPI\r
+; InternalMemCompareMem (\r
+;   IN      CONST VOID                *DestinationBuffer,\r
+;   IN      CONST VOID                *SourceBuffer,\r
+;   IN      UINTN                     Length\r
+;   );\r
+;------------------------------------------------------------------------------\r
+global ASM_PFX(InternalMemCompareMem)\r
+ASM_PFX(InternalMemCompareMem):\r
+    push    rsi\r
+    push    rdi\r
+    mov     rsi, rcx\r
+    mov     rdi, rdx\r
+    mov     rcx, r8\r
+    repe    cmpsb\r
+    movzx   rax, byte [rsi - 1]\r
+    movzx   rdx, byte [rdi - 1]\r
+    sub     rax, rdx\r
+    pop     rdi\r
+    pop     rsi\r
+    ret\r
+\r