This repository contains an MVP for a basic virtual machine implementation for LC3 architecture. It is a Rust version of this tutorial.
A VM is a program that acts like a computer. 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. Most importantly, it can understand a machine language which you can use to program it. (This paragraph was taken from Justin Meiners' "Write your own virtual machine").
LC-3 is an assembly language created for teaching purposes that implements a reduced set of instructions. The architecture includes:
- a set of 16 instructions.
- a memory with a 2^16 location address space.
- a word of 16 bits.
For further information on LC-3 check:
- Rust toolchain installed
- Make installed.
In order to run a binary with the VM you can run the command
make run path=<binary-path>
This repository provides two example programs that are inside the binary-examples repository. In order to execute any of them you could use:
make run path=./binary-examples/2048.obj
or
make run path=./binary-examples/rogue.obj
The binaries were taken as examples from the following repositories:
This repository contains full explanatory inline comments for the implementation. In order to see it in a friendlier way you can run
make doc
that will generate source code documentation and open it in the browser.
make build: allows the user to build the VM.make test: allows the user to run the tests.