Lucas Braesch

Joined: 31 May 2010 Posts: 1757
|
Post subject: Re: First One Posted: Sun May 27, 2012 12:16 pm |
|
|
| José Carlos wrote: |
Hi. Sorry if this has already been answered before.
I'm trying to compile an old engine of mine in 64 bits. I have some old asm code for FirstOne() (left and right, I mean, MSB and LSB) which won't compile for X64.
Is there some C code out there I can use for the tasks?
I don't care much for speed. I just want it to be problem-free.
Thanks in advance. |
From Stockfish. fast and portable
| Code: |
static const unsigned BitTable[NB_SQUARE] = {
0, 1, 2, 7, 3, 13, 8, 19, 4, 25, 14, 28, 9, 34, 20, 40, 5, 17, 26, 38, 15,
46, 29, 48, 10, 31, 35, 54, 21, 50, 41, 57, 63, 6, 12, 18, 24, 27, 33, 39,
16, 37, 45, 47, 30, 53, 49, 56, 62, 11, 23, 32, 36, 44, 52, 55, 61, 22, 43,
51, 60, 42, 59, 58
};
unsigned first_bit(uint64_t b)
/* From Stockfish */
{
return BitTable[((b & -b) * 0x218a392cd3d5dbfULL) >> 58];
} |
|
|