Author: David Rasmussen
Date: 13:29:37 01/13/02
Go up one level in this thread
On January 13, 2002 at 15:06:27, Tim Foden wrote: >On January 13, 2002 at 08:48:13, David Rasmussen wrote: > >>Even though I try to keep my program extremely portable and ANSI/ISO C++ >>compliant, except for the parts that can't be, I would like to see how much >>faster my program would be with an inline assembler version of my FirstBit() >>function for use in VC++ (jeez, when will 64-bit processors be common...). >> >>My board setup is a1=0,...,h8=63. For some reason, I can't get it to work. >> >>int FirstBit(BitBoard bitboard) >>{ >> __asm { >> bsr edx, dword ptr bitboard >> mov eax, 0 >> jnz l1 >> bsr edx, dword ptr bitboard+4 >> mov eax, 32 >> jnz l1 >> mov edx, -1 >> l1: add eax, edx >> sub eax, 1 >> } >>} >> >>This is written from me head, as I have deleted what I previously did, so I >>haven't even tried to compile this, but you get the idea. The problem was that >>for some bitboards, it returned the correct value, but for some other bitboards, >>bsr just returned some weird wrong number, which made the entire function return >>some weird wrong number. What's the problem? > >1) Why are you subtracting 1 at the end? This would seem to return -2..62 >instead of -1..63. >2) mov edx, -1 seems wrong. eax contains 32 here, so the final result will be >32-1-1 == 30. Maybe remove the final sub, and make this: mov edx, -33? > >Chees, Tim. I don't know what I was thinking at that moment. Any, I've found a solution now. /David
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.