diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-03 21:27:18 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-03 21:27:18 +0000 |
commit | bc4c57b243eaad8ef054d6ab7de7602b76b22f0d (patch) | |
tree | 0db4a1b4fc3b4ed48b5b896a04cdc1c82cd2eecf /examples/factorial.asm | |
parent | dea8e238074291c181f6780e445d046d08ca6668 (diff) | |
download | ovm-bc4c57b243eaad8ef054d6ab7de7602b76b22f0d.tar.gz ovm-bc4c57b243eaad8ef054d6ab7de7602b76b22f0d.tar.bz2 ovm-bc4c57b243eaad8ef054d6ab7de7602b76b22f0d.zip |
Use label features and entry points for examples
Diffstat (limited to 'examples/factorial.asm')
-rw-r--r-- | examples/factorial.asm | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/factorial.asm b/examples/factorial.asm index 08c3c13..2d4b6f9 100644 --- a/examples/factorial.asm +++ b/examples/factorial.asm @@ -1,7 +1,10 @@ -;;; factorai.asm: A program that generates the factorials of each +;;; factorial.asm: A program that generates the factorials of each ;;; number from 1 to 24 (24!~=UINT64_MAX). Using the registers to ;;; store `n` and `n!`. + ;; Setup entrypoint + global main +main: ;; Setup initial REG[0] = 1 and REG[1] = 1 push.word 1 mov.word 0 @@ -9,7 +12,7 @@ mov.word 1 ;; Print `REG[0]: REG[1]` - ;; Here is the loop back point `#` +loopback: push.byte '\t' print.char push.reg.word 0 @@ -39,5 +42,5 @@ push.reg.word 0 gte.word ;; Jump to `#` - jump.if.byte 4 + jump.if.byte loopback halt |