diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-29 17:00:39 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-29 17:00:39 +0000 |
commit | fa3ecc00731d3f6045ba2c18aced28cb988d6fa9 (patch) | |
tree | 963bdf9cab634c890641856e418ce7a9f0354318 /examples/fib.asm | |
parent | 6a34fd2d2ee2159ebc8d1927de55bf9cc2a7dc8d (diff) | |
download | ovm-fa3ecc00731d3f6045ba2c18aced28cb988d6fa9.tar.gz ovm-fa3ecc00731d3f6045ba2c18aced28cb988d6fa9.tar.bz2 ovm-fa3ecc00731d3f6045ba2c18aced28cb988d6fa9.zip |
Easier to read documentation in examples
Diffstat (limited to 'examples/fib.asm')
-rw-r--r-- | examples/fib.asm | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/examples/fib.asm b/examples/fib.asm index 717ca8c..565c5a8 100644 --- a/examples/fib.asm +++ b/examples/fib.asm @@ -6,6 +6,7 @@ ;; Constants %const(limit) 12200160415121876738 %end + %const(increment_i) push.reg.word 2 push.word 1 @@ -31,36 +32,38 @@ ;; Setup entrypoint global main main: - ;; Setup iterator i + ;; Setup iterator I push.word 1 mov.word 2 - ;; Setup initial REG[0] = 1 and REG[1] = 1 + ;; Setup initial A -> W[0] = 1 and B -> W[1] = 1 push.word 1 mov.word 0 push.word 1 mov.word 1 - ;; Print REG[0] and REG[1] + ;; Print "$I: $A" and "($I + 1): $B" loopback: call print_pair - ;; REG[0] += REG[1] + ;; $A += $B push.reg.word 0 push.reg.word 1 plus.word mov.word 0 - ;; REG[1] += REG[0] + ;; $B += $A push.reg.word 0 push.reg.word 1 plus.word mov.word 1 + ;; IF $B >= $LIMIT ... push.word $limit push.reg.word 1 gte.word - ;; Jump to `loopback` + ;; THEN jump to `loopback` jump.if.byte loopback + ;; ELSE halt halt print_pair: |