cnttzd

Count Trailing Zeros Doubleword

cnttzd RA, RS

Counts the number of trailing zeros in 64-bits.

Details

The cnttzd instruction counts the number of trailing zero bits in a doubleword (64-bit) value. It starts from the least significant bit and counts zeros until it encounters a one.

Pseudocode Operation

n ←0
do i = 0 to 63
   if (RS)i = 1 then leave
RA ←n

Programming Note

The cnttzd instruction is useful for quickly determining the position of the least significant set bit in a 64-bit value. It operates efficiently on any aligned doubleword, but be cautious with unaligned data as it may lead to unexpected results or exceptions. This instruction can be executed at user privilege level without requiring special permissions.

Example

cnttzd r4, r3

Encoding

Binary Layout
31
0
RS
6
RA
11
/
16
570
21
/
31
 
Format X-form
Opcode 0x7C00047A
Extension Base

Operands

  • RA
    Target
  • RS
    Source