Author: Gerd Isenberg
Date: 01:21:13 12/01/02
Go up one level in this thread
On November 30, 2002 at 23:27:56, Russell Reagan wrote:
>On November 30, 2002 at 17:44:59, Gerd Isenberg wrote:
>
>>Btw. the above routine is a bit suspicious because the manuals say that
>>bsf(reg32, zero) leaves the target register undefined (may be under some strange
>>conditions).
>
>int BitSearch_v1 (BitBoard bb)
>{
> __asm
> {
> bsf eax,[bb]
> jnz found
> bsf eax,[bb+4]
> xor eax, 32
> found:
> }
>}
>
>How about that one? Is it suspicious? Or should this work according to the
>documentation?
The preconditions is that at least one bit is set, either in the low or
highword. With this precondition the above function is conform with the
documentation - otherwise you have to do something like this:
// return: -1 if no bit is set
// 0..63 otherwise
int BitSearch_v3 (BitBoard bb)
{
__asm
{
bsf eax,[bb]
jnz finished
bsf eax,[bb+4]
jz nobitset
xor eax, 32
jmp finished
nobitset:
mov eax, -1
finished:
}
}
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.