Author: Filip Tvrzsky
Date: 16:50:56 03/29/03
Go up one level in this thread
On March 29, 2003 at 19:37:22, Sune Fischer wrote: >On March 29, 2003 at 14:16:15, Russell Reagan wrote: > >>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; >>} > >Hmm, I get warnings: > >"bits.h:117:27: warning: multi-line string literals are deprecated" > >-S. Please, see my previous message http://www.talkchess.com/forums/1/message.html?291092 So modify the code following way: int LowBit (Bitboard b) { int result; asm volatile ("\n\ movl $-33, %0 \n\ bsfl %2, %0 \n\ addl $32, %0 \n\ bsfl %1, %0 \n" : "=q" (result) : "g" ((unsigned long)b), "g" ((unsigned long)(b>>32)) : "cc" ); return result; } Filip
This page took 0.02 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.