diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-03-05 22:08:17 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-03-05 22:08:17 +0200 |
| commit | ff8a3bc4ac48f8025d793c078f4c6d2ffbce4019 (patch) | |
| tree | 1acef1429d0a4776a6eb2450732a8d8c570c1a71 /atk16_schasm/main.scm | |
| parent | 4932c084731d87bf6039535f28dd7c0a40af73bc (diff) | |
Add procedure declaration & call macros
Diffstat (limited to 'atk16_schasm/main.scm')
| -rw-r--r-- | atk16_schasm/main.scm | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/atk16_schasm/main.scm b/atk16_schasm/main.scm index 3258a7f..a3f16ad 100644 --- a/atk16_schasm/main.scm +++ b/atk16_schasm/main.scm @@ -47,7 +47,7 @@ (def-label 'branch-true (emit-word 2)) -;; use macros for convenience +;; use macros like %if, %while for convenience (let ((x #x5678)) (%if-else (R1 == R2) (emit-word #x1234) @@ -56,11 +56,18 @@ (%if (R1 <= (u16 #xFF)) (emit-word #xbeef)) -(comment - (ld R1 (u16 10)) - (%while (R1 > (u16 0)) - (%call println (label 'text-data)) - (sub R1 (u16 1)))) +;; procedure declarations +(%def-proc println str) +(def-label 'println + ;; R0 := str + ;; ... + (ld PC SP pop: #t indirect: 1)) + +;; procedure calls +(ld R1 (u16 10)) +(%while (R1 > (u16 0)) + (%call println (label 'text-data)) + (sub R1 (u16 1))) ;; compile to a 128KB image file (write-image-to "out.bin") |
