]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/CompilerStub/Ia32/memset.asm
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / CompilerStub / Ia32 / 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 .686
25 .model flat,C
26 .mmx
27 .code
28
29 ;------------------------------------------------------------------------------
30 ; VOID *
31 ; memset (
32 ; OUT VOID *Buffer,
33 ; IN UINT8 Value,
34 ; IN UINTN Count
35 ; )
36 ;------------------------------------------------------------------------------
37 memset PROC USES edi
38 mov al, [esp + 12]
39 mov ah, al
40 shrd edx, eax, 16
41 shld eax, edx, 16
42 mov ecx, [esp + 16] ; ecx <- Count
43 cmp ecx, 0 ; if Count == 0, do nothing
44 je @SetDone
45 mov edi, [esp + 8] ; edi <- Buffer
46 mov edx, ecx
47 and edx, 7
48 shr ecx, 3 ; # of Qwords to set
49 jz @SetBytes
50 add esp, -10h
51 movq [esp], mm0 ; save mm0
52 movq [esp + 8], mm1 ; save mm1
53 movd mm0, eax
54 movd mm1, eax
55 psllq mm0, 32
56 por mm0, mm1 ; fill mm0 with 8 Value's
57 @@:
58 movq [edi], mm0
59 add edi, 8
60 loop @B
61 movq mm0, [esp] ; restore mm0
62 movq mm1, [esp + 8] ; restore mm1
63 add esp, 10h ; stack cleanup
64 @SetBytes:
65 mov ecx, edx
66 rep stosb
67 @SetDone:
68 mov eax, [esp + 8] ; eax <- Buffer as return value
69 ret
70 memset ENDP
71
72 END