]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.nasm
MdePkg BaseMemoryLibMmx: Convert Ia32/SetMem.asm to NASM
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibMmx / Ia32 / SetMem.nasm
diff --git a/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.nasm b/MdePkg/Library/BaseMemoryLibMmx/Ia32/SetMem.nasm
new file mode 100644 (file)
index 0000000..35e0fc4
--- /dev/null
@@ -0,0 +1,68 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006, 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
+;   SetMem.nasm\r
+;\r
+; Abstract:\r
+;\r
+;   SetMem function\r
+;\r
+; Notes:\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+    SECTION .text\r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID *\r
+;  EFIAPI\r
+;  InternalMemSetMem (\r
+;    IN VOID   *Buffer,\r
+;    IN UINTN  Count,\r
+;    IN UINT8  Value\r
+;    )\r
+;------------------------------------------------------------------------------\r
+global ASM_PFX(InternalMemSetMem)\r
+ASM_PFX(InternalMemSetMem):\r
+    push    edi\r
+    mov     al, [esp + 16]\r
+    mov     ah, al\r
+    shrd    edx, eax, 16\r
+    shld    eax, edx, 16\r
+    mov     ecx, [esp + 12]             ; ecx <- Count\r
+    mov     edi, [esp + 8]              ; edi <- Buffer\r
+    mov     edx, ecx\r
+    and     edx, 7\r
+    shr     ecx, 3                      ; # of Qwords to set\r
+    jz      @SetBytes\r
+    add     esp, -0x10\r
+    movq    [esp], mm0                  ; save mm0\r
+    movq    [esp + 8], mm1              ; save mm1\r
+    movd    mm0, eax\r
+    movd    mm1, eax\r
+    psllq   mm0, 32\r
+    por     mm0, mm1                    ; fill mm0 with 8 Value's\r
+.0:\r
+    movq    [edi], mm0\r
+    add     edi, 8\r
+    loop    .0\r
+    movq    mm0, [esp]                  ; restore mm0\r
+    movq    mm1, [esp + 8]              ; restore mm1\r
+    add     esp, 0x10                    ; stack cleanup\r
+@SetBytes:\r
+    mov     ecx, edx\r
+    rep     stosb\r
+    mov     eax, [esp + 8]              ; eax <- Buffer as return value\r
+    pop     edi\r
+    ret\r
+\r