cntlzd

Count Leading Zeros Doubleword

cntlzd RT,RA
cntlzd. RT,RA

Counts the number of consecutive 0 bits starting from bit 0 (MSB of 64-bit reg).

Details

The cntlzd instruction counts the number of consecutive zero bits starting at bit 0 of register RS and places the result into register RA. If Rc=1, CR Field 0 is set to reflect the result.

Pseudocode Operation

n ← 0
do while n < 64
    if (RS)n = 1 then leave
    n ← n + 1
RA ← EXTZ64(n)
if Rc=1 then
    CR Field 0 is set to reflect the result

Programming Note

When Rc=1 (dot form), CR0 is updated with the signed comparison of the result against zero (LT, GT, EQ) and the current SO bit from XER.

Example

cntlzd r3, r4

Encoding

Binary Layout
31
0
RS
6
RA
11
00000
31
000111010
Rc
 
Format X-form
Opcode 0x7C000074
Extension Base
Registers Altered CR0

Operands

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