Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bitboards and Piece Lists

Author: Dann Corbit

Date: 01:56:35 06/15/01

Go up one level in this thread


On June 15, 2001 at 04:03:38, Marcus Heidkamp wrote:

>On June 14, 2001 at 19:34:09, Dann Corbit wrote:
>
>>Using this "darn-fast" branchless first-bit location routine:
>>int FirstPiece(BITBOARD bits)
>>{
>>//    if (bits == 0) return -1;
>>__asm {
>>;       64-bit number to move into ECX:EBX, will never be zero!
>>        mov ecx,dword ptr [bits+4]
>>        mov ebx,dword ptr [bits]
>>        bsf eax,ecx
>>        add eax,32
>>        bsf eax,ebx
>>      }
>>}
>>
>>I would think that iterating over the board would be just as fast (or possibly
>>faster) than using piece lists.
>>
>>I am curious if others who use bitboards find piece lists to be valuable.
>>I am somewhat surprised to see that FirstPiece() is consuming a lot of CPU.
>
>Hi Dann!
>
>Are you sure this works? According to Intel's specs the destination of bsf will
>be UNDEFINED if the source is zero. It may be overwritten by the last bsf if ebx
>is zero.
>
>I do not have my FirstPiece() function at hand, but I needed to use a
>conditional move for exactly that case. As far as I recall you are using an AMD
>processor. That might be the reason why it works.

There is a caveat:
You must never call this routine with an empty bitboard.  Since we call it with
the fully populated board, there will always be at least two kings on it.



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.