Instructions¶
-
enum UNIT_Instruction¶
Enumerated type containing the ID for all UNIT stack-based instructions.
-
enumerator UNIT_OP_LOAD_STRING¶
-
enumerator UNIT_OP_LOAD_INTEGER¶
-
enumerator UNIT_OP_ADD¶
-
enumerator UNIT_OP_SUBTRACT¶
-
enumerator UNIT_OP_MULTIPLY¶
-
enumerator UNIT_OP_DIVIDE¶
-
enumerator UNIT_OP_MODULO¶
-
enumerator UNIT_OP_RETURN_VALUE¶
-
enumerator UNIT_OP_EXIT¶
-
enumerator UNIT_OP_POP¶
-
enumerator UNIT_OP_PREPARE_CALL¶
-
enumerator UNIT_OP_CALL_NAME¶
-
enumerator UNIT_OP_STORE_LOCAL¶
-
enumerator UNIT_OP_LOAD_LOCAL¶
-
enumerator UNIT_OP_ADDRESS_OF¶
-
enumerator UNIT_OP_COMPARE_EQUAL¶
-
enumerator UNIT_OP_COMPARE_NOT_EQUAL¶
-
enumerator UNIT_OP_COMPARE_GREATER¶
-
enumerator UNIT_OP_COMPARE_GREATER_EQUAL¶
-
enumerator UNIT_OP_COMPARE_LESS¶
-
enumerator UNIT_OP_COMPARE_LESS_EQUAL¶
-
enumerator UNIT_OP_JUMP_TO¶
-
enumerator UNIT_OP_JUMP_IF_TRUE¶
-
enumerator UNIT_OP_JUMP_IF_FALSE¶
-
enumerator UNIT_OP_COPY¶
-
enumerator UNIT_OP_SWAP¶
-
enumerator UNIT_OP_READ_BYTES¶
-
enumerator UNIT_OP_WRITE_BYTES¶
-
enumerator UNIT_OP_CAST¶
-
enumerator UNIT_OP_PUSH_VIRTUAL¶
-
enumerator UNIT_OP_LOAD_STRING¶
Constants¶
Opcode |
Effect |
Description |
|---|---|---|
|
Push a constant 32-bit integer onto the stack. |
|
|
Push a constant string onto the stack. |
Arithmetic¶
Opcode |
Effect |
Description |
|---|---|---|
|
Add two numbers together. |
|
|
Subtract two numbers. |
|
|
Multiply two numbers together. |
|
|
Divide two numbers. |
|
|
Take the remainder of two numbers. |
Local Variables¶
Opcode |
Effect |
Description |
|---|---|---|
|
Store a value into a local variable. |
|
|
Read the value of a local variable. |
|
|
Push the memory address of a local variable. |
Memory Access¶
Opcode |
Effect |
Description |
|---|---|---|
|
Read |
|
|
Write |
Comparisons¶
Opcode |
Effect |
Description |
|---|---|---|
|
Compare two values for equality. |
|
|
Compare two values for inequality. |
|
|
Check whether a value is greater than another. |
|
|
Check whether a value is greater than or equal to another. |
|
|
Check whether a value is less than another. |
|
|
Check whether a value is less than or equal to another. |
Control Flow¶
Opcode |
Effect |
Description |
|---|---|---|
|
Unconditionally jump to a label. |
|
|
Jump to a label if the top of the stack is nonzero. |
|
|
Jump to a label if the top of the stack is zero. |
Function Calls¶
Opcode |
Effect |
Description |
|---|---|---|
Collects |
Prepare arguments for a function call. Used internally by |
|
|
Call a named function and push its return value. |
|
|
Declare a procedure parameter. Used at the start of a procedure body. |
Stack Manipulation¶
Opcode |
Effect |
Description |
|---|---|---|
|
Discard the value on top of the stack. |
|
|
Duplicate a stack item. With no argument, copies the top. |
|
|
Swap two stack items. With no argument, swaps the top two. |
Type Conversion¶
Opcode |
Effect |
Description |
|---|---|---|
|
Cast the top of the stack to the integer type specified by |
Program Control¶
Opcode |
Effect |
Description |
|---|---|---|
|
Return a value and end execution of the current procedure. |
|
|
Exit the entire program with the given status code. |