Arm/popcount
From ASMBits
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 15 lines.
Sample Input
5 255
Sample Output
2 8
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 15 lines.
5 255
2 8
// A test case to test your function with .global _start _start: mov r0, #5 bl popcount 1: b 1b // Done // Only your function (starting at popcount) is judged. The test code above is not executed. popcount: