Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Assembly Programmers Challenge! (repost and clarification)

Author: Gerd Isenberg

Date: 23:46:02 01/21/03

Go up one level in this thread


On January 21, 2003 at 20:04:10, David Rasmussen wrote:

>On January 21, 2003 at 19:56:18, David Rasmussen wrote:
>
>>
>>It only seems to look at the first byte of the input, and the numbers returned
>>are nonsense.
>>
>
>Sorry, my mistake!!
>
>I am tired, so I defined C55 to be 0x55; etc... :)
>
>It works now, but it's slower for me than the other version. Why?
>
>/David

now idea David, lot of interferences possible. It's even microscopic or noise...
May be alignment of the consts:

// in some h file
#define CACHE_LINE  32
#define CACHE_ALIGN __declspec(align(CACHE_LINE))
#define BITBOARD_ALIGN __declspec(align(8))

// in some c/cpp file
const SBitCountConsts CACHE_ALIGN BitCountConsts =
{
	0x3333333333333333,	// C33
	0x5555555555555555,	// C55
	0x0f0f0f0f0f0f0f0f,	// C0F
        .....
};

What about only skipping the emms or using femms in your original code.
Btw. for bitScan i use this routine with reset the found bit. The first version
(USE_SAVE_BSF) with the condition is faster for me than the second.
Remember that bsf/bsr with zero register leaves the target register undefined,
which is probably unchanged with current processors...

__forceinline
UINT BitSearchAndReset(BitBoard &bb)
{
#ifdef	_M_IX86
#ifdef USE_SAVE_BSF
	__asm
	{
		xor		edx, edx
		mov		ebx, [bb]
		xor		eax, eax
		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
	}
#else
	__asm
	{
		mov		edx, [bb]
		bsf		eax, [edx+4]
		xor		eax, 32
		bsf		eax, [edx]
		btr		[edx],eax
	}
#endif
...
}

Regards,
Gerd



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.