Separated math and memory functions into their own files to limit the amount of objec...
[reactos.git] / reactos / lib / rtl / i386 / comparememory_asm.s
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: comparememory_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)
9 */
10
11 .intel_syntax noprefix
12
13 /* GLOBALS ****************************************************************/
14
15 .globl _RtlCompareMemory@12 // [4] (no bug)
16
17 /* FUNCTIONS ***************************************************************/
18
19 _RtlCompareMemory@12:
20 xor eax,eax // count = 0
21 mov ecx, dword [esp + 12 ] // ecx = Length
22 cmp ecx,0 // if (Length==0) goto .zero
23 je 3f
24
25 push edi// register that does not to be save eax,ecx,edx to
26 push ebx// the stack for protetion
27
28 mov edi, dword [esp + (4 + 8)] // edi = Destination
29 mov edx, dword [esp + (8 + 8)] // edx = Source
30
31 1:
32 mov bl,byte [edi + eax ] // if (src[count]!=des[count]) goto .pop_zero
33 cmp byte [edx + eax ],bl
34 jne 2f
35
36 inc eax // count = count + 1
37 dec ecx // Length = Length - 1
38 jnz 1b // if (Length!=0) goto .loop_1byte
39
40 2:
41 pop ebx // restore regiester
42 pop edi
43 3:
44 ret 12 // return count