Exercises — ISA (Instruction Set Architecture) — RISC vs CISC
Before we start, we reuse one tool the whole way down, so let us pin it in one place:
Level 1 — Recognition
L1-a
For each item, say whether it belongs to the ISA or the microarchitecture (the physical implementation, the "kitchen"):
- "The chip has 32 general-purpose registers named
x0–x31." - "Our branch predictor uses a 2-bit saturating counter."
- "Every instruction is exactly 32 bits long."
- "The cache is 8-way set-associative."
- "An
ADDinstruction sets the carry and zero status flags that a later branch reads."
Recall Solution
Rule of thumb: if a compiler or assembly programmer must know it to write a correct program, it is the ISA. If it only affects speed, hidden behind the same visible behaviour, it is microarchitecture.
- ISA — the register names and count are part of the visible contract.
- Microarchitecture — a predictor changes speed, not correctness; software never names it.
- ISA — instruction length is how the decoder is defined to read the stream; software depends on it.
- Microarchitecture — cache associativity is invisible to correctness; see Caches and Memory Hierarchy.
- ISA — this is the subtle one. Architectural side effects like x86's status flags (carry, zero, sign, overflow) look like internal plumbing, but because a later instruction's behaviour depends on them, the compiler must reason about them to emit correct code. They sit in the visible contract, so they are ISA. Contrast this with how many pipeline stages compute the flag — that timing is microarchitecture. The test is always: "if this changed silently, could a correct program break?" For flags, yes → ISA.
L1-b
Classify each instruction sketch as RISC-legal (load/store) or CISC-only:
ADD r1, r2, r3ADD [A], [B](memory + memory → memory)LW r1, 0(r2)MUL r4, [C], r5(one operand in memory)
Recall Solution
The load/store rule: in RISC, arithmetic instructions touch registers only. Any arithmetic that reads or writes memory is CISC-only.
- RISC-legal — all three operands are registers.
- CISC-only — arithmetic reads two memory operands.
- RISC-legal — a
LW(load word) is allowed to touch memory; that is its whole job. - CISC-only — the multiply reads a memory operand
[C]directly.
Level 2 — Application
L2-a
A program runs instructions, at , on a clock of . Find the total time in seconds.
Recall Solution
First convert the clock to a period. Why? The Iron Law needs (seconds per tick), not frequency (ticks per second). Now plug in: What it means: a billion instructions, each averaging 2.5 slow-ish ticks, on a fairly fast clock, takes about 1.25 seconds.
L2-b
Rewrite mem[A] = mem[A] + mem[B] in RISC load/store form and count the instructions. Then, given each RISC instruction averages and the clock period is ns, find the time for this one statement.
Recall Solution
RISC form (staging memory into registers, because arithmetic may not touch memory):
LW r1, A ; load A
LW r2, B ; load B
ADD r1, r1, r2 ; register + register
SW r1, A ; store back to A
That is instructions.
Level 3 — Analysis
L3-a
Two designs compile the same loop. Forecast the winner, then compute both times.
| Design | |||
|---|---|---|---|
| CISC | 6 instr | 6 cyc | 0.5 ns |
| RISC | 15 instr | 1.1 cyc | 0.35 ns |
The figure below turns the two rows of this table into two bars: each bar's height is the finished program time , and inside each bar the three lever values (, , ) that multiplied to make it. Notice the CISC bar is over 3× taller — the plum arrow points at why: its column is what inflates it.

