]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibMmx/X64/SetMem.nasm
MdePkg BaseMemoryLibMmx: Convert X64/SetMem.asm to NASM
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibMmx / X64 / SetMem.nasm
CommitLineData
9692aa20
JJ
1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2006, 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; SetMem.nasm\r
15;\r
16; Abstract:\r
17;\r
18; SetMem function\r
19;\r
20; Notes:\r
21;\r
22;------------------------------------------------------------------------------\r
23\r
24 DEFAULT REL\r
25 SECTION .text\r
26\r
27;------------------------------------------------------------------------------\r
28; VOID *\r
29; EFIAPI\r
30; InternalMemSetMem (\r
31; OUT VOID *Buffer,\r
32; IN UINTN Length,\r
33; IN UINT8 Value\r
34; );\r
35;------------------------------------------------------------------------------\r
36global ASM_PFX(InternalMemSetMem)\r
37ASM_PFX(InternalMemSetMem):\r
38 push rdi\r
39 mov rax, r8\r
40 mov ah, al\r
41 DB 0x48, 0xf, 0x6e, 0xc0 ; movd mm0, rax\r
42 mov r8, rcx\r
43 mov rdi, r8 ; rdi <- Buffer\r
44 mov rcx, rdx\r
45 and edx, 7\r
46 shr rcx, 3\r
47 jz @SetBytes\r
48 DB 0xf, 0x70, 0xC0, 0x0 ; pshufw mm0, mm0, 0h\r
49.0:\r
50 DB 0xf, 0xe7, 0x7 ; movntq [rdi], mm0\r
51 add rdi, 8\r
52 loop .0\r
53 mfence\r
54@SetBytes:\r
55 mov ecx, edx\r
56 rep stosb\r
57 mov rax, r8\r
58 pop rdi\r
59 ret\r
60\r