cnttzdm
Count Trailing Zeros Doubleword under Mask
Counts trailing zeros in RS, but only considering bits set in mask RB.
Details
The cntlzdm instruction counts the number of consecutive zero bits starting at bit 0 of register RS, but only considering the bits that are set to 1 in register RB as a mask. The result is placed into register RA.
Pseudocode Operation
n ← 0
count = 0
do while n < 64
do i = 0 to 63
if((RB)i=1) then do
n ← n + 1
if((RS)i=1) then break
count ← count + 1
end
end
RA ← EXTZ64(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