You copied the Doc URL to your clipboard.

Conditional execution in Thumb state

To execute Thumb instructions conditionally, you can either use an IT instruction, or a conditional branch instruction.

In Thumb state on processors before ARMv6T2, the only mechanism for conditional execution is a conditional branch. You can conditionally skip over the instruction using a conditional branch instruction.

In Thumb state on ARMv6T2 or later processors, instructions can also be conditionally executed by using any of the following:

  • CBZ and CBNZ instructions.

  • The IT (If-Then) instruction.

The Thumb CBZ (Conditional Branch on Zero) and CBNZ (Conditional Branch on Non-Zero) instructions compare the value of a register against zero and branch on the result.

IT is a 16-bit instruction that enables almost all Thumb instructions to be conditionally executed, based on the value of the condition flags and the condition code suffix specified. Each IT instruction provides conditional execution for up to four following instructions.

Example conditional instructions using IT block

    ; flags set by a previous instruction
    ITT   EQ
    LSLEQ r0, r0, #24
    ADDEQ r0, r0, #2