Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: On Beowulf - long post

Author: Dann Corbit

Date: 21:35:31 06/05/01

Go up one level in this thread


On June 05, 2001 at 20:18:30, Vincent Diepeveen wrote:
[snip]
>For some weird reason i hardly see assembly posted here :)

I've posted a few snippets, and I am sure that you saw this thingy in board.h of
Beowulf:

#if _MSC_VER >= 1200
#define FORCEINLINE __forceinline
#else
#define FORCEINLINE __inline
#endif

FORCEINLINE
int             FirstPiece(BITBOARD bits)
{
//    if (bits == 0) return -1;
    __asm {
        ; 64 - bit number to move into ECX:EBX, will never be zero !
        mov ecx, dword ptr[bits + 4]
        mov ebx, dword ptr[bits]
        bsf eax, ecx
        add eax, 32
        bsf eax, ebx
    }
}

but I think there is a good reason most people post in C.  This routine is
totally uninteresting to a Macintosh programmer and an Alpha programmer.  But
the same idea in C would be universally available.  Also, the method to
interface with assembly language -- even on a target architecture like 80x86
will vary quite a bit from language to language and even from compiler to
compiler.

A good assembly language snippet will never revolutionize your program (unless
you were doing something boneheaded before).  It will only give you a small
constant factor in speedup and that only if the routine in question was a hard
bottle-neck.

I think probably here we are interested mostly in algorithms.  I think C is a
very good universal language to communicate that.  It is close to the hardware,
and yet abstract enough to be easily grasped.  It could be considered as
something of a "portable assembler" though you obviously don't have lots of real
assembly details like rol/ror bsf/bsr etc.  But you do have inc and dec and shr
and shl and lots of other simple primitives.  So we can think about the ideas
rather than the details.  And once we understand the ideas it is very easy to
translate them into any language we like.



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.