Page 1 of 1
Very Strange???
Posted: Fri Jun 01, 2007 10:28 am
by LoopList
Code: Select all
I call
bitboard_print(0xFF);
void bitboard_print(const uint64 bitboard) {
sintx rank;
sintx file;
for (rank=SQUARE_RANK8; rank >= SQUARE_RANK1; rank--) {
for (file=SQUARE_FILEA; file <= SQUARE_FILEH; file++) {
if (bitboard & bitboard_from_file_rank(file, rank))
printf_s("x");
else
printf_s("-");
}
printf_s("\n");
}
printf_s("\n");
}
and I get
--------
--------
--------
xxxxxxxx
--------
--------
--------
xxxxxxxx
in Release mode. In Debug mode I get the right bitboard?!?!
What is the problem?
Re: Very Strange???
Posted: Fri Jun 01, 2007 10:30 am
by LoopList
Code: Select all
Sorry, I forgot the function:
inline uint64 bitboard_from_file_rank(const sintx file, const sintx rank) {
return uint64(1) << uint64(file + (rank << 3));
}
Re: Very Strange???
Posted: Fri Jun 01, 2007 10:38 am
by pijl
LoopList wrote:Code: Select all
I call
bitboard_print(0xFF);
void bitboard_print(const uint64 bitboard) {
sintx rank;
sintx file;
for (rank=SQUARE_RANK8; rank >= SQUARE_RANK1; rank--) {
for (file=SQUARE_FILEA; file <= SQUARE_FILEH; file++) {
if (bitboard & bitboard_from_file_rank(file, rank))
printf_s("x");
else
printf_s("-");
}
printf_s("\n");
}
printf_s("\n");
}
and I get
--------
--------
--------
xxxxxxxx
--------
--------
--------
xxxxxxxx
in Release mode. In Debug mode I get the right bitboard?!?!
What is the problem?
perhaps call with bitboard_print(uint64(0xFF));
Richard.
Re: Very Strange???
Posted: Fri Jun 01, 2007 10:51 am
by Alessandro Scotti
Your compiler is using the 32 bit version of the left shift, but I can't reproduce this behavior with MS Visual C++, which is the only compiler I can use right now. If using gcc make sure the compiler understand that "1" require a 64-bit shift, e.g. by explicitly using (1 ULL).
Re: Very Strange???
Posted: Fri Jun 01, 2007 11:23 am
by Gerd Isenberg
LoopList wrote:Code: Select all
Sorry, I forgot the function:
inline uint64 bitboard_from_file_rank(const sintx file, const sintx rank) {
return uint64(1) << uint64(file + (rank << 3));
}
Like Alessandro mentioned, for some weird reason the variable left shift amount is modulo 32. I would try this, note that (file + 8*rank) is only one lea ecx instruction...
Code: Select all
inline uint64 bitboard_from_file_rank(const sintx file, const sintx rank) {
const uint64 one = 1;
return one << (file + 8*rank);
}
What compiler did you use?
Gerd
Re: Very Strange???
Posted: Fri Jun 01, 2007 11:50 am
by LoopList
Thanks Gerd!
I used MS VC9 Beta in x64-mode