SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: What is the instruction set of the Cortex-M0?
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

What is the instruction set of the Cortex-M0?

David Moore
Last updated: September 14, 2023 12:19 pm
David Moore 6 Min Read
Share
SHARE

The Cortex-M0 is a 32-bit ARM processor designed for microcontroller applications. It has a reduced instruction set computer (RISC) architecture and uses the ARMv6-M Thumb instruction set. The Thumb instruction set is a compact 16-bit and 32-bit instruction set designed to provide high code density without compromising performance for microcontroller applications. Some key features of the Cortex-M0 instruction set architecture include:

Contents
Thumb 16-bit and 32-bit InstructionsLoad/Store ArchitectureARM and Thumb Instruction SetsConditional ExecutionRegistersAddressing ModesLoad/Store InstructionsData Processing InstructionsBranch InstructionsSupervisor Call and Exception HandlingDebugging and InstrumentationMemory Protection UnitWake-up Interrupt ControllerSystem Control BlockNested Vectored Interrupt ControllerPower ManagementThumb-2 Technology

Thumb 16-bit and 32-bit Instructions

The Thumb instruction set consists of both 16-bit and 32-bit instructions. 16-bit Thumb instructions are designed to be space-efficient for simple and frequently used operations like moves, adds, subtracts, and branches. 32-bit Thumb instructions are available for more complex operations and provide additional capabilities compared to 16-bit instructions.

Load/Store Architecture

The Cortex-M0 uses a load/store architecture where data processing operations only occur on registers, not directly on memory. All memory access is through load and store instructions that move data between registers and memory. This provides predictable timing of instructions.

ARM and Thumb Instruction Sets

The processor implements both the standard 32-bit ARM instruction set used in earlier ARM processors as well as the Thumb instruction set. The ARM instructions execute in ARM state, while Thumb instructions execute in Thumb state. Branch instructions can switch between ARM and Thumb states.

Conditional Execution

Most Thumb instructions can be conditionally executed based on the state of the condition flags in the CPSR register. This allows for efficient if-then-else structures without branching and improves overall performance.

Registers

The Cortex-M0 has 13 general purpose 32-bit registers (R0-R12) that can be accessed in most instructions. R13 is the stack pointer, R14 the link register, and R15 is the program counter. A program status register (PSR) contains condition flags, interrupt disable bits, and other status information.

Addressing Modes

The load/store architecture has simple and flexible addressing modes for memory access. The available addressing modes include:

  • Offset – register plus offset value
  • Pre-indexed – register plus offset, writing back to base register
  • Post-indexed – register value as base, add offset after transfer

Load/Store Instructions

Data transfer instructions between registers and memory include:

  • LDR – Load word from memory into register
  • STR – Store word from register into memory
  • LDRB – Load byte from memory into register
  • STRB – Store byte from register into memory

Data Processing Instructions

Arithmetic and logical instructions that operate on registers include:

  • ADD, SUB – Addition, Subtraction
  • AND, ORR – Logical AND, OR
  • MOV, MVN – Move, Move Negated
  • CMP, CMN – Compare, Compare Negated
  • EOR – Exclusive OR
  • LSL, LSR – Logical Shift Left/Right
  • ASR – Arithmetic Shift Right

Branch Instructions

Branch instructions for changes in program flow include:

  • B – Unconditional branch
  • Bxx – Conditional branch on condition xx
  • BL, BLX – Branch with Link register for subroutines

Supervisor Call and Exception Handling

The processor supports supervisor calls via the SVC instruction and configurable priority-based exception handling. SVCs allow supervisor code to be called from threads. Exceptions can be triggered by faults, interrupts, and traps for efficient handling in the exception framework.

Debugging and Instrumentation

Debugging capabilities are built into the architecture with breakpoints, watchpoints, tracing, and profiling features. This allows for real-time debugging and instrumentation of software without external probes.

Memory Protection Unit

An optional memory protection unit can enforce privilege and access rules by restricting memory access. This improves software robustness by limiting the effects of errant memory accesses.

Wake-up Interrupt Controller

The wake-up interrupt controller supports interrupts and wake-up events while minimizing power consumption, which is important for energy-constrained microcontroller applications.

System Control Block

The system control block provides system implementation information and configuration settings via registers in a system control space. This covers clocking, resets, power modes, and exception handling configurations.

Nested Vectored Interrupt Controller

The NVIC provides nested interrupt handling with configurable priorities and vectored exception entry points. This provides low-latency interrupt handling with minimal overhead.

Power Management

The processor includes multiple low power modes: sleep, deep sleep, and stop modes that disable clocks and wake up on events to conserve power. The WIC helps manage low power modes.

Thumb-2 Technology

Thumb-2 technology enhances the Thumb instruction set with more powerful 16-bit and 32-bit instructions to improve code density and performance. This includes more complex instructions for SIMD media processing among other enhancements.

In summary, the Cortex-M0 instruction set architecture is designed for microcontroller applications with high code density, low power, good performance, and extensive debugging features enabled by its RISC Thumb instruction set. The load/store model, conditional execution, flexible addressing modes, interrupts, system control block, and power management support the needs of deeply embedded software implementations.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article What is the Difference Between Cortex-M0 and M1?
Next Article How to get QEMU to run an ARM Thumb binary?
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

What is ARM Cortex M0 processor?

The ARM Cortex-M0 processor is a 32-bit reduced instruction set…

6 Min Read

Importance of Adequate Stack Size for Threads in Keil RTX

When developing multithreaded applications using Keil RTX, one important consideration…

7 Min Read

Syntax for inline assembly operands in GCC

The GNU Compiler Collection (GCC) provides an inline assembler that…

9 Min Read

How to Program ARM Cortex M4

The ARM Cortex M4 is a powerful 32-bit processor optimized…

5 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account