summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kdx@42l.fr>2023-03-19 03:20:42 +0100
committerkdx <kdx@42l.fr>2023-03-19 03:20:50 +0100
commit47c8fc6e1e179427b468bf38eaac9395d74cfcaf (patch)
tree7dd4c4f0a8529579e7f79d397584f03671f5c0a5
parent6d9b7f9f2116be36a3069dfcdc0b301f5f94a38a (diff)
downloadgolem-47c8fc6e1e179427b468bf38eaac9395d74cfcaf.tar.gz
golem's vm early draft
-rw-r--r--vm.md40
1 files changed, 40 insertions, 0 deletions
diff --git a/vm.md b/vm.md
new file mode 100644
index 0000000..8cde69d
--- /dev/null
+++ b/vm.md
@@ -0,0 +1,40 @@
+# GOLEM's VM
+
+GOLEM should compile to *something*, and bytecode seems to be the most
+appropriate for various reasons, including portability and longevity.
+
+This VM (and GOLEM in general) won't be optimisation beasts, but they will be
+functionnal and if a need to make a large GOLEM program faster comes up in the
+future it will be certainly doable by writing a custom compiler. Consider this
+to be a reference implementation.
+
+## gyte size
+
+GOLEM bytes will be called gytes to avoid any confusion. Bytes in this document
+will refer to 8 bits.
+
+Gyte size could be program specific or fixed.
+
+## header
+
+1 byte will contain gyte size.
+
+1 gyte will contain static data size.
+
+Static data will be stored in the header and will be loaded at the start of the
+VM memory.
+
+## memory
+
+GOLEM needs two memory regions:
+* the stack for small volatile data
+* the heap for allocated, large or long lasting data
+
+Memory sizes should be specified to the VM.
+
+## VM stacks
+
+GOLEM will have two stacks (to not counfound with memory stack):
+* the instruction stack to be used by instructions and immediate operations
+* the return stack used to store the program counter on function call and
+restore it on return