Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: FirstOne for Linux

Author: Russell Reagan

Date: 11:16:15 03/29/03

Go up one level in this thread


This will return the location of the least significant bit. Dieter helped me
with this one some time ago. The syntax that GCC uses for inline assembly is
AT&T syntax I believe, as opposed to the Intel syntax, which is what MSVC uses.
I'm not sure if this is the most optimal way to do it, but it worked for me, and
I figure that Dieter knows this stuff way better than me :)

int LowBit (Bitboard b) {
	int result;
	__asm__ volatile ("
		movl	$-33, %0
		bsfl	%2, %0
		addl	$32, %0
		bsfl	%1, %0"
		: "=q" (result)
		: "g" ((unsigned long)b), "g" ((unsigned long)(b>>32))
		: "cc" );
	return result;
}



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.