Author: Gerd Isenberg
Date: 11:28:57 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
May be your compiler settings are wrong, eg. for msvc6 "project settings / C-C++
/ optimization / Inline function expansion" should at least set on "Only
__inline", but not "disabled".
As Anthony already meantioned, the function should be defined (and not only a
prototype declaration) in some common header file of course.
You may try a safe conditional 64-bit bitscan, eg. "jnz found" after the first
bsf. May be the (often correct predicted) branch outperforms the expensive and
conditional skipped second "bsf".
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.