Load - store architecture model
What is a load/store architecture?
WHY this design? Three key reasons:
- Uniform instruction timing: Memory access is unpredictable (cache hits/misses). Separating it makes non-memory instructions fast and predictable.
- Simplified hardware: The ALU doesn't need memory interface logic. Decode is simpler (fewer instruction formats).
- Compiler optimization: Explicit data movement makes register allocation and instruction scheduling easier to optimize.
The alternative: Register-memory architectures
Contrast with x86 (a register-memory architecture):
; x86 can do this:
ADD [memory_addr], EAX ; Read memory, add EAX, write back
; RISC load/store requires:
LDR R1, [memory_addr] ; Load into register
ADD R1, R1, R2 ; Operate on registers
STR R1, [memory_addr] ; Store backWHY x86 seems "better": Fewer instructions! But the x86 ADD hides complexity—it's actually doing 3 operations internally, and its timing varies wildly based on cache behavior.
WHY RISC is actually better:
- Each instruction does one thing → pipelining is easier
- Predictable timing → easier to meet real-time deadlines
- Simpler decode → lower power, higher clock speeds
Deriving the performance advantage
Start from first principles:
-
Execution time = (Number of instructions) × (Cycles per instruction) × (Clock period)
-
Why does CPI differ?
- Register-memory: Each instruction might stall waiting for memory (variable latency)
- Load/store: Memory ops are explicit and isolated, so the pipeline knows exactly when to stall
-
Example scenario: Add two numbers from memory x86 (register-memory):
ADD [0x1000], EAX ; ~10 cycles if cache missARM (load/store):
LDR R1, [R0] ; ~10 cycles if cache miss ADD R1, R1, R2 ; ~1 cycle (register op) STR R1, [R0] ; ~10 cycles if cache missARM has 3 instructions vs. 1, but:
- ARM can pipeline the ADD while loads/stores happen
- ARM can reorder independent loads (out-of-order execution easier)
- ARM's simple decoder runs at 3 GHz vs. x86's 2.5 GHz (example numbers)
-
Working out the average CPI (where does "4" come from?): The two memory ops each cost ~10 cycles on a miss, the ALU op costs ~1 cycle. But those numbers are per-instruction latencies, not the throughput CPI. Because a pipelined machine overlaps these instructions, the effective per-instruction cost is much lower. Let's compute it explicitly.
Assume in steady-state pipelining, a cache miss stalls the pipe but subsequent independent instructions keep issuing. A common textbook approximation is:
Suppose the 3-instruction ARM sequence, with overlap, takes 12 pipeline cycles total (one memory miss largely hidden behind the other work, plus base pipeline fill):
For x86, the single fused instruction cannot overlap its internal read-modify-write, so its per-instruction cost stays at the full ~10-cycle latency:
This is why load/store's low CPI (4) beats the high CPI (10) of register-memory, even with more instructions.
-
Net result:
(Simplified, but shows the trade-off. In practice, ARM often wins due to better pipelining.)
Recall Explain to a 12-year-old
Imagine you're doing math homework. You have a calculator (the CPU registers) and a backpack full of notes (memory).
Load/store architecture = A strict teacher says: "You can only work with papers on your desk. If you need something from your backpack, take it out first (load). When you're done, put it back (store). You can't do math while reaching into your backpack!"
Register-memory architecture = A relaxed teacher says: "Just grab whatever you need from your backpack and calculate right there."
Why is the strict teacher's rule better? Because:
- You work faster when everything is on your desk (registers are 100x faster than memory)
- You know exactly when you're reaching into the backpack (predictable timing)
- Your desk stays organized (simpler hardware)
The trade-off: You need a bigger desk (more registers) to hold all your papers!
Key characteristics of load/store architectures
1. Instruction format regularity
WHY this matters: Simpler decode logic, faster instruction fetch.
All memory instructions have the same format:
All ALU instructions:
Contrast x86: Over 1000 instruction variants, variable length (1-15 bytes), complex addressing modes.
2. Large register files
WHY? Since memory isn't directly accessible, you need workspace.
| Architecture | Type | Registers |
|---|---|---|
| ARMv7 (32-bit) | Load/store | 16 registers R0–R15, but only R0–R12 are truly general-purpose (R13=SP, R14=LR, R15=PC are special) |
| AArch64 (ARM 64-bit) | Load/store | 31 general-purpose (X0–X30) |
| MIPS | Load/store | 32 general-purpose |
| RISC-V | Load/store | 32 general-purpose |
| x86 (32-bit) | Register-memory | 8 general (16 in x86-64) |
Derivation of register count:
Assume a typical loop body uses:
- 2-3 array pointers (base addresses)
- 3-4 loop variables (counters, temporaries)
- 2-3 intermediate calculation results
Minimum needed: ~8-10 registers.
But for compiler optimization, you want 2-3× this amount so the compiler can:
- Unroll loops (need parallel copies of variables)
- Keep frequently-used values "alive" across iterations
- Avoid "spilling" (writing registers back to memory)
Hence: 32 registers = practical sweet spot (more costs too many encoding bits). This is why the newer AArch64 jumped to 31 GPRs, while the older 32-bit ARMv7 made do with 16 total (of which ~13 are general).
3. Explicit memory ordering
Load/store forces programmers/compilers to think about data movement:
// C code
x = a[i] + b[i];
y = c[i] + d[i];Compiler must generate:
LDR R1, [a, i] ; These 4 loads can be
LDR R2, [b, i] ; reordered by the
LDR R3, [c, i] ; compiler for optimal
LDR R4, [d, i] ; cache usage!
ADD R5, R1, R2
ADD R6, R3, R4
STR R5, [x]
STR R6, [y]In a register-memory ISA, the implicit memory access in ADD [mem], reg hides these optimization opportunities.
Modern reality: Hybrid approaches
Observation: Pure load/store won. Almost all modern high-performance CPUs are load/store:
- ARM (phones, Apple M-series, servers)
- RISC-V (emerging)
- MIPS (legacy embedded)
- PowerPC (legacy servers)
But: Even x86 converts internally! Modern x86 CPUs:
- Decode complex x86 instructions into simpler micro-ops (μops)
- These μops are load/store style
- Execute on a RISC-like core
So x86 gets the worst of both worlds: complex decode + load/store execution. This is why ARM is winning in mobile (power efficiency).
Connections
- RISC vs CISC philosophy: Load/store is the defining RISC characteristic
- Instruction pipelining: Simple instructions enable efficient pipelines
- Register allocation: Compilers need many registers for load/store architectures
- Memory hierarchy: Explicit loads/stores expose cache behavior to the compiler
- Addressing modes: Load/store limits addressing mode complexity
- Instruction encoding: Uniform formats save opcode space
Flashcards
What is a load/store architecture? :: An ISA where only load and store instructions access memory, and all arithmetic/logic operations work exclusively on registers. Also called register-register architecture.
Why is load/store architecture faster despite more instructions?
What are the three main benefits of load/store architecture?
How many general-purpose registers in MIPS vs 32-bit x86?
Why does the x86 register-register multiply use IMUL not MUL?
What is register pressure and why does it matter for load/store?
Why do modern x86 CPUs use micro-ops?
What is the instruction format for RISC load/store?
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Dekho, is note ka core idea bahut simple hai - "load/store architecture" ka matlab hai ki CPU sidha memory pe calculation nahi kar sakta. Socho ek chef ki tarah jo sirf apne kitchen counter pe kaam kar sakta hai. Agar usko koi ingredient chahiye to pehle fridge se nikalna padega (yeh hai "load"), phir counter pe kaam karega (arithmetic/logic operations registers pe hote hain), aur kaam khatam hone ke baad wapas fridge mein rakhna padega (yeh hai "store"). Yani sirf load aur store instructions hi memory ko access kar sakte hain, baaki saara calculation sirf registers pe hota hai. RISC-style processors, jaise ARM, isi model ko follow karte hain.
Ab tum sochoge - yeh to zyada instructions lagta hai! x86 (register-memory architecture) mein ek hi ADD instruction memory se data padh sakta hai, calculate kar sakta hai, aur wapas likh sakta hai. Lekin yahan asli baat samajhna zaroori hai: x86 ka woh single instruction andar-andar 3 kaam kar raha hai aur uska timing predict karna mushkil hai (cache hit ya miss ke hisaab se). Jabki load/store mein har instruction ek hi simple kaam karta hai, isliye timing predictable hoti hai. Iska matlab hardware simple ban jaata hai, decode karna aasan hota hai, aur pipelining zyada aggressively ho sakti hai. Formula bhi yahi bolta hai: bhale instruction count zyada ho, lekin CPI (cycles per instruction) kaafi kam ho jaata hai aur clock frequency badhayi ja sakti hai.
Yeh baat matter kyun karti hai? Kyunki performance ka final formula hai . Load/store architecture mein bhale thoda badh jaaye, lekin kam CPI aur higher clock speed uska poora faayda cover kar deta hai. Isiliye aaj tumhare mobile phones, tablets, aur bahut se modern systems RISC/ARM chips use karte hain - simple, fast, aur power-efficient. Jab tum yeh samajh loge, to tumhe pata chalega ki "kam instructions matlab better" hamesha sach nahi hota - asli game predictability aur pipelining ka hai. Yeh concept computer architecture ka bahut fundamental building block hai, aur aage jab tum pipelining aur processor design padhoge, tab yeh intuition tumhare bahut kaam aayegi.