Difference between ARM and Thumb states (ARM vs. thumb)

In ARM-based processors, ARM and Thumb states serve different purposes, primarily affecting code size and memory efficiency. The ARM state operates with a full 32-bit RISC instruction set, while the Thumb state uses a compressed 16-bit instruction set, reducing memory usage while maintaining execution speed.

While both states execute at the same speed, the difference lies in how instructions are fetched and interpreted. ARM processors include dedicated hardware to expand Thumb instructions into their full 32-bit equivalents. This makes Thumb useful for embedded systems, mobile devices, and memory-constrained environments.

Comparison of ARM and Thumb states:

FeatureARM StateThumb State
Instruction SetFull 32-bit RISC instructions16-bit compressed subset (some 32-bit instructions available)
Code SizeLargerSmaller (optimized for memory efficiency)
Execution SpeedNo impact (Instructions are processed natively)No impact (CPU expands instructions efficiently)
Registers18 total: R0-R12, SP (R13), LR (R14), PC (R15), CPSR, SPSR (for exceptions)12 total: R0-R7, SP, LR, PC, CPSR (Registers must be used for state transitions)
CPSR T BitT = 0 (Indicates ARM state)T = 1 (Indicates Thumb state)
Branching Between StatesBX or BLX to an address with LSB = 0 switches to ARM state (e.g., BX 0x80000000)BX or BLX to an address with LSB = 1 switches to Thumb state (e.g., BX 0x80000001)
Exception HandlingARM state is entered on exceptionsNot available
Returning from ExceptionIf T bit in SPSR is 1, returns to the Thumb stateIf the T bit in SPSR is 1, returns to the Thumb state
Register AccessCan access status and coprocessor registersCannot directly access status or coprocessor registers
Stack OperationsUses LDR and STR for stack manipulationProvides dedicated stack mnemonics (PUSH, POP)
AdvantagesFull instruction set, direct register access, flexible operationsReduced memory usage, works efficiently with 16-bit bus
DisadvantagesRequires more memoryNo direct access to coprocessor/status registers; Some operations need multiple instructions instead of one
ARM vs Thumb states in a ARM processer

When to Use ARM vs Thumb?

  • Use ARM state when performance and full register access are required.
  • Use Thumb state for memory-efficient applications like embedded systems, IoT devices, and mobile processors.

ARM and Thumb states in processor architecture offer distinct advantages, primarily concerning code size optimization. ARM employs a unified instruction set, while Thumb introduces a 16-bit shorthand for a subset of these instructions. The processor fetches these 16-bit instructions and expands them into equivalent 32-bit instructions, ensuring execution speed remains unaffected. Dedicated hardware within the CPU interprets Thumb instructions efficiently.

ARM (Advanced RISC Machines) utilizes a comprehensive 32-bit RISC instruction set, requiring more memory but offering robust functionality across 18 registers, including SP (R13), LR (R14), PC (R15), CPSR, and SPSR for exception handling. In contrast, Thumb reduces memory usage with its 16-bit instructions, supporting a subset of ARM operations through 12 registers (R1-R7, SP, LR, PC, CPSR). The CPSR’s T bit distinguishes between ARM (T=0) and Thumb (T=1) states.

Branch instructions (BX or BLX) direct the processor to ARM or Thumb states based on the LSB of the target address. Exceptions typically trigger the ARM state, with returns governed by the SPSR’s T bit (0 for ARM, 1 for Thumb).

Thumb’s advantages include reduced memory footprint and efficient use of a 16-bit bus without compromising speed. However, limitations include the inability to directly access status or coprocessor registers and the need for multiple Thumb instructions to simulate certain complex ARM operations.

Difference between ARM and Thumb states (ARM vs. thumb)

Further reference: https://www.ijset.in/wp-content/uploads/IJSET_V9_issue4_362.pdf

Leave a Reply