Recall Solution
Forecast: RISC runs 2.5× the instructions, but each is far cheaper (CPI 1.1 vs 6) and the clock ticks faster (0.35 vs 0.5). Guess RISC. Verify — remember we are just plugging into the Iron Law for each row: RISC wins ( ns vs ns). Look at the figure: the tall orange CISC bar is dominated by its value; the short teal RISC bar shows a low and short crushing its larger — exactly what the plum arrows label.
L3-b
Now suppose the compiler improves and CISC's drops to 2 (everything else unchanged from L3-a). Recompute and state whether the winner flips.
Recall Solution
Again we simply re-evaluate the Iron Law for the CISC row, changing only the middle factor: RISC is unchanged at ns. So : RISC still wins, but only barely. The margin as a percentage of the CISC time is This is the whole point: shrink CISC's enough and the low- advantage nearly catches up. There is no law of nature declaring a winner — only a product of three factors.
Level 4 — Synthesis
L4-a
A CISC memory-to-memory ADD [A],[B] is internally cracked into RISC-like micro-ops ("µops"): load A, load B, add, store A. Each µop takes 1 cycle in the pipeline.
- How many µops does this one CISC instruction become?
- If the front-end decodes this CISC instruction in 1 extra cycle, what is the effective CPI of that single CISC instruction (decode + µops)?
- A pure-RISC compiler emits the same 4 operations as 4 separate instructions at each. Compare total cycles.
Recall Solution
- 4 µops (
load A,load B,add,store A) — exactly the RISC sequence from L2-b. - Effective cycles = decode + µops = cycles for one CISC instruction, so its effective .
- Pure RISC: instructions cycle cycles. Reading it: the "single fat instruction" costs 5 internal cycles vs the RISC 4 — the decode/crack overhead is the extra cycle. This is why modern x86-64 is "CISC outside, RISC inside": the fatness is convenience for the code stream, but the real work is still one small step at a time. See Microcode and Microarchitecture vs ISA.
L4-b
Code density. The CISC ADD [A],[B] encodes in 6 bytes. The four RISC instructions encode in 4 bytes each (fixed 32-bit). Compute total code size each way and the CISC density advantage as a ratio.
Recall Solution
- CISC size bytes (one instruction).
- RISC size bytes (four fixed 32-bit instructions).
- Ratio . So the RISC version is about 2.67× larger in bytes for this snippet. What it means: CISC's original selling point (dense code when memory was scarce) is real and quantifiable here — even though RISC may run faster, it costs more instruction-memory footprint.
Real-world caveat (don't over-sell the 6 bytes): the "6 bytes" is the raw encoding, but real binaries rarely hit that on the page. CISC's variable-length instructions can force alignment padding so the next instruction or a branch target lands on a clean boundary, and both ISAs carry metadata overhead (relocation entries, symbol tables, ELF/PE headers). So the true on-disk density gap is usually smaller than the neat suggests — the ratio is an upper bound on CISC's advantage, not a guarantee. This is the tension Compilers and Code Generation must manage.
Level 5 — Mastery
L5-a
You are designing a chip for battery-powered sensors where the program is tiny, fits in a small ROM, and runs rarely (so raw speed barely matters, but code size is precious). Using the numbers from L4-b, argue which philosophy fits and back it with the code-size ratio.
Recall Solution
Decision: lean toward CISC-style dense encoding (or a compressed RISC variant). Justification via the numbers: L4-b showed RISC used bytes vs CISC's bytes — a footprint penalty. When speed is a non-goal but ROM bytes are the binding constraint, minimizing -encoding-size dominates the Iron Law's . But apply the L4-b caveat honestly: that is a best case for CISC — alignment padding around variable-length instructions and fixed metadata overhead (headers, relocation tables) eat into the raw-byte win, so the real ROM saving is somewhat less. Even so, the direction still favours dense encoding. The classic RISC counter-move is compressed encodings (e.g. RISC-V "C" 16-bit instructions), which claw back density while keeping the simple pipeline — showing the dichotomy is a spectrum, not a wall.
L5-b
Full defense problem. Given these two candidate designs for a high-throughput server running a fixed hot loop:
| Design | |||
|---|---|---|---|
| A (CISC-y) | 5 instr | 4.0 cyc | 3.0 GHz |
| B (RISC-y) | 12 instr | 1.0 cyc | 4.0 GHz |
- Compute for each (this loop runs once; report ns).
- State the winner and by what percentage it is faster.
- Explain, using each of the three Iron-Law levers, why the winner wins.
Recall Solution
Step 1 — convert clocks to periods first. :
- A: .
- B: .
Step 1 — times (plug each row into the Iron Law ):
Step 2 — winner and "how much faster." B is faster. Now be careful about what "X% faster" means — the convention must be stated, because dividing by the slow one and the fast one give different numbers:
- Convention we use (the standard one): "B is X% faster than A" ⇒ speed-up measured against the faster machine's time, i.e. divide the time saved by the faster time . This answers "how much extra time does the slow machine burn, per unit of the fast machine's time?" So A takes about more time than B — equivalently B is "about 2.22× the speed."
- The other common phrasing — "A is Y% slower than B" ⇒ divide the time saved by the slower time , which gives a different number: So B finishes in , i.e. B runs in about of A's time ( less time). Both statements describe the same pair of numbers — the only difference is the denominator, which is exactly why you must name it.
Step 3 — lever-by-lever why (read alongside the figure). All three levers of :
- lever: A wins this one () — fewer, fatter instructions is the classic CISC advantage. This is B's only handicap.
- lever: B crushes it ( vs , a gap) — simple, regular instructions pipeline down to ~1 cycle each (Pipelining), whereas A's fat instructions are multi-cycle/microcoded.
- lever: B wins ( ns vs ns) — simpler decode lets the clock run faster ( GHz vs GHz). Putting the three together: the product is . A's lone win contributes the factor (pulling toward A), but the factor of and the clock factor of multiply to against A — so their product still lands firmly in B's favour. Two strong levers beat one, and the Iron Law makes the margin exact rather than a hunch. This is the canonical RISC argument — and it depended entirely on the numbers, exactly as the Iron Law demands.
The figure shows this in two panels. The left panel plots the three levers side-by-side (, , ) with a small plum letter over each pair marking which design wins that lever alone — you can literally see A win only the bar. The right panel collapses everything into the finished time : B's bar is the shorter one, with the plum arrow marking the ~2.22× speed-up.
