From bc4c57b243eaad8ef054d6ab7de7602b76b22f0d Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Fri, 3 Nov 2023 21:27:18 +0000 Subject: Use label features and entry points for examples --- examples/fib.asm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'examples/fib.asm') diff --git a/examples/fib.asm b/examples/fib.asm index 5542f48..4d61d5c 100644 --- a/examples/fib.asm +++ b/examples/fib.asm @@ -3,6 +3,10 @@ ;;; pairs of fibonacci numbers, we ensure only a finite amount of ;;; memory is necessary for this program to function, unlike a pure ;;; stack version. + + ;; Setup entrypoint + global main +main: ;; Setup initial REG[0] = 1 and REG[1] = 1 push.word 1 mov.word 0 @@ -10,7 +14,7 @@ mov.word 1 ;; Print REG[0] and REG[1] - ;; Here is the loop back point `#` +loopback: push.byte '\t' print.char push.reg.word 0 @@ -41,5 +45,5 @@ push.reg.word 1 gte.word ;; Jump to `#` - jump.if.byte 4 + jump.if.byte loopback halt -- cgit v1.2.3-13-gbd6f