Author: ion
Date: Sat Sep 2 20:36:48 2006
New Revision: 23887
URL: http://svn.reactos.org/svn/reactos?rev=23887&view=rev
Log:
- Fix a bug in RtlFillMemory.
- Fix overlap check comments.
Modified:
trunk/reactos/lib/rtl/i386/rtlmem.s
Modified: trunk/reactos/lib/rtl/i386/rtlmem.s
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/i386/rtlmem.s?rev=…
==============================================================================
--- trunk/reactos/lib/rtl/i386/rtlmem.s (original)
+++ trunk/reactos/lib/rtl/i386/rtlmem.s Sat Sep 2 20:36:48 2006
@@ -110,7 +110,7 @@
/* Get pattern */
mov al, [esp+16]
mov ah, al
- shr eax, 16
+ shl eax, 16
mov al, [esp+16]
mov ah, al
@@ -227,7 +227,7 @@
mov ecx, [esp+20]
cld
- /* Check for overlap */
+ /* Check if the destination is higher (or equal) */
cmp esi, edi
jbe Overlap
@@ -252,15 +252,16 @@
rep stosb
DoneMove:
+ /* Restore volatiles */
pop edi
pop esi
ret 12
Overlap:
- /* Avoid full overlap */
+ /* Don't copy if they're equal */
jz DoneMove
- /* Remove overlap */
+ /* Compare pointer distance with given length and check for overlap */
mov eax, edi
sub eax, esi
cmp ecx, eax
@@ -269,7 +270,7 @@
/* Set direction flag for backward move */
std
- /* Can only move some bytes, calculate how many */
+ /* Copy byte-by-byte the non-overlapping distance */
add esi, ecx
add edi, ecx
dec esi