Master the fundamental concepts of instruction set architecture through this focused micro-challenge.
CISC ISAs (x86) pack rich operations into variable-length encodings to save memory on 1980s machines with tiny RAM. RISC ISAs (ARM, RISC-V, MIPS) favor fixed-width instructions, many registers, and load/store simplicity so decode hardware stays fast and power low.
| Trait | CISC (x86) | RISC (ARM/RISC-V) |
|---|---|---|
| Instruction size | Variable | Fixed 32-bit (mostly) |
| Registers | 16 named GPRs | 31-32 GPRs |
| Memory ops | Arithmetic on memory | Loads/stores only |
Code density favors CISC: the same C function may compile smaller on x86. Clock-for-clock on modern out-of-order cores, RISC designs win on power and decode regularity, not raw instruction count.
For this exercise, you will compile identical loops for two targets and compare static instruction counts and dynamic retired instructions (perf stat). This task asks you to ground ISA debates in measured data instead of 1990s textbook slogans.
Keep the relevant datasheet, ISA manual, or architecture textbook chapter open while you implement. When your output disagrees with the reference trace on the same program, the bug is usually a mis-decoded opcode, a stale register read, or a flag bit left unchanged after arithmetic.
For this exercise, you will use those habits while implementing the requirement in the starter code. Microarchitectural product names change across CPU generations, but the control ideas (fetch, bypass, cache lines, vector lanes) stay stable enough to debug from first principles.
Benchmark and compare CISC vs RISC approaches.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github