Author: Dieter Buerssner
Date: 03:38:37 02/20/04
Go up one level in this thread
On February 20, 2004 at 06:06:32, Dieter Buerssner wrote: >Or perhaps: > >inline int FirstSetBit(unsigned long long a) >{ > int res; > __asm__ __volatile__ > ("bsfl %1, %0 \n" > "addl $32, %0 \n" > "bsfl %2, %0 \n" > : "=r&" (res) > : "g"((unsigned long)a), "g" ((unsigned long)(a>>32)) > : "cc"); > return res; >} Hmmm, this may not work always. "g" means any register, memory operand or immediate value. But bsf won't work for immediate values. So, in situations where the compiler knows the concrete value of a, this would fail, because it would use an immediate value for bsf (bsfl $1815, %eax). So, one probably should use: : "rm"((unsigned long)a), "rm" ((unsigned long)(a>>32)) r for any register, m for any memory operand (the machine supports). Regards, Dieter
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.