Skip to content

Simple Virtual Machine interpreting assembly language and computing on stack

Notifications You must be signed in to change notification settings

hblxo/abstract_vm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

abstract_vm

C++ simple virtual machine interpreting basic assembly language.

Description

42 school project using c++ to make a virtual machine that can interpret basic assembly language et perform operations between operands.

See file abstract-vm.en.pdf for full project instructions

Install && Launch

make && ./avm

Then you can write instructions.

Instructions :

Instructions Description
push v Pushes the value v at the top of the stack. The value must have one of the following form:
  • int8(n) : Creates an 8-bit integer with value n.
  • int16(n) : Creates a 16-bit integer with value n.
  • int32(n) : Creates a 32-bit integer with value n.
  • float(z) : Creates a float with value z.
  • double(z) : Creates a double with value z.
pop Unstacks the value from the top of the stack. If the stack is empty, the program execution must stop with an error
dump Displays each value of the stack.
assert v Asserts that the value at the top of the stack is equal to the one passed as parameter for this instruction.
add Unstacks the first two values on the stack, adds them together and stacks the result.
sub ... subtracts them, then stacks the result.
mul ... multiplies them, then stacks the result.
div ... divides them, then stacks the result.
mod ... calculates the modulus, then stacks the result.
max ... return the greater value.
min ... return the smaller value.
pow ...
sin ...
cos ...
tan ...
sqrt ...
and ...
xor ...
or ...
print Asserts that the value at the top of the stack is an 8-bit integer.
exit Terminate the execution of the current program.

Notes

Abstract-vm is a school project. Please note that this is my first project in C++. Some improvements are possible, such as :

  • color & verbose mode
  • execution of instructions in live
  • some minor corrections in operations
  • exception handling improvement
  • better options handling
  • etc.

About

Simple Virtual Machine interpreting assembly language and computing on stack

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published