Skip to content

soufianeamini/abstract-vm

Repository files navigation

Abstract-Vm

The purpose of this project is to create a simple virtual machine that can interpret programs written in a basic assembly language.

How to build

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

How to run

./avm

The avm will read from standard input and interpret code after each ';;' token.

./avm example.avm

The avm will read the file and execute the instructions in it provided the assembly code is correct.

How to run tests

There are two tests: Unit tests and integration tests.

  1. Unit tests To run unit tests, make sure to uncomment the #define DEBUG line at the top of the main.cpp file. Then run make run.

  2. Integration tests In order to run integration tests, make sure the line #define DEBUG at 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/

Features

This project features multiple things:

Virtual Machine

AVM is a stack based virtual machine that can interpret an assembly language with a limited and explicit type system.

.avm files

.avm are files that contain assembly code that respects the grammar dictated in grammar.txt.

Errors

Files containing syntax error will not be interpreted. An .avm file needs to contain an exit instruction.

Formatter

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.

Implementation details

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.

About

Repository for Abstract-Vm project in c++17

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published