JSVM

April 17, 2017 ยท View on GitHub

Javascript virtual machine is one instruction set machine to parse and execute an assembly like code. This machine is written to be used by students studying compilers and willing to test and debug generated byte code in a simple manner.

1. Instruction set

InstructionArgumentDescription
#String:-Define label
PUSH#NumberPush a number to the stack (32bit)
POP-Pop from stack
DATA#StringDefine variable with name
STORE#StringPut head in variable
LOAD#StringPush variable's value to stack
ADD-Addition
SUB-Substruction
MULT-Multiplication
DIV-Division
MOD-Remainder
AND-And
OR-Or
XOR-Exclusive or
Not-Ones' complement
RAS#Number<32Right arithmetic shift
RBS#Number<32Right binary shift
LS#Number<32Left shift
LT-Lower than
LE-Lower or equal to
JMP#LabelUnconditional jump to label
BEQ#LabelBranch to label if equal
BNE#LabelBranch to label if not equal
PRINT-Print integers in stack as characters until \0
PRINTN-Print number head of stack
READ-Read string and push it to stack
READN-Read number (32bit) and push it to stack

2. Features

  • Drag and drop byte code file
  • Step by step execution
  • Full code execution
  • GUI: Stack, Symbol table and Program counter

3. Todo

  • Tests and fixes
  • Add more instructions
  • Add a framebuffer
  • Better strings support
  • Older browsers support

Enjoy !