Skip to main content
Be Bitwise

General vs. Special Registers

Registers & Instruction Sets · Foundations track

3 min read

In this module

Two Kinds of Registers

Not all registers are equal. Some are general-purpose workhorses that hold whatever data the program needs. Others have a specific job baked into the hardware. The distinction matters for reading assembly code and reasoning about how programs actually execute.

General-Purpose Registers

These are the registers available for everyday use. A program can load values into them, do arithmetic on them, and store results back. Depending on the architecture, they might be named R0 through R7, or carry letters like EAX, EBX, ECX on x86 processors.

How many general-purpose registers you get varies by architecture. A simple teaching CPU might give you 8. 32-bit ARM has 13 general-purpose registers (R0-R12, with R13-R15 reserved for SP, LR, PC). 64-bit ARM (AArch64) has 31 general-purpose registers (X0-X30). x86-64 has 16 (RAX to R15), though that count includes RSP, the stack pointer, and RBP, which code often keeps as a frame pointer. More registers means the CPU can juggle more values without constantly hitting memory.

Special-Purpose Registers

A handful of registers carry dedicated roles the hardware depends on:

  • Program Counter (PC) holds the memory address of the next instruction to fetch. After each fetch, the PC auto-increments. Jump and branch instructions modify the PC to redirect the flow of execution.

  • Stack Pointer (SP) points to the top of the call stack. The stack is where return addresses, local variables, and saved register values get stored when calling functions. Push and pop operations adjust the SP automatically.

  • Flags Register carries the status bits the ALU sets after arithmetic and logic operations: zero, carry, overflow, sign. Not every instruction touches them (an x86 mov doesn't, and most ARM instructions only do when you ask with an S suffix). Conditional branch instructions consult these flags to decide whether to jump.

  • Instruction Register (IR) holds the instruction currently being decoded and executed. You don't touch the IR from your program; the control unit manages it entirely.

Key Concept

General-purpose registers store whatever data your program needs. Special-purpose registers like the Program Counter, Stack Pointer, Flags Register, and Instruction Register have fixed roles that the CPU hardware depends on to function correctly.

Why This Matters

When you write or read assembly language, most of the work is shuffling data between general-purpose registers, doing operations on them, and occasionally poking at special registers through specific instructions (a CALL instruction, for example, pushes the PC onto the stack). Knowing which registers exist and what they do is the first step toward understanding how software really talks to hardware.

You can watch the PC and SP cooperate in the simulator below. Step to the CALL and look at three things at once: the PC jumps to the double routine, SP drops from 0xFF to 0xFE, and the return address (4, the address of the instruction after the CALL) appears at memory address 0xFE. Step on to RET and the CPU reads that 4 back into the PC and moves SP back up, so execution carries on where it left off.

For the best simulation experience, use a desktop browser.

Assembly

200ms

Registers

R00
0x0000
R10
0x0000
R20
0x0000
R30
0x0000
R40
0x0000
R50
0x0000
R60
0x0000
R70
0x0000
PC0
0x0000
SP255
0x00FF
FLAGS0x00
ZCVN

ALU

Idle

Memory

PCSPWatched
Memory contents — rows indexed by base address, columns by hex offset
Address0123456789ABCDEF
0000000000000000000000000000000000
1000000000000000000000000000000000
2000000000000000000000000000000000
3000000000000000000000000000000000
4000000000000000000000000000000000
5000000000000000000000000000000000
6000000000000000000000000000000000
7000000000000000000000000000000000
8000000000000000000000000000000000
9000000000000000000000000000000000
A000000000000000000000000000000000
B000000000000000000000000000000000
C000000000000000000000000000000000
D000000000000000000000000000000000
E000000000000000000000000000000000
F000000000000000000000000000000000

Pipeline

Cycle 0
Fetch
Decode
Execute
Writeback
→
→
→
No instruction loaded

Notice that RET doesn't wipe the 4 from memory. It just moves SP past it. The stack module will show why that leftover data matters.