Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Begging for assembler FirstOne() and LastOne()

Author: Vincent Diepeveen

Date: 16:48:04 05/18/02

Go up one level in this thread


On May 18, 2002 at 13:38:02, Matthias Gemuh wrote:

>
>Hi Experts,
>I want to speed up my chess engine and need assembler versions of these
>functions. These below seem to be pentium-specific. I need something general
>and don't understand assembler.

they are general functions, but indeed they are very slow
functions. 2 very slow jnz instructions are there. Not the instruction
is that slow, but if it gets wrong predicted then the branch is
giving loads of penalties.

If i remember well some time ago a way faster version for the K7
was posted, which also seems to work for the P3 (p4 i do not know),
though that is not garantueed.

>int FirstBit(BITBOARD a)
>{
>  __asm {
>        bsr     edx, dword ptr a+4
>        mov     eax, 31
>        jnz     l6
>        bsr     edx, dword ptr a
>        mov     eax, 63
>        jnz     l6
>        mov     edx, -1
>  l6:   sub     eax, edx
>  }
>}
>
>int LastBit(BITBOARD a)
>{
>  __asm {
>        bsf     edx, dword ptr a
>        mov     eax, 63
>        jnz     l7
>        bsf     edx, dword ptr a+4
>        mov     eax, 31
>        jnz     l7
>        mov     edx, -33
>  l7:   sub     eax, edx
>  }
>}
>
>Please, help me.
>
>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.