Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Speaking of fast ways to do things...

Author: Andrew Dados

Date: 11:28:33 04/19/00

Go up one level in this thread


On April 19, 2000 at 13:49:25, Dann Corbit wrote:

>What is the fastest way to fill a linear array of bytes with zero, given the
>following conditions:
>1.  Intel PII or higher CPU
>2.  Guarantee that the number of bytes is an even number?
>
>I am porting a chess program, and memset() is the bottleneck.  I don't need to
>memset an arbitrary character.  It's always zero.

for pure 32bit windoze (assuming es==ds):

asm
 mov edi, begin_address
 mov ecx, count ; number of words to fill
 xor eax,eax    ; filling with 0x0000
 shr ecx,2      ; here carry gets set if count is not divisible by 4
 rep stosd
 jnc @finito
 stosw          ; fill extra word if count mod 4 !=0
@finito:
end;





This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.