Author: David Rasmussen
Date: 03:30:17 02/06/03
I do this (in a header file, because most implementations can't inline across
compilation units) when compiling with MSVC/Intel:
INLINE int FirstBit(const BitBoard bitboard)
{
__asm
{
bsf eax,[bitboard+4]
xor eax,32
bsf eax,[bitboard]
}
}
INLINE int LastBit(const BitBoard bitboard)
{
__asm
{
bsr eax,[bitboard]
sub eax,32
bsr eax,[bitboard+4]
add eax,32
}
}
INLINE int PopCount(BitBoard a)
{
__asm {
mov ecx, dword ptr a
xor eax, eax
test ecx, ecx
jz l1
l0:
lea edx, [ecx - 1]
inc eax
and ecx, edx
jnz l0
l1:
mov ecx, dword ptr a + 4
test ecx, ecx
jz l3
l2:
lea edx, [ecx - 1]
inc eax
and ecx, edx
jnz l2
l3:
}
}
Is there anyway to do the same when using g++/gcc ?
/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.