Author: Jaime Benito de Valle Ruiz
Date: 05:05:08 01/20/04
Go up one level in this thread
On January 20, 2004 at 06:11:12, Steve Maughan wrote:
>I have been having problems linking assembler routines into Monarch. I'm using
>Visual Studio .NET 2003. The following routine runs with no problems:
>
>int bsf(bitboard a)
>{__asm
> {
> bsf eax, dword ptr[a + 4]
> add eax, 32
> bsf eax, dword ptr[a]
> }
>}
>
>No doubt many will recognize it as the classic "Bit Scan First" routine.
>However if I add a '__forceinline' or '_inline' before the 'int' I get the
>following errors when the program links (it generates code with no errors):
>
>Linking...
>board.obj : error LNK2019: unresolved external symbol _bsf referenced in
>function _clear_board
>checks.obj : error LNK2001: unresolved external symbol _bsf
>genmove.obj : error LNK2019: unresolved external symbol _bsf referenced in
>function _generate_black_evade_check
>test.obj : error LNK2001: unresolved external symbol _bsf
>Release/Monarch.exe : fatal error LNK1120: 1 unresolved externals
>
>What am I doing incorrectly? I've looked through the project options and cannot
>identify any options to 'tick'.
>
>All help appreciated!
>
>Steve Maughan
Far from being the most "elegant" solution, at least this macro will do the
trick (works in MSVC6):
#define BSFF(a,b) { \
__asm{ \
__asm bsf eax, dword ptr[a + 4] \
__asm add eax, 32 \
__asm bsf eax, dword ptr[a] \
__asm mov dword ptr[b],eax \
}}
where "a" is a 64-bit variable, and "b" another 32-bit variable used to output
the result.
Example:
__int64 a=0x1000; // (set the 12th bit on)
int b;
BSFF(a,b);
printf("%d ",b); // it should print "12"
Regards,
Jaime
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.