VYantra or Virtual Yantra is a minimalistic assembly language and a virtual machine. 'Yantra' is Sanskrit for a machine.
Because I want to learn something new (2).
For now, it supports some instructions using which you can load scaler values and perform mathematical and logical operations, jump statements etc. to get the answer to life universe and everything. Eventually I plan to add support for functions and more instructions to it.
It can't solve any of the real life problems yet. Its like a little more than zygote now - not even an embryo.
git clone this repo in whatever directory you like.
git clone https://github.com/prabhatexit0/vyantra-v2.git
Get into that directory and run the make command
cd vyantra-v2 && make
also optionally you can install yantra in you are on linux by running the following command while in project root directory
sudo make install
Create a file with .ys extension and appropirate yantra language syntax (Syntax is documented below). Then while you are in root directory of the project you can execute it like this:
./yantra.out {file_name}.ys
and in case you've installed it, then from any directory where your file is located by doing:
yantra {file_name}.ys
also you can add -v flag if you want to see verbose output.
For verbose console output:
if you've installed:
yantra {file_name}.ys -v
and if you have not installed (from project root directory):
./yantra.out {file_name}.ys -v
Vyantra is a register based VM and supports three registers.
Three registers can be accessed in the language using A, B and C for first, second and third register repectively.
and you can load positive integer value by prefixing it with #.
- Loading instructions into the memory:
load {A | B | C} #{integer_value}
- Performing binary operations:
Some binary mathematical and logical operations are also supported.
Binary Instructions:
add,sub,mult,div,and,or,xor
{binary_instruction} {loading register} {operand register one} {operand register two}
- Jump Statements
you can define label by prefixing a postive integer value with
:Like this:
:{int_value}
and to jump to he label defined, You can use this instruction.
jmp {int_value}
- To halt a program. You can use
haltinstruction.
halt
!start
load A #40
load B #2
add C B C
show C
!end
Warning: Infinite loop
!start
:9
load B #40
load C #2
add A B C
show A
show B
show C
jmp 9
!end
more to be added soon