0
0
Cnc-programmingComparisonBeginner · 4 min read

Thumb State vs Arm State: Key Differences in ARM Architecture

In ARM architecture, ARM state uses 32-bit instructions for full performance, while Thumb state uses 16-bit instructions to reduce code size and improve efficiency. Thumb state is ideal for memory-constrained environments, whereas ARM state offers more powerful instruction capabilities.
⚖️

Quick Comparison

This table summarizes the main differences between Thumb state and ARM state in ARM processors.

AspectARM StateThumb State
Instruction Size32-bit fixed lengthMostly 16-bit, some 32-bit (Thumb-2)
Code DensityLower (larger code size)Higher (smaller code size)
PerformanceHigher due to full instruction setSlightly lower but more efficient
Instruction SetFull ARM instruction setSubset of ARM instructions plus Thumb-2 extensions
Use CasePerformance-critical applicationsMemory-constrained or power-sensitive applications
SwitchingProcessor switches states via special instructionsSame as ARM, controlled by state bit
⚖️

Key Differences

ARM state executes 32-bit instructions, providing a rich and powerful instruction set that supports complex operations and high performance. This state is preferred when speed and full instruction capabilities are critical.

Thumb state uses mostly 16-bit instructions, which reduces the size of the compiled code significantly. This smaller code size improves memory usage and can lead to better cache utilization and power efficiency, making it ideal for embedded systems with limited resources.

Modern ARM processors support Thumb-2, which extends Thumb with some 32-bit instructions to regain some performance while keeping code size low. Switching between ARM and Thumb states is done by setting a processor mode bit, allowing flexible use of both instruction sets in the same program.

⚖️

Code Comparison

Here is an example of adding two numbers in ARM state using 32-bit instructions.

armasm
    AREA ARMCode, CODE, READONLY
    ENTRY
    MOV     R0, #5      ; Load 5 into R0
    MOV     R1, #3      ; Load 3 into R1
    ADD     R2, R0, R1  ; Add R0 and R1, store in R2
    END
Output
R2 = 8
↔️

Thumb State Equivalent

The same addition in Thumb state uses 16-bit instructions for compactness.

armasm
    AREA ThumbCode, CODE, READONLY
    ENTRY
    MOVS    R0, #5      ; Load 5 into R0 (Thumb uses MOVS)
    MOVS    R1, #3      ; Load 3 into R1
    ADDS    R2, R0, R1  ; Add R0 and R1, store in R2
    END
Output
R2 = 8
🎯

When to Use Which

Choose ARM state when your application demands maximum performance and full access to the ARM instruction set, such as in high-speed computing or complex algorithms.

Choose Thumb state when you need to save memory and improve power efficiency, especially in embedded systems or devices with limited storage and battery life.

Many modern ARM processors allow switching between states dynamically, so you can optimize critical code sections in ARM state and less critical parts in Thumb state.

Key Takeaways

ARM state uses 32-bit instructions for full performance and capability.
Thumb state uses mostly 16-bit instructions to reduce code size and improve efficiency.
Thumb-2 extends Thumb with some 32-bit instructions for better performance.
Switching between ARM and Thumb states is controlled by a processor mode bit.
Use ARM state for speed-critical code and Thumb state for memory or power-constrained environments.