cnttzdm

Count Trailing Zeros Doubleword under Mask

cnttzdm RA, RS, RB

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

cnttzdm r4, r3, r5

Encoding

Binary Layout
31
0
RS
6
RA
11
RB
16
571
21
/
31
 
Format X-form
Opcode 0x7C000476
Extension Base
Registers Altered CR0, XER

Operands

  • RA
    Target
  • RS
    Source
  • RB
    Mask
  • RT
    Target General Purpose Register