diff options
Diffstat (limited to 'vm.md')
-rw-r--r-- | vm.md | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -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 +``` |