2 ; * COPYRIGHT: See COPYING in the top level directory
3 ; * PROJECT: ReactOS kernel
4 ; * FILE: i386_RtlZeroMemory.asm
5 ; * PURPOSE: Memory functions
6 ; * PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
13 GLOBAL _RtlZeroMemory@8 ; (no bug) (max optimze code)
17 ; * [1] VOID STDCALL RtlZeroMemory (PVOID Destination, ULONG Length);
22 mov ecx,dword [esp + 8 ] ; Length
23 cmp ecx,0 ; if (Length==0) goto .zero
26 pushad ; Save all register on the stack
27 mov edi, dword [esp + (4 + 32)] ; Destination
28 xor eax,eax ; ZeroFillByte = 0
32 ; code for take four byte each time it loop
33 mov ebx,ecx ; temp_Length = Length
34 shr ecx,2 ; Length = Length / sizeof(ULONG)
35 jz .1byte ; if (Length==0) goto .1byte
37 shl ecx,2 ; Length = Length * sizeof(ULONG)
38 sub ebx,ecx ; temp_Length = temp_Length - Length;
39 jz .4bytes ; if (temp_Length==0) goto .4byte
41 ; move 4byte and 1byte
42 shr ecx,2 ; Length = Length / sizeof(ULONG)
44 rep stosd ; while (Length!=0) { (ULONG *) Destination[Length-1]=ZeroFillByte; Legnth = Legnth - 1 }
45 mov ecx,ebx ; Length = temp_Length
46 rep stosb ; while (Length!=0) { (UCHAR *) Destination[Length-1]=ZeroFillByte; Legnth = Legnth - 1 }
47 popad ; restore register
52 mov ecx,dword [esp + (12 +32) ] ; Length
54 rep stosb ; while (Length!=0) { (UCHAR *) Destination[Length-1]=ZeroFillByte; Legnth = Legnth - 1 }
55 popad ; restore register
60 shr ecx,2 ; Length = Length / sizeof(ULONG)
62 rep stosd ; while (Length!=0) { (ULONG *) Destination[Length-1]=ZeroFillByte; Legnth = Legnth - 1 }
63 popad ; restore register