summaryrefslogtreecommitdiff
path: root/vm.md
diff options
context:
space:
mode:
authorkdx <kdx@42l.fr>2023-03-19 03:47:59 +0100
committerkdx <kdx@42l.fr>2023-03-19 03:47:59 +0100
commit8721f551a0c796960b941e3abc4f1cc2c35eaac4 (patch)
tree42c673f896793af712b904664832f39b227e35ef /vm.md
parent47c8fc6e1e179427b468bf38eaac9395d74cfcaf (diff)
downloadgolem-8721f551a0c796960b941e3abc4f1cc2c35eaac4.tar.gz
i'm insane
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
+```