Nios/popcount

From ASMBits

nios/bswapPrevious

Write a function that returns the number of 1 bits in a given 32-bit integer (also known as population count).

int popcount (int n);

Expected solution length: Around 10 lines.

Sample Input

5
255

Sample Output

2
8

Make sure you test all of the corner cases (What's the smallest possible answer? Largest?).

Write your solution here

Upload a source file...