Build your own Virtual Machine
An emulator for the LC-3 teaching computer (or the CHIP-8 game console) that runs real programs.
- Intermediate
- About 6–12 h
- 4 checkpoints
- 3 tutorials · C, C++
Pick a tutorial, then check yourself at each checkpoint. Work in any language you like.
Choose a tutorialWhy build it
An emulator is a loop that fetches, decodes and executes instructions. Building one explains registers, binary encoding and memory-mapped I/O, and connects software to hardware.
You will be able to
- Decode binary instructions with masks and shifts.
- Model registers, memory and condition flags.
- Implement memory-mapped I/O and trap routines for the keyboard and screen.
- Load and run real program images.
Skills it exercises
Recommended on Operating Systems & Linux and Data Structures & Algorithms.
How you know you are there
Work in any language. Each checkpoint ends with something you can run or observe, so you can check it yourself.
- Checkpoint 1Self-check
Fetch, decode, execute
Done when: The VM loads an image and executes ADD, LD and BR, with a unit test for each opcode.
- Checkpoint 2Self-check
Every opcode
Done when: All instructions of the architecture are implemented and tested.
- Checkpoint 3Self-check
I/O
Done when: Trap routines read keys and print characters, with the terminal in raw mode.
- Checkpoint 4Self-check
Real programs
Done when: 2048 or Rogue (LC-3), or a CHIP-8 game, is playable in your VM.
Stretch goals
- A disassembler and a single-step debugger for your VM.
- A Game Boy emulator as the next, much larger step.
Step-by-step guides
Pick one in a language you know (tutorial languages: C, C++). They open on the author’s site.
- C
Write your Own Virtual Machine(external site)
C, about 250 lines, with 2048 and Rogue to run at the end.
- C++
How to write an emulator (CHIP-8 interpreter)(external site)
C++, CHIP-8: a smaller machine with graphics.
- C
Writing a Game Boy emulator, Cinoop(external site)
C, a Game Boy emulator: the harder next step.
Where to go next
- Build your own Operating System
Advanced · 40–80 h
Practice builds are self-paced: Tech Atlas does not track them or count them as evidence. To show a skill, take its knowledge check from the skill page.
Tutorials come from codecrafters-io/build-your-own-x (CC0, snapshot of 2026-07-14, commit aa17439; links checked on 2026-10-19). Each tutorial belongs to its author and keeps its own licence; Tech Atlas links to it and does not host it. Briefs, checkpoints and the mapping to skills are Tech Atlas editorial drafts.