Author: Sune Fischer
Date: 04:19:06 12/02/02
Go up one level in this thread
On December 01, 2002 at 17:05:06, Gerd Isenberg wrote:
>oups, something shorter and faster:
>
>int getBitIndex(BitBoard singleBit)
>{
> __asm
> {
> pxor mm2, mm2 ; 0
> movd mm0, [singleBit]
> punpckldq mm0, [singleBit+4]
> pcmpeqd mm6, mm6 ; -1
> pxor mm7, mm7 ; 0
> pcmpeqd mm2, mm0 ; ~mask of the none zero dword
> PI2FD mm1, mm0 ; 3f8..,400..
> pxor mm2, mm6 ; mask of the none zero dword
> psrlq mm6, 63 ; 01
> psrld mm1, 23 ; 3f8 to 7f
> psrld mm2, 25 ; 7f mask
> psllq mm6, 32+5 ; 20:00
> psubd mm1, mm2 ; - 7f mask
> por mm1, mm6 ; + 32 in high dword
> pand mm1, mm2 ; & 7f mask
> psadbw mm1, mm7 ; add all bytes
> movd eax, mm1
> }
>}
This is great, I will try it.
What I really need is GetFirstBitAndReset() functions.
You posted this (for uint64):
__asm
{
xor edx, edx
mov ebx, [bb]
mov eax, edx
inc edx
bsf ecx, [ebx]
jnz found
bsf ecx, [ebx + 4]
lea ebx, [ebx + 4]
xor eax, 32
found:
shl edx, cl
xor eax, ecx
xor [ebx], edx
}
Is it possible to make it xor out the bit it found too?
Perhaps it is too complicated, in my case I think b&(-b) needs to be in
assembler, so that the precondition is removed entirely.
Is it possible to do a similar optimization on 32 bit?
I have this:
uint32 FirstBit32(uint32 bitmap)
{
__asm
{
bsf eax, [bitmap]
jnz done
mov eax, 0
done:
}
}
I would like functions that precondition the bitboard is not empty, ie. that at
least 1 bit is set. The little function above isn't optimized for that, how do I
change it?
Thanks :)
-S.
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.