0
0
ARM Architectureknowledge~10 mins

IT block for conditional execution (Thumb-2) in ARM Architecture - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - IT block for conditional execution (Thumb-2)
Evaluate Condition
Yes
Execute First Instruction
Check IT Mask
Yes
Execute Next Instruction(s) Conditionally
End of IT Block
No
Skip Instruction or Exit
The IT block evaluates a condition once, then executes up to four following instructions conditionally based on that initial condition and an IT mask.
Execution Sample
ARM Architecture
ITTE EQ
MOV R0, #1
MOV R0, #0
MOV R1, #2
This code sets up an IT block with condition EQ, then executes the first two instructions if EQ (MOV R0,#1 then MOV R0,#0), and the third if NE.
Analysis Table
StepInstructionCondition EvaluatedCondition ResultAction TakenRegister Changes
1ITTE EQEQTrueSet IT mask: Then, Then, ElseNo change
2MOV R0, #1EQTrueExecutedR0 = 1
3MOV R0, #0EQTrueExecutedR0 = 0
4MOV R1, #2NEFalseSkippedR1 unchanged
5Next instruction outside IT blockN/AN/AExecuted unconditionallyDepends on instruction
💡 IT block ends after executing instructions as per IT mask; subsequent instructions execute normally.
State Tracker
RegisterStartAfter Step 2After Step 3After Step 4Final
R0undefined1000
R1undefinedundefinedundefinedundefinedundefined
Key Insights - 3 Insights
Why does MOV R1, #2 get skipped even though the IT block is active?
Because the condition NE (Else in IT mask) is false at step 4 (execution_table row 4), so the instruction is skipped as per the IT mask.
How many instructions can an IT block conditionally execute?
Up to four instructions following the IT instruction can be conditionally executed based on the IT mask, as shown in the concept_flow and execution_table.
What happens after the IT block ends?
Instructions after the IT block execute normally without condition, as shown in step 5 of the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the value of R0 after step 3?
Aundefined
B1
C0
D2
💡 Hint
Check the Register Changes column at step 3 in the execution_table.
At which step does the condition NE evaluate to false causing the instruction to be skipped?
AStep 1
BStep 4
CStep 3
DStep 2
💡 Hint
Look at the Condition Evaluated and Condition Result columns in the execution_table.
If the initial condition was NE instead of EQ, which instruction would execute at step 3?
AMOV R0, #0
BMOV R0, #1
CMOV R1, #2
DNone
💡 Hint
Consider how the IT mask applies conditions to instructions after ITTE EQ in the execution_table.
Concept Snapshot
IT block allows up to 4 conditional instructions after an IT instruction.
IT instruction sets condition and mask (e.g., ITTE EQ).
Each following instruction executes if its condition matches.
Conditions are evaluated once at IT instruction.
Instructions outside IT block run normally.
Full Transcript
The IT block in Thumb-2 architecture lets the processor conditionally execute up to four instructions based on a single condition check. First, the IT instruction sets the condition and a mask that defines which following instructions run if the condition is true or false. Then, each instruction after the IT is executed or skipped depending on its condition and the mask. For example, with ITTE EQ, the first two instructions run if equal, the third if not equal. After the IT block ends, instructions run normally without condition. This mechanism helps write compact conditional code without branching.