Computer Chess Club Archives


Search

Terms

Messages

Subject: bitboard routine question

Author: Inmann Werner

Date: 12:57:28 09/17/99


Hello.

Implementing bitboards I came to the old and known problem of finding the
number of a bit in the bitboard on Intel machines (32 bit).
Trying a little around this evening, I came to following routine. It is simple
in C, but looking at the assemmbler outcome, I do not know, if it is good.
How do you implement such a extreme critical routine?

Werner


***************
//Testroutine, not tuned but readable
//hope no silly bug in it :)
// hope also, the idea is clear

typedef unsigned __int64 BITBOARD;
long lookup1[65];
BITBOARD teil;

init_bits()
{
int i;
BITBOARD a,b,c;
long erg;


	lookup1[0]=0;
	a=1;
	teil=67;   /*## OK ##*/
	for(i=1;i<64;i++)
	{
	   lookup1[i]=erg;
	   a=a<<1;
	}
}

long findbit(BITBOARD x)
{
BITBOARD c;
long bitnr,erg;

   c=x-(x&(x-1));
   bitnr=c%teil;
   erg=lookup1[bitnr];
   return(erg);
}
******************************************



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.