]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibOptDxe/X64/SetMem.nasm
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptDxe / X64 / SetMem.nasm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
5 ;
6 ; Module Name:
7 ;
8 ; SetMem.Asm
9 ;
10 ; Abstract:
11 ;
12 ; SetMem function
13 ;
14 ; Notes:
15 ;
16 ;------------------------------------------------------------------------------
17
18 DEFAULT REL
19 SECTION .text
20
21 ;------------------------------------------------------------------------------
22 ; VOID *
23 ; EFIAPI
24 ; InternalMemSetMem (
25 ; IN VOID *Buffer,
26 ; IN UINTN Count,
27 ; IN UINT8 Value
28 ; )
29 ;------------------------------------------------------------------------------
30 global ASM_PFX(InternalMemSetMem)
31 ASM_PFX(InternalMemSetMem):
32 push rdi
33 push rbx
34 push rcx ; push Buffer
35 mov rax, r8 ; rax = Value
36 and rax, 0xff ; rax = lower 8 bits of r8, upper 56 bits are 0
37 mov ah, al ; ah = al
38 mov bx, ax ; bx = ax
39 shl rax, 0x10 ; rax = ax << 16
40 mov ax, bx ; ax = bx
41 mov rbx, rax ; ebx = eax
42 shl rax, 0x20 ; rax = rax << 32
43 or rax, rbx ; eax = ebx
44 mov rdi, rcx ; rdi = Buffer
45 mov rcx, rdx ; rcx = Count
46 shr rcx, 3 ; rcx = rcx / 8
47 cld
48 rep stosq
49 mov rcx, rdx ; rcx = rdx
50 and rcx, 7 ; rcx = rcx & 7
51 rep stosb
52 pop rax ; rax = Buffer
53 pop rbx
54 pop rdi
55 ret
56