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
The cntlzw instruction counts the number of consecutive zero bits starting at bit 32 of register RS and places this count into register RA. The result ranges from 0 to 32, inclusive. If Rc is set to 1, CR field 0 is updated to reflect the result.
Pseudocode Operation
n <- 0; while RS[32+n] = 0 do n <- n + 1; RA <- n
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
Encoding
Binary Layout
31
0
RS
6
RA
11
00000
16
000011010
21
Rc
31
Operands
-
RA
Target Register -
RS
Source Register