Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Determining location of LSB/MSB

Author: Gerd Isenberg

Date: 12:00:53 02/10/04

Go up one level in this thread


On February 10, 2004 at 10:57:15, Bas Hamstra wrote:

>On February 09, 2004 at 09:07:41, Gerd Isenberg wrote:
>
>>On February 09, 2004 at 05:09:07, Renze Steenhuisen wrote:
>>
>>>
>>>Hi there!
>>>
>>>does anyone know the fastest way to determine the lcoation of the Least/Most
>>>Significant Bit, and to clear that bit?
>>>
>>>In my case the most important platforms (at the moment) are Pentium III and IV.
>>>
>>>Thanks!
>>
>>find lsb from CCC archives:
>>
>>http://chessprogramming.org/cccsearch/ccc.php?art_id=265616
>>
>>Walter Faxon's magic BitScan:
>>http://chessprogramming.org/cccsearch/ccc.php?art_id=272378
>>
>>Matt Taylor's De Bruijn folding trick:
>>http://chessprogramming.org/cccsearch/ccc.php?art_id=305965
>>
>>Gerd
>>
>>
>>>
>>>Renze
>
>Gerd,
>
>IMO the BSF instruction is still fastest. Don't test this in loops, in a
>searching engine you get quite different results and BSF is in my case clearly
>the winner,

Hi Bas,

yes, i'm aware of loop tests :-)
and i still use bsf too with my athlon XP.
But i'm working on completely get rid of it, but not only due the fact that
bsf64 is still 9 cycle vector path instruction on Opteron.


>especially for the paltforms he mentiones, and besides he is not
>talking 64 bit...

oups, sorry.

>
>
>Bas.
>
>
>int LastOne(unsigned int Number)
>
>{  asm mov EAX, Number
>   asm BSF EAX, EAX
>}

isn't that shorter?

int LastOne(unsigned int Number)
{
   asm BSF EAX, word ptr[Number]
}

Cheers,
Gerd



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.