clz
Count Leading Zeros (Thumb)
CLZ <Rd>, <Rm>
Counts consecutive zeros.
Pseudocode Operation
Rd ← CountLeadingZeros(Rm[31:0])
Example
CLZ r0, r2
Encoding
Binary Layout
111110101
31:23
011
22:20
Rn
19:16
1111
15:12
Rd
11:8
10
7:6
00
5:4
Rm
3:0
Operands
-
Rd
Destination general-purpose register -
Rm
Second source / offset general-purpose register
Related
Other forms of clz
Across architectures
Count Leading Zeros : how x86, ARM, RISC-V, and PowerISA each do this.
More in A32 (Base)
Reference
View in Arm A64 ISA Reference ↗
Arm AArch32 ISA
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x016F0F10 | CLZ{<c>}{<q>} <Rd>, <Rm> | A32 | cond | 00010110 | 1 | 1 | 1 | 1 | Rd | 1 | 1 | 1 | 1 | 0001 | Rm | ||
| 0xFAB0F080 | CLZ{<c>}{<q>} <Rd>, <Rm> | T32 | 111110101 | 011 | Rn | 1111 | Rd | 10 | 00 | Rm |
Description
Count Leading Zeros returns the number of binary zero bits before the first binary one bit in a value.
Operation
if ConditionPassed() then
EncodingSpecificOperations();
result = CountLeadingZeroBits(R[m]);
R[d] = result<31:0>;