Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: 2M+ nps Crafty (Question for Bob)

Author: Dann Corbit

Date: 21:10:41 02/26/04

Go up one level in this thread


On February 26, 2004 at 23:59:22, Russell Reagan wrote:

>On February 26, 2004 at 23:55:15, Slater Wold wrote:
>
>>Whenever I use /DUSE_ASSEMBLY /DINLINE_AMD, I get the following error:
>>
>>Microsoft (R) C/C++ Optimizing Compiler Version 14.00.2207 for AMD64
>>Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
>>
>>x1.c
>>c:\c64\inlineamd.h(6) : error C2061: syntax error : identifier 'FirstOne'
>>c:\c64\inlineamd.h(6) : error C2059: syntax error : ';'
>>c:\c64\inlineamd.h(6) : error C2059: syntax error : 'type'
>>c:\c64\inlineamd.h(21) : error C2061: syntax error : identifier 'LastOne'
>>c:\c64\inlineamd.h(21) : error C2059: syntax error : ';'
>>c:\c64\inlineamd.h(21) : error C2059: syntax error : 'type'
>>c:\c64\inlineamd.h(36) : error C2061: syntax error : identifier 'PopCnt'
>>c:\c64\inlineamd.h(36) : error C2059: syntax error : ';'
>>c:\c64\inlineamd.h(36) : error C2059: syntax error : 'type'
>>x1.c(8213) : warning C4028: formal parameter 1 different from declaration
>>NMAKE : fatal error U1077: 'cl' : return code '0x2'
>>Stop.
>>
>>
>>Any ideas?
>
>I haven't looked at this, but my first guess is that you are trying to use Bob's
>assembly that was written for gcc. gcc uses AT&T style assembly, while Microsoft
>compilers use Intel style assembly.

You guessed correctly.

/*
     AMD Opteron inline functions for FirstOne(), LastOne() and
     PopCnt().  Note that these are 64 bit functions and they use
     64 bit (quad-word) X86-64 instructions.
*/
int static __inline__ FirstOne(long word)
{
  long      dummy, dummy2;

asm("          bsrq    %0, %1"                       "\n\t"
    "          jnz     1f"                           "\n\t"
    "          movq    $-1, %1"                      "\n\t"
    "1:        movq    $63, %0"                      "\n\t"
    "          subq    %1, %0"                       "\n\t"
    :"=r&"(dummy), "=r&" (dummy2)
    :"0"((long) (word))
    :"cc");
  return (dummy);
}

int static __inline__ LastOne(long word)
{
  long      dummy, dummy2;

asm("          bsfq    %0, %1"                       "\n\t"
    "          jnz     1f"                           "\n\t"
    "          movq    $-1, %1"                      "\n\t"
    "1:        movq    $63, %0"                      "\n\t"
    "          subq    %1, %0"                       "\n\t"
    :"=r&"(dummy), "=r&" (dummy2)
    :"0"((long) (word))
    :"cc");
  return (dummy);
}

int static __inline__ PopCnt(long word)
{
  long      dummy, dummy2, dummy3;

asm("          xorq    %0, %0"                      "\n\t"
    "          testq   %1, %1"                      "\n\t"
    "          jz      2f"                          "\n\t"
    "1:        leaq    -1(%1),%2"                   "\n\t"
    "          incq    %0"                          "\n\t"
    "          andq    %2, %1"                      "\n\t"
    "          jnz     1b"                          "\n\t"
    "2:                      "                      "\n\t"
    :"=r&"(dummy), "=r&"(dummy2), "=r&" (dummy3)
    :"1"((long) (word))
    :"cc");
  return (dummy);
}




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.