]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/CompilerStub/X64/memset.asm
134700d91293a1ce7c7dd8bb4bdd28e411fea516
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / CompilerStub / X64 / memset.asm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2007, Intel Corporation
4 ; All rights reserved. This program and the accompanying materials
5 ; are licensed and made available under the terms and conditions of the BSD License
6 ; which accompanies this distribution. The full text of the license may be found at
7 ; http://opensource.org/licenses/bsd-license.php
8 ;
9 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 ;
12 ; Module Name:
13 ;
14 ; SetMem.asm
15 ;
16 ; Abstract:
17 ;
18 ; memset function
19 ;
20 ; Notes:
21 ;
22 ;------------------------------------------------------------------------------
23
24 .code
25
26 ;------------------------------------------------------------------------------
27 ; VOID *
28 ; memset (
29 ; OUT VOID *Buffer, --> rcx
30 ; IN UINT8 Value, --> rdx
31 ; IN UINTN Length --> r8
32 ; );
33 ;------------------------------------------------------------------------------
34 memset PROC USES rdi
35 mov rax, rcx
36 cmp r8, 0 ; if Size == 0, do nothing
37 je @SetDone
38 mov rax, rdx ; rdx <-> r8
39 mov rdx, r8 ; rdx <- Length
40 mov r8, rax ; r8 <- Value
41 mov ah, al
42 DB 48h, 0fh, 6eh, 0c0h ; movd mm0, rax
43 mov r8, rcx
44 mov rdi, r8 ; rdi <- Buffer
45 mov rcx, rdx
46 and edx, 7
47 shr rcx, 3
48 jz @SetBytes
49 DB 0fh, 70h, 0C0h, 00h ; pshufw mm0, mm0, 0h
50 @@:
51 DB 48h, 0fh, 7eh, 07h ; movd [rdi], mm0
52 add rdi, 8
53 loop @B
54 @SetBytes:
55 mov ecx, edx
56 rep stosb
57 mov rax, r8
58 @SetDone:
59 ret
60 memset ENDP
61
62 END