cntlzdm
Count Leading Zeros Doubleword under Mask
Counts leading zeros in RS, but only considering bits set in mask RB.
Details
The cntlzdm instruction counts the number of leading zero bits in a doubleword, but only considers the bits that are set to 1 in a mask specified by another register. The result is placed into the destination register.
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 cntlzdm instruction is useful for counting leading zeros in a doubleword while considering only the bits that are set to 1 in a mask. Ensure that both the source and mask registers are correctly aligned and that the mask register has at least one bit set to 1 to avoid undefined behavior. This instruction operates at user privilege level and does not generate exceptions under normal conditions, but it may incur performance penalties on processors without hardware support for this operation.
Example
Encoding
Operands
-
RA
Target -
RS
Source -
RB
Mask