Population count

The popcnt instructions, short for population count, are used to count the amount of 1s in a numbers binary representation.

Try it


;; load a number onto the stack
i32.const 130 ;; 10000010

;; count the 1s

;; the top item on the stack will now be 2
Instruction Binary opcode
i32.popcnt 0x69
i64.popcnt 0x7b