1 ; * base on ntdll/rtl/mem.c v 1.13 2003/07/11 13:50:23
3 ; * COPYRIGHT: See COPYING in the top level directory
4 ; * PROJECT: ReactOS kernel
5 ; * FILE: i386_RtlMemory.asm
6 ; * PURPOSE: Memory functions
7 ; * PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
14 GLOBAL _RtlMoveMemory@12 ; (no bug) (max optimze code)
19 ; * [1] VOID STDCALL RtlMoveMemory (PVOID Destination, CONST VOID *Source,ULONG Length);
25 mov ecx,dword [esp + 12 ] ; ecx = Length
26 cmp ecx,0 ; if (Length==0) goto .zero
30 mov edi, dword [esp + (4 + 32)] ; eax = Destination
31 mov esi, dword [esp + (8 + 32)] ; edx = Source
33 ; calc how many bytes it should handle same time
34 mov ebx,ecx ; temp_Length = Length
35 shr ecx,2 ; Length = Length / sizeof(ULONG)
36 jz .1byte ; if (Length==0) goto .1byte
38 shl ecx,2 ; Length = Length * sizeof(ULONG)
39 sub ebx,ecx ; temp_Length = temp_Length - Length
40 jz .4bytes ; if (temp_Length==0) goto .4byte
42 ; move 4byte and 1byte
43 shr ecx,2 ; Length = Length / sizeof(ULONG)
45 rep movsd ; while (Length!=0) { (ULONG *) Destination[Length-1] = (ULONG *) Source[Length-1]; Legnth = Legnth - 1 }
46 mov ecx,ebx ; Length = temp_Length
47 rep movsb ; while (Length!=0) { (UCHAR *) Destination[Length-1] = (UCHAR *) Source[Length-1]; Legnth = Legnth - 1 }
48 popad ; restore regiester
53 mov ecx,dword [esp + (12 +32) ] ; ecx = Length
55 rep movsb ; while (Length!=0) { (UCHAR *) Destination[Length-1] = (UCHAR *) Source[Length-1]; Legnth = Legnth - 1 }
57 popad ; restore regiester
62 shr ecx,2 ; Length = Length / sizeof(ULONG)
64 rep movsd ; while (Length!=0) { (ULONG *) Destination[Length-1] = (ULONG *) Source[Length-1]; Legnth = Legnth - 1 }
65 popad ; restore regiester