This commit is a WORK IN PROGRESS for the base implementation of the HyphaeVM. This will be squashed into a larger commit eventually when the work of implementing the HyphaeVM is finished. Of note, the ISA is mostly finished and much of the VM design is in place. Yet to be done are a few traps in mycelium, migrating pieces like the number package and the sexpr package into the VM package, and of course much testing. Signed-off-by: Ava Affine <ava@sunnypup.io>
303 lines
5.7 KiB
TOML
303 lines
5.7 KiB
TOML
# NOTE: keep libc out of this, thats what trap vector is for
|
|
# NOTE: to programmers: only registers allow mutable acess
|
|
|
|
[[instructions]]
|
|
name = "trap"
|
|
args = ["index"]
|
|
output = "result of function"
|
|
description = "triggers callback in trap vector at index"
|
|
|
|
[[instructions]]
|
|
name = "bind"
|
|
args = ["name", "operand"]
|
|
output = ""
|
|
description = "map name to operand in sym table."
|
|
|
|
[[instructions]]
|
|
name = "unbind"
|
|
args = ["name"]
|
|
output = ""
|
|
description = "remove name mapping from sym table."
|
|
|
|
[[instructions]]
|
|
name = "bound"
|
|
args = ["name"]
|
|
output = "expr = true if name is bound"
|
|
description = "test if a name is already bound"
|
|
|
|
[[instructions]]
|
|
name = "push"
|
|
args = ["operand"]
|
|
output = ""
|
|
description = "pushes operand onto stack."
|
|
|
|
[[instructions]]
|
|
name = "pop"
|
|
args = []
|
|
output = ""
|
|
description = "removes element at top of stack."
|
|
|
|
[[instructions]]
|
|
name = "enter"
|
|
args = []
|
|
output = ""
|
|
description = "create new stack frame"
|
|
|
|
[[instructions]]
|
|
name = "exit"
|
|
args = []
|
|
output = ""
|
|
description = "delete current stack frame"
|
|
|
|
[[instructions]]
|
|
name = "load"
|
|
args = ["src", "dest"]
|
|
output = ""
|
|
description = "copies src into dest"
|
|
|
|
[[instructions]]
|
|
name = "clear"
|
|
args = ["dest"]
|
|
output = ""
|
|
description = "clears dest"
|
|
|
|
[[instructions]]
|
|
name = "nop"
|
|
args = []
|
|
output = ""
|
|
description = "no operation"
|
|
|
|
[[instructions]]
|
|
name = "halt"
|
|
args = []
|
|
output = ""
|
|
description = "halts the VM"
|
|
|
|
[[instructions]]
|
|
name = "panic"
|
|
args = ["error"]
|
|
output = ""
|
|
description = "sets error state and halts VM"
|
|
|
|
[[instructions]]
|
|
name = "jmp"
|
|
args = ["addr"]
|
|
output = ""
|
|
description = "sets ictr register to addr"
|
|
|
|
[[instructions]]
|
|
name = "jmpif"
|
|
args = ["addr"]
|
|
output = ""
|
|
description = "if expr register holds true, sets ictr to addr"
|
|
|
|
[[instructions]]
|
|
name = "eq"
|
|
args = ["a", "b"]
|
|
output = "a == b"
|
|
description = "equality test"
|
|
|
|
[[instructions]]
|
|
name = "lt"
|
|
args = ["a", "b"]
|
|
output = "a < b"
|
|
description = "less than test"
|
|
|
|
[[instructions]]
|
|
name = "gt"
|
|
args = ["a", "b"]
|
|
output = "a > b"
|
|
description = "greater than test"
|
|
|
|
[[instructions]]
|
|
name = "lte"
|
|
args = ["a", "b"]
|
|
output = "a <= b"
|
|
description = "less than equals test"
|
|
|
|
[[instructions]]
|
|
name = "gte"
|
|
args = ["a", "b"]
|
|
output = "a >= b"
|
|
description = "greater than equals test"
|
|
|
|
[[instructions]]
|
|
name = "bool_not"
|
|
args = []
|
|
output = "expr = !expr"
|
|
description = "boolean not"
|
|
|
|
[[instructions]]
|
|
name = "bool_and"
|
|
args = ["a", "b"]
|
|
output = "a && b"
|
|
description = "boolean and"
|
|
|
|
[[instructions]]
|
|
name = "bool_or"
|
|
args = ["a", "b"]
|
|
output = "a || b"
|
|
description = "boolean or"
|
|
|
|
[[instructions]]
|
|
name = "byte_and"
|
|
args = ["a", "b"]
|
|
output = "a & b"
|
|
description = "bitwise and"
|
|
|
|
[[instructions]]
|
|
name = "byte_or"
|
|
args = ["a", "b"]
|
|
output = "a | b"
|
|
description = "bitwise or"
|
|
|
|
[[instructions]]
|
|
name = "xor"
|
|
args = ["a", "b"]
|
|
output = "a xor b"
|
|
description = "bitwise exclusive or"
|
|
|
|
[[instructions]]
|
|
name = "byte_not"
|
|
args = []
|
|
output = "expr = !expr"
|
|
description = "bitwise not"
|
|
|
|
[[instructions]]
|
|
name = "add"
|
|
args = ["a", "b"]
|
|
output = "a + b"
|
|
description = "numeric addition"
|
|
|
|
[[instructions]]
|
|
name = "sub"
|
|
args = ["a", "b"]
|
|
output = "a - b"
|
|
description = "numeric subtraction"
|
|
|
|
[[instructions]]
|
|
name = "mul"
|
|
args = ["a", "b"]
|
|
output = "a * b"
|
|
description = "numeric multiplication"
|
|
|
|
[[instructions]]
|
|
name = "fdiv"
|
|
args = ["a", "b"]
|
|
output = "a / b"
|
|
description = "numeric FLOAT division"
|
|
|
|
[[instructions]]
|
|
name = "idiv"
|
|
args = ["a", "b"]
|
|
output = "a / b"
|
|
description = "numeric INTEGER division"
|
|
|
|
[[instructions]]
|
|
name = "pow"
|
|
args = ["a", "b"]
|
|
output = "a ^ b"
|
|
description = "numeric operation to raise a to the power of b"
|
|
|
|
[[instructions]]
|
|
name = "modulo"
|
|
args = ["a", "b"]
|
|
output = "a % b"
|
|
description = "numeric modulo operation"
|
|
|
|
[[instructions]]
|
|
name = "rem"
|
|
args = ["a", "b"]
|
|
output = "remainder from a / b"
|
|
description = "remainder from integer division"
|
|
|
|
[[instructions]]
|
|
name = "inc"
|
|
args = ["src"]
|
|
output = ""
|
|
description = "increments number at source"
|
|
|
|
[[instructions]]
|
|
name = "dec"
|
|
args = ["src"]
|
|
output = ""
|
|
description = "decrements number at source"
|
|
|
|
[[instructions]]
|
|
name = "cton"
|
|
args = ["src"]
|
|
output = ""
|
|
description = "mutates a char datum into a number datum"
|
|
|
|
[[instructions]]
|
|
name = "ntoc"
|
|
args = ["src"]
|
|
output = ""
|
|
description = "mutates a number datum into a char datum"
|
|
|
|
[[instructions]]
|
|
name = "ntoi"
|
|
args = ["src"]
|
|
output = ""
|
|
description = "mutates a number datum into its exact form"
|
|
|
|
[[instructions]]
|
|
name = "ntoe"
|
|
args = ["src"]
|
|
output = ""
|
|
description = "mutates a number datum into its inexact form"
|
|
|
|
[[instructions]]
|
|
name = "mkvec"
|
|
args = []
|
|
output = "a blank vector"
|
|
description = "creates a new vector"
|
|
|
|
[[instructions]]
|
|
name = "mkbvec"
|
|
args = []
|
|
output = "a blank bytevector"
|
|
description = "creates a blank bytevector"
|
|
|
|
[[instructions]]
|
|
name = "index"
|
|
args = ["collection", "index"]
|
|
output = "collection[index]"
|
|
description = "extracts element from collection at index"
|
|
|
|
[[instructions]]
|
|
name = "length"
|
|
args = ["collection"]
|
|
output = "length of collection"
|
|
description = "calculates length of collection"
|
|
|
|
[[instructions]]
|
|
name = "subsl"
|
|
args = ["collection", "start", "end"]
|
|
output = "collection[start:end]"
|
|
description = "returns a subset from collection denoted by start and end indexes"
|
|
|
|
[[instructions]]
|
|
name = "inser"
|
|
args = ["collection", "elem", "idx"]
|
|
output = ""
|
|
description = "inserts an element at specified index into a collection"
|
|
|
|
[[instructions]]
|
|
name = "cons"
|
|
args = ["left", "right"]
|
|
output = "resulting collection"
|
|
description = "either append right to left or make new list from both"
|
|
|
|
[[instructions]]
|
|
name = "car"
|
|
args = ["list"]
|
|
output = "returns first element in cons cell"
|
|
description = "takes an AST and returns first element in top level cons cell"
|
|
|
|
[[instructions]]
|
|
name = "cdr"
|
|
args = ["list"]
|
|
output = "returns last element in cons cell"
|
|
description = "takes an AST and returns last element in top level cons cell"
|
|
|