Skip to content
/ vm Public

A virtual machine and lexer in C for a custom Aseembly-like language (.pvb). Capable of running on ATmega328p microprocessors.

Notifications You must be signed in to change notification settings

provrb/vm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Provrb VM

This project introduces a custom x86_64 Assembly-like language feature similiar syntax, operations, and syscalls.

How it Works

The applicaton consists of a lexer and bytecode virtual machine. After running the virtual machine with your .pvb file as an input, the lexer will break each instruction into tokens.

For eaxmple, a move instruction may look like this:

mov $5, rax ; here we are moving the number 5 into register 'rax'

And be tokenized as such:

OPCODE: OP_MOV, VALUE: 5 (i64), DEST: rax (index 1 in memory), SRC: NONE

If an instruction is invalid (insufficient amount of operands, unknown instruction, etc) or there is no '_start:' function/label declared, the lexer will throw a syntax error before running, and will provide a description on the error.

After a successful lexical analysis, the virtual machine will run each instruction, increasing the virtual machines instruction pointer. The instruction pointer corresponds to which instruction to run in an array of instructions.

Depending on the opcode in the instruction, the virtual machjine will perform an action. When jumping, the virtual machine can simply increment the instruction pointer a certain amount of times to skip previous instructions easily.

A .pvb program would like as a C program as such

About

A virtual machine and lexer in C for a custom Aseembly-like language (.pvb). Capable of running on ATmega328p microprocessors.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published