CLZ

Count Leading Zeros.

Show/hideSyntax

CLZ{cond} Rd, Rm

where:

cond

is an optional condition code.

Rd

is the destination register.

Rm

is the operand register.

Show/hideUsage

The CLZ instruction counts the number of leading zeros in the value in Rm and returns the result in Rd. The result value is 32 if no bits are set in the source register, and zero if bit 31 is set.

Show/hideRegister restrictions

You cannot use PC for any operand.

You can use SP in these ARM instructions but this is deprecated in ARMv6T2 and above.

You cannot use SP in Thumb instructions.

Show/hideCondition flags

This instruction does not change the flags.

Show/hideArchitectures

This ARM instruction is available in ARMv5T and above.

This 32-bit Thumb instruction is available in ARMv6T2 and above.

There is no 16-bit Thumb version of this instruction.

Show/hideExamples

    CLZ     r4,r9
    CLZNE   r2,r3

Use the CLZ Thumb instruction followed by a left shift of Rm by the resulting Rd value to normalize the value of register Rm. Use MOVS, rather than MOV, to flag the case where Rm is zero:

    CLZ r5, r9
    MOVS r9, r9, LSL r5

Show/hideSee also

Reference:
Copyright © 2011 ARM. All rights reserved.ARM DUI 0588A
Non-ConfidentialID061811