2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: zeromemory_asm.S
5 * PURPOSE: Memory functions
6 * PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
7 * Alex Ionescu (alex@relsoft.net)
8 * Magnus Olsen (magnusolsen@greatlord.com)
11 .intel_syntax noprefix
13 /* GLOBALS ****************************************************************/
15 .globl _RtlZeroMemory@8 // (no bug) (max optimze code)
17 /* FUNCTIONS ***************************************************************/
20 mov ecx,dword [esp + 8 ] // Length
21 cmp ecx,0// if (Length==0) goto .zero
24 pushad // Save all register on the stack
25 mov edi, dword [esp + (4 + 32)] // Destination
26 xor eax,eax // ZeroFillByte = 0
28 // code for take four byte each time it loop
29 mov ebx,ecx // temp_Length = Length
30 shr ecx,2// Length = Length / sizeof(ULONG)
31 jz 1f // if (Length==0) goto .1byte
33 shl ecx,2// Length = Length * sizeof(ULONG)
34 sub ebx,ecx // temp_Length = temp_Length - Length//
35 jz 2f // if (temp_Length==0) goto .4byte
37 // move 4byte and 1byte
38 shr ecx,2// Length = Length / sizeof(ULONG)
40 rep stosd// while (Length!=0) { (ULONG *) Destination[Length-1]=ZeroFillByte// Legnth = Legnth - 1 }
41 mov ecx,ebx // Length = temp_Length
42 rep stosb// while (Length!=0) { (UCHAR *) Destination[Length-1]=ZeroFillByte// Legnth = Legnth - 1 }
43 popad // restore register
48 mov ecx,dword [esp + (12 +32) ] // Length
50 rep stosb// while (Length!=0) { (UCHAR *) Destination[Length-1]=ZeroFillByte// Legnth = Legnth - 1 }
51 popad // restore register
56 shr ecx,2// Length = Length / sizeof(ULONG)
58 rep stosd// while (Length!=0) { (ULONG *) Destination[Length-1]=ZeroFillByte// Legnth = Legnth - 1 }
59 popad // restore register