Author: Steven Edwards
Date: 20:02:30 05/16/05
A data point for x86 xitboard programmers:
I recently implemented inline assembly language assist for Symbolic's toolkit
for the FirstSq/NextSq functions when running on an x86 host. (I had already
done this for PowerPC hosts.) As with the PowerPC assembly assist, a speedup of
about 16% was seen in movepath enumeration tests.
Here's the wrapper for the x86 "bsfl" instruction (adapted from the g++ include
file library):
static __inline__ unsigned int __ffz(unsigned int word)
{
__asm__("bsfl %1,%0"
:"=r" (word)
:"r" (~word));
return word;
}
Here's FirstSq:
CTSq FirstSq(void) const
{
if (myDwrdVec[0] !=0)
return (CTSq) __ffz(~myDwrdVec[0]);
else
{
if (myDwrdVec[1] !=0)
return (CTSq) (__ffz(~myDwrdVec[1]) + 32);
else
return CTSqNil;
};
}
And here's NextSq:
CTSq NextSq(void)
{
if (myDwrdVec[0] != 0)
{
const unsigned int theFZ = __ffz(~myDwrdVec[0]);
myDwrdVec[0] ^= (1 << theFZ);
return (CTSq) theFZ;
}
else
{
if (myDwrdVec[1] != 0)
{
const unsigned int theFZ = __ffz(~myDwrdVec[1]);
myDwrdVec[1] ^= (1 << theFZ);
return (CTSq) (theFZ + 32);
}
else
return CTSqNil;
};
}
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.