Author: Gerd Isenberg
Date: 13:00:35 11/17/02
Go up one level in this thread
Hi Anthony,
i havn't compared it in an simple loop running n times and mesured the time.
The effect in my chess program is rather significant, a few percent if i
remember well. To traverse bitboards, i use this version, which resets the found
bit as well:
__forceinline UINT BitSearchAndReset(BitBoard &bb)
{
#ifdef _M_IX86
#ifdef FASTEST_AND_SAFEST
__asm
{
xor edx, edx
mov ebx, [bb]
mov eax, edx
inc edx
bsf ecx, [ebx]
jnz found
bsf ecx, [ebx + 4]
lea ebx, [ebx + 4]
xor eax, 32
found:
shl edx, cl
xor eax, ecx
xor [ebx], edx
}
#else
__asm
{
mov edx, [bb]
bsf eax, [edx+4]
xor eax, 32
bsf eax, [edx]
btr [edx],eax
}
#endif
#else // _M_IX86
BitBoard lsbb = bb & (-(__int64)bb);
bb ^= lsbb;
UINT32 lsb = LOWBOARD(lsbb) | HIGHBOARD(lsbb);
return ((((((((((HIGHBOARD(lsbb)!=0) <<1)
^((lsb & 0xffff0000)!=0))<<1)
^((lsb & 0xff00ff00)!=0))<<1)
^((lsb & 0xf0f0f0f0)!=0))<<1)
^((lsb & 0xcccccccc)!=0))<<1)
^((lsb & 0xaaaaaaaa)!=0);
#endif
}
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.