Skip to main content
Be Bitwise

What Are Registers?

Registers & Instruction Sets · Foundations track

3 min read

In this module

The Fastest Storage You Have

Registers are tiny storage locations built directly into the CPU. They hold the data the processor is actively working with: the numbers being added, the address of the next instruction, the result of the last comparison. Accessing a register takes less than a single nanosecond.

Why Not Just Use RAM?

RAM is huge. Modern computers have gigabytes of it. But RAM is also a long way from the CPU, electrically speaking. A round trip to main memory can take 50 to 100 nanoseconds or more. That sounds small in human terms; at 3 GHz the CPU can tick through 150 to 300 cycles in that window. Waiting that long for every byte would grind performance into the ground.

Registers solve this by keeping a small amount of data right where the CPU needs it, on the chip itself, wired directly to the ALU and control unit. The tradeoff is capacity. A typical CPU has somewhere between 8 and 32 general-purpose registers, each holding just one word of data (32 or 64 bits depending on the architecture). An x86-64 chip has 16, named rax through r15; a 64-bit ARM chip has 31, x0 to x30.

Key Concept

Registers are the fastest form of storage in a computer. They live inside the CPU and can be accessed in a fraction of a nanosecond. The tradeoff is that there are very few of them, typically 8 to 32 general-purpose registers.

The Speed Hierarchy

Registers sit at the top of what's called the memory hierarchy:

  • Registers are the smallest and fastest. Inside the CPU.
  • Cache (L1, L2, L3) is larger and slightly slower. Still on or next to the CPU chip.
  • RAM is much larger, much slower.
  • Disk / SSD is enormous, but orders of magnitude slower than RAM.

Here's the same ladder with rough numbers attached. They're typical figures for a current desktop or laptop and vary between chips, so treat them as orders of magnitude rather than specs:

Look at the jump between the last two boxes. An SSD read takes roughly a thousand times longer than a RAM read, and a RAM read takes around a hundred times longer than a register access.

Every level trades speed for capacity. Programs run fastest when the data they need is already in a register. A large part of what compilers and CPU designers do is keep the right data in registers at the right time.

What Registers Look Like

A register is a small group of flip-flops, the same kind of one-bit memory circuits you'd build from logic gates. Line up 32 flip-flops and you have a 32-bit register that can hold one integer, one memory address, or one instruction. Simple in concept, indispensable in practice.

The simulator below shows the eight general-purpose registers (R0 to R7) of a small teaching CPU, plus its special ones. Press Step and watch R0 take the value 5, then R1 copy it, then R1 grow to 12. Nothing outside the register panel changes, because none of these instructions touches memory.

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