summaryrefslogtreecommitdiff
path: root/vm.md
diff options
context:
space:
mode:
Diffstat (limited to 'vm.md')
-rw-r--r--vm.md32
1 files changed, 32 insertions, 0 deletions
diff --git a/vm.md b/vm.md
index 8cde69d..ba705a5 100644
--- a/vm.md
+++ b/vm.md
@@ -38,3 +38,35 @@ 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
+
+## manually translated onlymain.golem
+
+```
+gyte size: 1
+; store stack offset and program counter
+call main
+; quit
+stop
+main:
+ ; stack offset
+ push s0
+ push 2
+ add
+ save s0
+ ; argv
+ push (s0-1)
+ ; (sub argc 1)
+ push (s0-2)
+ push 1
+ sub
+ ; [argv (sub argc 1)]
+ deref
+ ; (print [argv (sub argc 1)]
+ print
+ ; return (less argc 2)
+ push (s0-2)
+ push 2
+ sub
+ ; restore stack offset and program counter
+ ret
+```