Author: Dieter Buerssner
Date: 15:25:41 02/16/04
Go up one level in this thread
On February 15, 2004 at 16:29:51, Dann Corbit wrote: >FORCEINLINE int PopCnt(BITBOARD a) >{ > /* Because Crafty bitboards are typically sparsely populated, we use a > streamlined version of the boolean.c algorithm instead of the one in x86.s >*/ > __asm { > mov ecx, dword ptr a > xor eax, eax > test ecx, ecx > jz l1 > l0: lea edx, [ecx - 1] > inc eax > and ecx, edx > jnz l0 > l1: mov ecx, dword ptr a + 4 > test ecx, ecx > jz l3 > l2: lea edx,[ecx - 1] > inc eax > and ecx, edx > jnz l2 > l3:} >} I have seen this code many times. I also commented on it many times (never got any answer to the point). Why would you want to code this in inline assembly? To me it seems, equivalent C code (possibly micro optimized fór some environment, but still more general than the assembly) will run faster (I showed examples several times - IIRC including examples of what MSVC made of the C code and some reasoning about not needed "mov ecx, dword ptr a" when using C). Regards, Dieter
This page took 0.01 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.