I want to fill the file space with two characters repeated over and over again. I do it this way:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov edi,pMemory
xor ecx,ecx
mov ecx,FileSize
or ecx,00h
jz @f
xor eax,eax
mov eax,6261h

@Begin:
stosw
sub ecx,02h
jbe @End
jmp @Begin

@End:
invoke WriteFile,hFile,pMemory,FileSize,ADDR WriteSize,NULL

@@:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


This works well, but can it, or should it be optimized? Is there a faster method of doing this? Any help appreciated.

best regards,

czDrillard
Posted on 2002-08-05 17:39:14 by czDrillard
Well, you could modify it slightly, going with:

mov edi,pMemory
mov ecx,FileSize
shr ecx,2
inc ecx
mov eax,62616261h
rep stosd

invoke WriteFile,hFile,pMemory,FileSize,ADDR WriteSize,NULL

Fake
Posted on 2002-08-05 17:45:43 by Fake51
Thanks Fake51,

I have not tried your method yet, but stosd should be faster than stosw and the same goes for shr2.

best regards,

czDrillard
Posted on 2002-08-06 20:40:54 by czDrillard
Memory filling optimizations issues has been discused many times on the board...

From the FAQ :rolleyes:
Posted on 2002-08-07 03:03:15 by JCP