update for HEAD-2003091401
[reactos.git] / lib / ntdll / nasm / rtl / i386_RtlCompareMemory.asm
1 ; * base on ntdll/rtl/mem.c v 1.13 2003/07/11 13:50:23 
2 ; * 
3 ; * COPYRIGHT:       See COPYING in the top level directory
4 ; * PROJECT:         ReactOS kernel
5 ; * FILE:            i386_RtlCompareMemory.asm
6 ; * PURPOSE:         Memory functions
7 ; * PROGRAMMER:      Magnus Olsen (magnusolsen@greatlord.com)
8 ; * UPDATE HISTORY:
9 ; *                  Created 20/07-2003
10 ; * 
11                         
12   
13
14
15           BITS 32
16         GLOBAL _RtlCompareMemory@12      ; [4]  (no bug)  
17         
18         SECTION .text
19
20 ; *
21 ; * [4] ULONG STDCALL RtlCompareMemory(PVOID Source1, PVOID Source2, ULONG Length)
22 ; *
23
24 _RtlCompareMemory@12:
25       xor eax,eax                    ; count = 0  
26       mov ecx, dword [esp + 12 ]     ; ecx = Length                                       
27         cmp ecx,0                      ; if (Length==0) goto .zero
28         je  .zero
29       
30       push edi                       ; register that does not to be save eax,ecx,edx to 
31       push ebx                       ; the stack for protetion
32                             
33       mov edi, dword [esp + (4 + 8)] ; edi = Destination                       
34       mov edx, dword [esp + (8 + 8)] ; edx = Source                          
35
36 .loop_1byte:
37       mov bl,byte [edi + eax ]      ;  if (src[count]!=des[count]) goto .pop_zero           
38       cmp byte [edx + eax ],bl      
39       jne .pop_zero                 
40
41       inc eax                       ;  count = count + 1
42       dec ecx                       ;  Length = Length - 1
43       jnz .loop_1byte               ;  if (Length!=0) goto .loop_1byte
44
45 .pop_zero:      
46       pop ebx                       ; restore regiester 
47       pop edi                       
48 .zero:    
49       ret 12                        ; return count