I'm having a trouble of thinking of way to count the number of 1 bits in a binary number with out using any condition tests or branches. Only ones i know have condition tests or branches like

Code:
while (n!=0)
{
count++;
n=n&(n-1)
}
This is for my assembly language class and I'm supposed to use any kind of shifting or and/or. But if I saw it in C++ i probably be able to convert it.