Skip to main content
Be Bitwise

ARM Registers & Execution Modes

ARM Architecture Deep Dive · CPU Architectures track

3 min read

In this module

A Generous Register Set

ARM hands you a lot more general-purpose registers than x86 does. More registers means fewer trips to memory, which translates straight into faster, cheaper code. It's one of RISC's quietest wins.

AArch64 (ARM64) Registers

The modern 64-bit ARM architecture provides:

  • X0-X30 - 31 general-purpose 64-bit registers. Each can also be accessed as a 32-bit register using the name W0-W30 (the lower 32 bits).
  • XZR/WZR - the zero register. In most instructions, register number 31 reads as zero and discards writes.
  • SP - the stack pointer. It is a separate register, not one of the 31 GP registers.
  • PC - the program counter. Not directly accessible as a general-purpose register in AArch64 (unlike AArch32 where it was R15).
  • PSTATE - processor state flags (similar in concept to x86's RFLAGS). Includes the N (negative), Z (zero), C (carry), and V (overflow) condition flags.

The naming is clean and systematic. X0 is the full 64-bit register; W0 is its lower 32-bit half. None of x86's AL/AH/AX/EAX/RAX archaeology.

Writing a W register zero-extends into the full X register, just as writing EAX clears the top of RAX on x86-64. Two registers have fixed jobs under the standard calling convention (AAPCS64): X29 is the frame pointer and X30 the link register, which holds the return address after a BL. Arguments go in X0-X7, and the result comes back in X0.

AArch32 (Legacy 32-bit ARM) Registers

The older 32-bit ARM architecture uses a different register layout:

  • R0-R12 - general-purpose 32-bit registers.
  • R13 (SP) - stack pointer.
  • R14 (LR) - link register, holds the return address after a branch-with-link instruction.
  • R15 (PC) - program counter. Uniquely, R15 is accessible as a general-purpose register, which enables some clever (and dangerous) tricks.

Execution Modes and Exception Levels

ARM implements a hierarchy of privilege levels that control what software can do.

Exception Levels

AArch64 defines four exception levels (EL0-EL3), each with increasing privilege. EL0 is where user applications run. EL1 is for the OS kernel. EL2 is for hypervisors (virtual machine managers). EL3 runs secure firmware. Higher exception levels can access everything lower levels can, but not vice versa. This hardware-enforced separation is fundamental to system security.

LevelNameTypical Software
EL0UserApplications
EL1KernelOperating system
EL2HypervisorVirtual machine monitor
EL3Secure MonitorFirmware, TrustZone

Each exception level has its own stack pointer and a slice of dedicated system registers. When something interesting happens (interrupt, system call, fault), the processor jumps up to a higher level. It's the same idea as x86's rings 0 through 3, but the ARM model is cleaner and more consistently applied.

Each level has its own instruction for calling up to the next one, and a single instruction, eret, for returning down:

Interrupts and faults climb the same ladder without any instruction being involved: a page fault in an app, for example, is taken to EL1 just as an svc is.

Banked Registers

AArch32 uses banked registers: different execution modes carry their own copies of certain registers. Switch from user mode to interrupt mode, and the hardware quietly swaps in a different R13 (stack pointer) and R14 (link register) for you. No manual save-and-restore on every mode switch. Faster, and harder to get wrong.

Comparing to x86

ARM's 31 general-purpose registers versus x86-64's 16 means ARM code spends less time shuttling values to and from memory. The systematic naming (X0-X30 against RAX, RBX, RCX...) is much easier to learn. The exception level model is more modern and applied more consistently than x86's segmented ring model. These are the dividends of designing a clean architecture without forty years of backward compatibility nailed to your foot.