Menu
Coddy logo textTech

Registers vs Memory

Part of the Fundamentals section of Coddy's Assembly journey — lesson 3 of 45.

You have now learned about two places where data can live inside a computer:

  • Registers — tiny storage boxes inside the CPU
  • Memory (RAM) — a giant grid of numbered slots outside the CPU

But why are there two places? Why can't the CPU just work directly with memory?

The answer is speed. Registers are extremely fast because they are inside the CPU. Memory is slower because it is outside. The CPU can access a register in a single cycle, but accessing memory takes much longer.

Side-by-side comparison:

FeatureRegistersMemory (RAM)
LocationInside the CPUOutside the CPU
SpeedExtremely fast (1 cycle)Slower (many cycles)
Number of storage slotsVery few (16-32 on x86-64)Millions or billions
Size of each slot8 bytes (64 bits)1 byte
How you access themBy name (rax, rbx, rcx...)By address (1000, msg, buffer)
Volatile?Yes (disappears when power off)Yes (disappears when power off)

The most important rule in assembly:

The CPU cannot work directly with data in memory. Data must be loaded into registers first.

This is not optional. It is how the CPU is designed. Every addition, every comparison, every move of data must go through a register.

The three-step pattern you will use constantly:

StepWhat happensExample
1. LOADCopy data from memory into a registermov rax, [count]
2. WORKDo something with the registeradd rax, 5
3. STORECopy the result back to memory (if needed)mov [result], rax

What happens if you forget this rule?

If you try to add two numbers that are both in memory, the assembler will give you an error. The CPU simply cannot do it. You must load them into registers first.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals