Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bitboards with BSF/BSR

Author: Gerd Isenberg

Date: 02:37:21 12/12/01

Go up one level in this thread


I use bsf in the way that assumes that undefined means unchanged here, simply by
empirical evidence. So long as i play on my own hardware it's OK for me. Has
anybody found that this doesn't work on other x86-CPUs?

Gerd


// precondition: bb not null
__forceinline unsigned int BitSearch(BitBoard bb)
{
#ifdef	_M_IX86
	__asm
	{
		bsf		eax,[bb+4]
		add		al, 32
		bsf		eax,[bb]
	}
#else
	BitBoard lsbb = bb & (-(__int64)bb);
	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.