From 47c8fc6e1e179427b468bf38eaac9395d74cfcaf Mon Sep 17 00:00:00 2001 From: kdx Date: Sun, 19 Mar 2023 03:20:42 +0100 Subject: golem's vm early draft --- vm.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 vm.md 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 -- cgit v1.2.3