Author: Gerd Isenberg
Date: 08:40:24 12/10/01
Go up one level in this thread
Following code works well on my Celeron-Notebook and even on my Athlon-PC. It
seems that "bsf" target register is not affected if no bit is found, hopefully
undefined means unchanged on PIII and PIV.
Gerd
#ifdef _M_IX86
// precondition: BitBoard not empty
__forceinline unsigned int BitSearchAndReset(BitBoard &bb)
{
__asm
{
mov edx, [bb]
bsf eax, [edx+4]
add al, 32
bsf eax, [edx]
btr [edx],eax
}
}
#else
...
http://developer.intel.com/design/Pentium4/manuals/24547104.pdf
BSF¡ªBit Scan Forward
Description
Searches the source operand (second operand) for the least significant set bit
(1 bit). If a least
significant 1 bit is found, its bit index is stored in the destination operand
(first operand). The
source operand can be a register or a memory location; the destination operand
is a register. The
bit index is an unsigned offset from bit 0 of the source operand. If the
contents source operand
are 0, the contents of the destination operand is undefined.
Operation
IF SRC =0
THEN
ZF ¡û1;
DEST is undefined;
ELSE
ZF ¡û0;
temp ¡û0;
WHILE Bit(SRC, temp) =0
DO
temp ¡ûtemp + 1;
DEST ¡ûtemp;
OD;
FI;
Opcode Instruction Description
0F BC BSF r16,r/m16 Bit scan forward on r/m16
0F BC BSF r32,r/m32 Bit scan forward on r/m32
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.