Thumb State vs Arm State: Key Differences 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.
| Aspect | ARM State | Thumb State |
|---|---|---|
| Instruction Size | 32-bit fixed length | Mostly 16-bit, some 32-bit (Thumb-2) |
| Code Density | Lower (larger code size) | Higher (smaller code size) |
| Performance | Higher due to full instruction set | Slightly lower but more efficient |
| Instruction Set | Full ARM instruction set | Subset of ARM instructions plus Thumb-2 extensions |
| Use Case | Performance-critical applications | Memory-constrained or power-sensitive applications |
| Switching | Processor switches states via special instructions | Same 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.
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
ENDThumb State Equivalent
The same addition in Thumb state uses 16-bit instructions for compactness.
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
ENDWhen 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.