Experimental Universal Virtual Machine (pip install arkhe
) (python -m arkhe
)
Check out arkhe.vm.TypeTable
LOAD REGISTER OPERANDS+ TYPE?
Type is optional and int by default.
Takes 2 operands, maximum 2^16
(operand1 << 8) | operand2
Takes n operands as hex.
{OPERATION} R1 R2 TARGET
=
TARGET_REG = R1 {OPERATION} R2
- ADD
- SUB
- MUL
- TRUEDIV
Mapped from python's operator
module.
JMP R1
Set counter to given register's value
JMP{F/B} R1
F for forward, B for backward. Increment or decrement counter's value by R1's value
{OPERATION} R1 R2
Sets _eqflag
of Arkhe
instance to the result of given operation. Mapped directly from operators
library
- EQ
- NE
- LT
- GT
- GE
- LE
JEQ R1
JNQ R1
JEQ: Set counter to R1's value if _eqflag
is True
JNQ: Set counter to R1's value if _eqflag
is False
ALLOC R1
DEALLOC R1 0/1
INSERT R1 R2
READ R1 R2
ALLOC: Allocates memory amount of R1 DEALLOC: Deallocates memory amount of R1 from Head (1) or Tail (0) INSERT: Insert r2's value to memory. r1 points to segment for insertment READ: Read value from memory and set it to r2. r1 points to segment for read operation.
SYMSET R1 R2
SYMREAD R1 R2
SYMSET: Updates record on symtable with k:v
pair of R1:R2
SYMREAD: Reads symtable record with key
as R1 and loads value to R2
NOP does nothing, HLT raises arkhe.vm.HLT
exception.