assembly

Population Count using popcnt instruction (counting number of on bits)

Using popcnt instruction found on newer processors to get population count which is number of set bits. Reference : SSE4 Here are couple example inputs with expected output. 0xA = 1010 — > 2 0x3F2 = 1111110010 — > 7 #include <iostream> #include <stdio.h>   using namespace std;   int main() { // 0xA = …

Population Count using popcnt instruction (counting number of on bits) Read More »