Master the fundamental concepts of cpu design through this focused micro-challenge.
Memory-mapped I/O maps device registers into the same address space as RAM. A store to address 0xFF00 might print a character instead of writing DRAM. Embedded ARM and AVR firmware uses this model exclusively.
cLoading…
The CPU does not need new opcodes. Existing LOAD/STORE instructions target either RAM or a device based on address decoding in the memory subsystem.
0x0000 - 0x7FFF0x8000 and above (example map)For example, storing ASCII 72 ('H') to the print port should emit a character on the host console.
For this exercise, you will map one output address to printf or equivalent. This task asks you to extend mem_write with a device hook, the same pattern Linux uses when drivers map PCI BARs into virtual memory.
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.
Implement memory-mapped I/O for character output.
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