cnttzdm
Count Trailing Zeros Doubleword under Mask
Counts trailing zeros in RS, but only considering bits set in mask RB.
Details
Counts the number of trailing zeros in RS considering only the bit positions set to 1 in the mask RB (Power10 Scalar). The count is placed in RA. No CR, XER, or FPSCR fields are affected.
Pseudocode Operation
mask ← RB; masked_value ← RS ∧ mask; if (masked_value = 0) then RA ← 64; else count ← 0; for i in 63 downto 0 do; if (masked_value[i] = 1) then break; count ← count + 1; RA ← count;
Programming Note
The cnttzdm instruction is useful for counting trailing zeros in a doubleword while applying a mask. Ensure that the mask register (RB) has bits set to 1 where you want to consider the corresponding bits in the source register (RS). The result is zero-extended to 64 bits before being stored in the destination register (RA). This instruction operates at user privilege level and does not generate any exceptions under normal conditions. Performance may vary based on the distribution of zeros and ones in the registers.
Example
Encoding
Operands
-
RA
Target -
RS
Source -
RB
Mask -
RT
Target General Purpose Register