A tiny stack machine
Build a bytecode interpreter in C: an array of instructions, a stack, a program counter and a switch in a loop, with jumps that make loops.
- The skill
- Build a tiny virtual machine that runs a list of numbers as a program, and see how a processor steps through code.
- You make
- A bytecode interpreter with arithmetic and jumps, a countdown written in its own machine code, and a reverse Polish calculator.
Premium lesson
£7.99 a month or £59 a year. Cancel any time.
Builds on 36 Bit flags. Free to try: C Foundations and the playground.
Passed
You can now
Step 1 of 8
exercise_1.c
You've reached the good stuff.
4 exercises in this lesson, checked as you type. Premium opens every lesson after Foundations, in all four courses.
C, 32-bit: int and pointers are 4 bytes