Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: FirstBit() in assembler

Author: Severi Salminen

Date: 13:03:01 01/13/02

Go up one level in this thread


O
>>I do something like this (Dann Corbit's trick):
>>
>>        bsf eax dword ptr bitboard+4
>>        add eax 32
>>        bsf eax dword ptr bitboard
>>
>
>I don't understand that. 32 is added to eax no matter what. So the result is
>always at least 32.
>
>Where can I see this code in action?

No, the point is that (the above assumes that index 0 is in 1st bit in bitboard
and index 63 is in last place of bitboard+4) if there are 1-bits in the lower
part the second bsf will overwrite the eax (including the add eax,32) it won't
add the result to eax. If there are only 0-bits in lower part, then the 2nd bsf
won't have any influence (according to specs bsf leaves eax "undefined" in case
of no bits found -situation...). So the above is based on the assumption that
the specs are not totally accurate. You can play safe (what I've been doing) by
adding one conditional jump and reversing the order of bsf's.

Severi



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.