4.2 Instructions

Since the virtual machine is stack-based, every instruction representing an operation will pop it’s operands, and push the result to the stack.

mnemonicdescriptionbnf object
notNot, invert the bits of the operandnot
lnotLogical not, invert the boolean interpretation of the operandlnot
negNegate, switch the sign of the operandneg
andAnd, performs a binary AND operation between two operandsand
orOr, performs a binary OR operation between two operandsor
xorExclusive or, performs a binary XOR operation between two operandsxor
shlLeft bitshift, shifts the bits of the operand to the left, appending zeroesshl
shrRight bitshift, shifts the bits of the operand to the right, appending zeroesshr
landLogical and, boolean interpretation of the logical AND on two operandsland
lorLogical or, boolean interpretation of the logical OR on two operandslor
addAddition, adds the value of two operandsadd
subSubstraction, subtract the value of two operandssub
multMultiplication, multiplies the value of two operandsmult
divDivision, return the dividend of the euclidian division of operand 1 by operand 2div
modModulo, return the rest of the euclidian division of operand 1 by operand 2mod
gtGreater than, compares the two operands and return a result for boolean interpretationgt
geGreater than or equals to, compares the two operands and return a result for boolean interpretationge
ltLess than, compares the two operands and return a result for boolean interpretationlt
leLess than or equals to, compares the two operands and return a result for boolean interpretationle
eqEquals, compares the two operands and return a result for boolean interpretationeq
neqDifferent from, compares the two operands and return a result for boolean interpretationdiff
updzUpdate zero flag, pops the value from the stack and set it as the new zero flagupdz
pushPush value, push a 64 bits value to the stackpush_value
pushPush relative address, push a 64 bits relative address to the stack, corresponding generally to a labelpush_label
pushPush from stack pointer relative address, push to the stack the 8 bytes found at the stack pointer + the address given as operandpush_stack
popPop empty, pop 8 bytes from the stackpop
popPop to stack pointer relative address, pop 8 bytes from the stack, and write them to the stack pointer + the address given as operandpop_stack
callCall, op 8 bytes from the stack, register the new stack pointer, push the PC and stack pointer to the callstack, and jump to the value of the 8 bytes popped from the stackcall
retReturn, reset the stack to the stack pointer, pop the callstack and jump to the address from the callstack popret
jmpJump, pop an address from the stack, and set the PC to itjmp
zjmpZero jump, pop an address from the stack, and if the zero flag is set, set the PC to itzjmp
affShow, pop 8 bytes from the stack, apply a modulo 256 to the result, and write a single ascii character corresponding to the resultaff
affsShow string, the first operand is a 64 bits integer corresponding to the number of caracters, that we will call n. The next n bytes are the ascii values of the characters that will be wroteaffs