Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: To Georg v. Zimmermann, lastSquare()

Author: Georg v. Zimmermann

Date: 09:30:46 01/22/02

Go up one level in this thread


Hey Matthias,

I am honored but we must give credit where credit is due. :) That firstSquare()
came from the Corbit wizzard.

Below is the _asm for popCount taken from Beowulf. About lastSquare() I dont
know if something faster than whats in Crafty is possible, but I am just a guy
who knows nothing about _asm and a little bit about chess algorithms.

#ifdef MMX_POPCOUNT
#include "amd3dx.h"

/* Athlon MMX optimized popcount function, based on AMD's Athlon
   optimization manuals */

FORCEINLINE int Count(BITBOARD v)
{
    static const __int64 C55 = 0x5555555555555555;
    static const __int64 C33 = 0x3333333333333333;
    static const __int64 C0F = 0x0F0F0F0F0F0F0F0F;

    __asm {
        movd            mm0, word ptr v;
        punpckldq       mm0, word ptr v + 4;
        movq            mm1, mm0;
        psrld           mm0, 1;
        pand            mm0, [C55];
        psubd           mm1, mm0;
        movq            mm0, mm1;
        psrld           mm1, 2;
        pand            mm0, [C33];
        pand            mm1, [C33];
        paddd           mm0, mm1;
        movq            mm1, mm0;
        psrld           mm0, 4;
        paddd           mm0, mm1;
        pand            mm0, [C0F];
        pxor            mm1, mm1;
        psadbw(mm0, mm1);
        movd            eax, mm0;
        emms;
    }
}
#else
FORCEINLINE int Count(BITBOARD a)
{
/* I think Dann stole this code from Crafty */
    __asm {
           mov  ecx, dword ptr a
           xor eax, eax
           test ecx, ecx
           jz l1
    l0:
           lea edx, [ecx - 1]
           inc eax
	               and ecx, edx
           jnz l0
    l1:
           mov ecx, dword ptr a + 4
           test ecx, ecx
           jz l3
    l2:
           lea edx, [ecx - 1]
           inc eax
	               and ecx, edx
           jnz l2
    l3:
    }
}
#endif


Good luck !


On January 22, 2002 at 04:30:04, Matthias Gemuh wrote:

>
>Hi Georg,
>I tried your firstSquare() with Borland C++ Builder 5, and it works!
>I did not "inline" it anyway. Can you, please, post your lastSquare() here
>or send it to me?
>I don't know Assembler, but would like to see how my program performs with
>firstSquare(), lastSquare() and BitCount() coded in Asm. I don't have
>BitCount() yet, but it should count the bits in a 64-Bit integer.
>Every other thing in my program will remain in C/C++.
>
>Thanks,
>Matthias.



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.