This document provides a technical specification for the Zero VM assembly instructions. The Virtual Machine operates on a Stack-Based Architecture where most instructions pop operands from the top of the stack and push results back.
Description: Pops the top value from the stack and stores it in a specified location.
STORE <index>: Pops the value and stores it at the absolute stack index.STORE [*]: Pops the value into the ei (Return Value) register.STORE #<offset>: Pops the value and stores it at the relative positionbp + offset(Base Pointer offset).
Description: Loads a value from a specified location and pushes it onto the stack.
LOAD <index>: Loads data from the absolute stack index.LOAD [*]: Loads data from the ei register.LOAD #<offset>: Loads data from the relative positionbp + offset.LOAD .<name>: Loads the function pointer associated withnamefrom the Symbol Table.
These instructions push literal values of specific types onto the stack.
| Instruction | Type | Example | Description |
|---|---|---|---|
| PUSH_D | Integer | PUSH_D 1 |
Push a 64-bit integer. |
| PUSH_F | Float | PUSH_F 1.2 |
Push a double-precision floating point. |
| PUSH_B | Boolean | PUSH_B 1 |
Push true (1) or false (0). |
| PUSH_S | String | PUSH_S "text" |
Push a string constant. |
| PUSH_N | Null | PUSH_N |
Push a null value. |
Description: Transfers control to a function.
CALL <name>: Calls the function by its identifier.CALL -1: Dynamic call. Pops the value attop - 1and treats it as a function pointer to execute.
Description: Cleans up the stack.
FREE <n>: Removesnelements from the top of the stack.
Description: Property access for objects.
- Pops
a(attribute name) andb(object). - Pushes the value of
b.aonto the stack. Requiresbto be anObjecttype.
Description: Property set for objects.
- Pops
a(attribute name) andb(object) andc(value). - Set
ctoa.b.
Description: Direct assignment.
- Pops value
a. Assigns it to the element attop - 1. - Requirement: The element at
top - 1must be a reference type.
Unless otherwise specified, these instructions pop two values: a (top) and b (top-1), then push the result of b [op] a.
| Mnemonic | Operation | Description |
|---|---|---|
| ADD | b + a |
Addition. |
| MINUS | b - a |
Subtraction. |
| MULTI | b * a |
Multiplication. |
| DIV | b / a |
Division. |
| NEGATE | -a |
Pops a, pushes its arithmetic negation. |
- G / GE: Greater Than (
b > a) / Greater or Equal (b >= a). - L / LE: Less Than (
b < a) / Less or Equal (b <= a). - E / NE: Equal (
b == a) / Not Equal (b != a). - NOT: Logical NOT (
!a). Popsa, pushes inverted boolean result.
Description: Unconditional relative jump.
JUMP <offset>: Moves the Program Counter (PC) by the specified offset (e.g.,PC = PC + offset).
Description: Conditional relative jump.
- Pops the top value. If it is
false,PC = PC + offset. Otherwise, proceeds to the next instruction.