Hi there,

Im pretty new to assembly and have been working on a program that is supposed to count the number of significant bits in a variable length vector composed of 32 bit words.  Here is the main code in c++.  By the way full disclosure this is an uni homework, im not expecting a full solution but cues to get me started. 

Thanks!!


void main (void)
{
const UInt32 dim = 3;
UInt32 vecteur;
UInt32 bitCount;
vecteur[0] = 0x556677;
vecteur[1] = 0;
vecteur[2] = 0x5A;
bitCount = countSignificantBits (dim, vecteur);
Console::WriteLine ("Nombre de bits significatifs: {0:D}", bitCount);
Console::WriteLine ("{0:x8}",vecteur[0]);
}


Posted on 2011-12-05 17:36:38 by massamble1

Hi there,

Hallo  :)

Im pretty new to assembly and have been working on a program that is supposed to count the number of significant bits in a variable length vector composed of 32 bit words.  Here is the main code in c++.  By the way full disclosure this is an uni homework, im not expecting a full solution but cues to get me started. 

googling exactly popcount, You will find implementations
and explanations. the first 5 items match surely what You need.

i wrote this at http://groups.google.com/group/comp.lang.asm.x86/browse_frm/thread/6c8b3f09d890af1b
then evolving from that snippet, i reached the  4 bytes/clock cycle
using SSE3, as fast as the CSA (Carry Save Adder) method
but 1/3 the codesize.

it seems impossible at the moment to break the barrier of 4 bytes/clock cycle.

Cheers,
hopcode
x64lab
Posted on 2011-12-05 22:44:32 by hopcode