Count trailing zeros

The ctz instructions, short for count trailing zeros, are used to count the amount of zeros at the start of the numbers binary representation.

Try it


;; load a number onto the stack
i32.const 8388608 ;; 00000000_10000000_00000000_00000000

;; count trailing zeros

;; the top item on the stack will now be 23
Instruction Binary opcode
i32.ctz 0x68
i64.ctz 0x7a