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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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
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
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
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
I have not tried your method yet, but stosd should be faster than stosw and the same goes for shr2.
best regards,
czDrillard
Memory filling optimizations issues has been discused many times on the board...
From the FAQ :rolleyes:
From the FAQ :rolleyes: