Keil Logo Arm Logo

Assembler User Guide

Conditional execution in Thumb state

Conditional execution in Thumb state

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 CBZ and CBNZ

  • using 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, on the value of the ALU flags, using the condition code suffix. Each IT instruction provides conditional execution for up to four following instructions.

Example 19. Conditional instructions using IT block

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

Copyright © 2007-2008, 2011-2012 ARM. All rights reserved.ARM DUI 0379D
Non-ConfidentialID062912

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.