2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
5 * PURPOSE: Memory functions
6 * PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
11 .intel_syntax noprefix
13 /* GLOBALS ****************************************************************/
15 .globl _RtlZeroMemory@8 // (no bug) (max optimze code)
16 .globl _RtlFillMemoryUlong@12 // (no bug) (max optimze code)
17 .globl _RtlFillMemory@12 // [4] (no bug)
18 .globl _RtlCompareMemoryUlong@12 // [5] (no bug)
19 .globl _RtlCompareMemory@12 // [4] (no bug)
21 /* FUNCTIONS ***************************************************************/
24 mov ecx,dword [esp + 8 ] // Length
25 cmp ecx,0// if (Length==0) goto .zero
28 pushad // Save all register on the stack
29 mov edi, dword [esp + (4 + 32)] // Destination
30 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 1f // if (Length==0) goto .1byte
37 shl ecx,2// Length = Length * sizeof(ULONG)
38 sub ebx,ecx // temp_Length = temp_Length - Length//
39 jz 2f // 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
67 _RtlFillMemoryUlong@12:
68 mov ecx, dword [esp + 8 ] // Length
69 shr ecx,2// Length = Length / sizeof(ULONG)
70 jz 1f // if (Length==0) goto .zero
73 mov edi, dword [esp + (4 + 4)] // Destination
74 mov eax, dword [esp + (12 + 4)] // Fill
76 rep stosd// while (Length>0) {Destination[Length-1]=Fill// Length = Length - 1}
82 mov ecx,dword [esp + 8 ] // ecx = Length
83 cmp ecx,0// if (Length==0) goto .zero
86 mov edx, dword [esp + 4] // edx = Destination
87 mov eax, dword [esp + 12] // eax = fill
89 mov byte [edx + ecx -1],al // src[Length - 1] = fill
90 dec ecx // Length = Length - 1
91 jnz 1b // if (Length!=0) goto .loop
95 _RtlCompareMemoryUlong@12:
97 mov ecx, dword [esp + 8 ] // ecx = Length
98 shr ecx,2 // Length / sizeof(ULONG)
99 jz 1f // if (Length==0) goto .zero
101 push edi// register that does not to be save eax,ecx,edx to
102 push ebx// the stack for protetion
104 mov edi, dword [esp + (4 + 8)] // edx = Destination
105 mov eax, dword [esp + (12 + 8)] // ebx = value
122 _RtlCompareMemory@12:
123 xor eax,eax // count = 0
124 mov ecx, dword [esp + 12 ] // ecx = Length
125 cmp ecx,0 // if (Length==0) goto .zero
128 push edi// register that does not to be save eax,ecx,edx to
129 push ebx// the stack for protetion
131 mov edi, dword [esp + (4 + 8)] // edi = Destination
132 mov edx, dword [esp + (8 + 8)] // edx = Source
135 mov bl,byte [edi + eax ] // if (src[count]!=des[count]) goto .pop_zero
136 cmp byte [edx + eax ],bl
139 inc eax // count = count + 1
140 dec ecx // Length = Length - 1
141 jnz 1b // if (Length!=0) goto .loop_1byte
144 pop ebx // restore regiester
147 ret 12 // return count