Author: Gerd Isenberg
Date: 14:05:06 12/01/02
Go up one level in this thread
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 page took 0.03 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.