cntlzd
Count Leading Zeros Doubleword
cntlzd RT,RA
cntlzd. RT,RA
cntlzd. RT,RA
Counts the number of consecutive 0 bits starting from bit 0 (MSB of 64-bit reg).
Details
Counts the number of consecutive zero bits from the MSB (bit 0) of the 64-bit doubleword in RS and stores the result in RT. The count ranges from 0 to 64. If Rc=1, CR0 is updated based on the result.
Pseudocode Operation
n ← 0
while n < 64 and RS[n] = 0 do n ← n + 1
RT ← n
if Rc = 1 then CR0 ← (RT = 0, RT < 0, RT > 0, SO)
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
// r3 = Leading Zeros in 64-bit r4.
Encoding
Binary Layout
31
0
RS
6
RA
11
00000
31
000111010
Rc
Operands
-
RA
Target Register -
RS
Source Register -
RT
Target General Purpose Register