The purpose of this project is to create a simple virtual machine that can interpret programs written in a basic assembly language.
Run the command make in order to download dependencies and build the project.
You will need to have the following dependencies installed on your system:
- clang
- make
- cmake
- python
./avmThe avm will read from standard input and interpret code after each ';;' token.
./avm example.avmThe avm will read the file and execute the instructions in it provided the assembly code is correct.
There are two tests: Unit tests and integration tests.
-
Unit tests To run unit tests, make sure to uncomment the
#define DEBUGline at the top of the main.cpp file. Then runmake run. -
Integration tests In order to run integration tests, make sure the line
#define DEBUGat the top of main.cpp is commented out. Then run the following commands:
python -m venv .venv
source .venv/bin/activate
pip install ward
ward -p tests/This project features multiple things:
AVM is a stack based virtual machine that can interpret an assembly language with a limited and explicit type system.
.avm are files that contain assembly code that respects the grammar dictated in grammar.txt.
Files containing syntax error will not be interpreted. An .avm file needs to contain an exit instruction.
To run the formatter, you can execute the following command:
./amv --format <.avm-file>The output is a nicely formatted .avm file, and you can redirect the output to whatever file you want.
The project is implemented using a Lexer/Parser couple, and a Vm class that interprets the instructions generated by the parser. It executes mathematical operations following an infix notation, and it checks for overflows and underflows. It is compiled with -std=c++17.