cnttzw
Count Trailing Zeros Word
Counts the number of trailing zeros in the low 32-bits.
Details
Counts the number of trailing zero bits in the low 32 bits of general-purpose register RS and stores the count in RA. The count ranges from 0 to 32; if all 32 bits are zero, the result is 32. No condition register or status flags are affected.
Pseudocode Operation
count ← 0
for i in 0..31:
if RS[32+i] == 0 then count ← count + 1
else break
RA ← count
Programming Note
The cnttzw instruction is useful for quickly determining the number of trailing zeros in a word, which can be helpful in bit manipulation tasks. Be cautious with Rc=1 as it modifies CR0 based on the result, affecting subsequent conditional operations. Ensure that the input register (RS) is correctly aligned and contains valid data to avoid unexpected results.
Example
Encoding
Operands
-
RA
Target -
RS
Source