Get the latest tech news
Write Your Own Virtual Machine (2022)
By: Justin Meiners and Ryan Pendleton View the final code and other resources in the GitHub repo. In this tutorial, I will teach you how to write your own virtual machine (VM) that can run assembly language programs, such as my friend’s 2048 or my Roguelike.
It simulates a CPU along with a few other hardware components, allowing it to perform arithmetic, read and write to memory, and interact with I/O devices, just like a physical computer. KBSR and KBDR allows you to poll the state) of the device and continue execution, so the program can stay responsive while waiting for input. Not only does this method reduce code duplication, but it’s also closer to how a computer would actually be wired in hardware, where each processing step must occupy physical space on a chip.
Or read this on Hacker News