Author: Robert Hyatt
Date: 08:38:46 02/06/03
Go up one level in this thread
On February 06, 2003 at 06:30:17, David Rasmussen wrote:
>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]
> }
>}
Note that is unsafe. It works for the moment, but it might not work in the
future, leading to a lot of unnecessary debugging.
>
>INLINE int LastBit(const BitBoard bitboard)
>{
> __asm
> {
> bsr eax,[bitboard]
> sub eax,32
> bsr eax,[bitboard+4]
> add eax,32
> }
>}
Same comment applies.
>
>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
Look at crafty source code, in particular lock.h. I just finished an inline asm
Lock()
and Unlock() function that work just fine with gcc/g++.
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.