Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bit counting revisited

Author: Andrzej Nagorko

Date: 12:24:51 04/20/00

Go up one level in this thread


On April 20, 2000 at 13:43:30, Flemming Rodler wrote:

>On April 20, 2000 at 12:46:19, KarinsDad wrote:
>
>>I have a question on your statistics.
>>
>>Did you enter in ALL combinations of bit patterns x number of times for your
>>test, or did you enter in set bit patterns x number of times, or did you enter
>>in random bit patterns x number of times?
>>
>>KarinsDad :)
>
>
>I used the pattern 2^N-1 for N bits set so it is fixed. It should not matter if
>the bits are ialways the same or at random positions. The number of intructions
>performed  in the first algorithm is only depedent on N and not the location of
>the 1-bits. The 3 other algorithms are constant regardless of input. Just to
>verify that there where no subtle differences in the time of the performed
>maschine code instructions depepending on the input I also ran some tests with
>random bits and the results were the same. Running ALL combinations of bit
>patterns is infeasable - else chess whould have been solved already :-)
>
>Best regards
>Flemming
>
>PS: I still hope someone can show me how to inline assembler under gcc.

Hopefully this helps (and works! :) :

#define firstone(b) \
({ int __value; long long int __arg = (b); \
   asm ("bsfl %1,%0\n\t" \
	"jnz 1f\n\t" \
	"bsfl 4+%1,%0\n\t"\
	"jz 2f\n\t" \
	"addl $32,%0\n\t" \
	"jmp 1f\n\t" \
	"2:\n\t" \
	"movl $64,%0\n\t" \
	"1:\n\t" \
	: "=r" (__value) \
	: "o"  (__arg) ); \
	__value; })

best wishes,
Andrzej Nagorko



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.