Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Please test "bsf eax, VAR", VAR==0

Author: David Rasmussen

Date: 14:45:30 01/17/02

Go up one level in this thread


On January 17, 2002 at 17:05:41, Dann Corbit wrote:

>On January 17, 2002 at 08:19:25, Severi Salminen wrote:
>
>>I'd really like to know if it is safe to assume, the eax will be left
>>unaffected.
>>
>>Som do this:
>>
>>mov eax,0xffffffff
>>mov dword ptr VAR,0
>>
>>start:
>>bsf eax,dword ptr VAR
>>cmp eax, 0xffffffff
>>jne exit
>>bsr eax,dword ptr VAR
>>cmp eax, 0xffffffff
>>jne exit
>>jmp start
>>exit:
>>
>>Let it run a little and check if it ever goes to exit:. I have not yet gotten
>>any good answers from Intel, but they are working on it. I won't use the fast
>>firstbit() and lastbit() versions if the above assumption is not valid.
>
>You can certainly do a test and branch version instead of the more primitive
>method.  One thing for sure, the brancheless notion will *not* work if you give
>it a bitboard that is purely empty (no bits set in either half).  Emperically,
>you can try the evil undefined behavior trick which is branchless and "appears
>to work on all 32 bit intel chips and clones" but for which there are no
>guarantees.
>
>Fortunately, 64 bit chips are coming along soon which will greatly simplify the
>whole mess.

Me, in my Homer Simpson voice: "Mmmm.... 64 bits..."

/David



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.