Author: Frank E. Oldham
Date: 00:56:03 02/18/04
Go up one level in this thread
On February 18, 2004 at 03:29:21, Andreas Guettinger wrote:
>On February 17, 2004 at 22:37:32, Frank E. Oldham wrote:
>
>>uses assembly language FirstOne and LastOne;
>>for example,
>> square = FirstOne(temp)
>>becomes
>> asm("cntlzd %0, %1" : "=r" (square) : "r" (temp));
>>and
>> from = LastOne(piecebd);
>>becomes
>> asm("cntlzd %0, %1" : "=r" (from) : "r" (piecebd ^ (piecebd - 1)));
>
>Nice NPS. :)
>
>Do these FirstOne() LastOne() also work on a G4?
>
>regards
>Andy
Not quite -- cntlzd is a 64-bit instruction, "count leading zeros double" -- but
the G4
only has the 32-bit analogue cntlzw, so each half of the bitboard has to be done
separately.
In MW-compatible asm, it looks like:
asm int __inline__ FirstOne(BITBOARD arg1)
{
/*
register unsigned long i;
if (i = a >> 32)
return (__cntlzw(i));
if (i = (unsigned int) a)
return (__cntlzw(i) + 32);
return (64);
*/
mr. r5, r3;
beq @2;
cntlzw r3, r5;
blr;
@2
cntlzw r3, r4;
addi r3, r3, 32;
}
and similarly for LastOne.
Frank
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.