mirror of
https://github.com/reactos/reactos.git
synced 2025-05-19 00:54:18 +00:00
69 lines
3.1 KiB
NASM
69 lines
3.1 KiB
NASM
; * base on ntdll/rtl/mem.c v 1.13 2003/07/11 13:50:23
|
|
; *
|
|
; * COPYRIGHT: See COPYING in the top level directory
|
|
; * PROJECT: ReactOS kernel
|
|
; * FILE: i386_RtlMemory.asm
|
|
; * PURPOSE: Memory functions
|
|
; * PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com)
|
|
; * UPDATE HISTORY:
|
|
; * Created 20/07-2003
|
|
; *
|
|
|
|
|
|
BITS 32
|
|
GLOBAL _RtlMoveMemory@12 ; (no bug) (max optimze code)
|
|
|
|
SECTION .text
|
|
|
|
; *
|
|
; * [1] VOID STDCALL RtlMoveMemory (PVOID Destination, CONST VOID *Source,ULONG Length);
|
|
; *
|
|
|
|
|
|
|
|
_RtlMoveMemory@12:
|
|
mov ecx,dword [esp + 12 ] ; ecx = Length
|
|
cmp ecx,0 ; if (Length==0) goto .zero
|
|
je .zero
|
|
|
|
pushad
|
|
mov edi, dword [esp + (4 + 32)] ; eax = Destination
|
|
mov esi, dword [esp + (8 + 32)] ; edx = Source
|
|
|
|
; calc how many bytes it should handle same time
|
|
mov ebx,ecx ; temp_Length = Length
|
|
shr ecx,2 ; Length = Length / sizeof(ULONG)
|
|
jz .1byte ; if (Length==0) goto .1byte
|
|
|
|
shl ecx,2 ; Length = Length * sizeof(ULONG)
|
|
sub ebx,ecx ; temp_Length = temp_Length - Length
|
|
jz .4bytes ; if (temp_Length==0) goto .4byte
|
|
|
|
; move 4byte and 1byte
|
|
shr ecx,2 ; Length = Length / sizeof(ULONG)
|
|
cld ; clear d flag
|
|
rep movsd ; while (Length!=0) { (ULONG *) Destination[Length-1] = (ULONG *) Source[Length-1]; Legnth = Legnth - 1 }
|
|
mov ecx,ebx ; Length = temp_Length
|
|
rep movsb ; while (Length!=0) { (UCHAR *) Destination[Length-1] = (UCHAR *) Source[Length-1]; Legnth = Legnth - 1 }
|
|
popad ; restore regiester
|
|
ret 12 ; return
|
|
|
|
; move 1byte
|
|
.1byte:
|
|
mov ecx,dword [esp + (12 +32) ] ; ecx = Length
|
|
cld ; clear d flag
|
|
rep movsb ; while (Length!=0) { (UCHAR *) Destination[Length-1] = (UCHAR *) Source[Length-1]; Legnth = Legnth - 1 }
|
|
|
|
popad ; restore regiester
|
|
ret 12 ; return
|
|
|
|
; move 4bytes
|
|
.4bytes:
|
|
shr ecx,2 ; Length = Length / sizeof(ULONG)
|
|
cld ; clear d flag
|
|
rep movsd ; while (Length!=0) { (ULONG *) Destination[Length-1] = (ULONG *) Source[Length-1]; Legnth = Legnth - 1 }
|
|
popad ; restore regiester
|
|
.zero:
|
|
ret 12 ; return
|
|
|
|
|