cntlzw
Count Leading Zeros Word
cntlzw RA, RS
Counts the number of consecutive 0 bits starting from bit 32 (MSB of the low word).
Details
Counts the number of consecutive zero bits from the MSB (bit 0) of the 32-bit word in RS and stores the result in RA. The count ranges from 0 to 32. If Rc=1, CR0 is updated based on the result.
Pseudocode Operation
n ← 0
while n < 32 and RS[n] = 0 do n ← n + 1
RA ← n
if Rc = 1 then CR0 ← (RA = 0, RA < 0, RA > 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
cntlzw r3, r4
// r3 = Leading Zeros in lower 32-bits of r4.
Encoding
Binary Layout
31
0
RS
6
RA
11
00000
16
000011010
21
Rc
31
Operands
-
RA
Target Register -
RS
Source Register