diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-03-08 00:48:20 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-03-08 00:48:20 +0200 |
| commit | 7f83828988c2efab56f37c1711cbf6118be8234f (patch) | |
| tree | d0990b1a9c3e607d4bac3c44f884455dba7c49e6 /atk16_schasm/main.scm | |
| parent | 501a434ff5834cba51b9efcff1fe18cd75f87334 (diff) | |
Refactor, improve
Diffstat (limited to 'atk16_schasm/main.scm')
| -rw-r--r-- | atk16_schasm/main.scm | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/atk16_schasm/main.scm b/atk16_schasm/main.scm index 931a9db..4dc353a 100644 --- a/atk16_schasm/main.scm +++ b/atk16_schasm/main.scm @@ -8,7 +8,7 @@ (emit-word #x1234) ;; compile instructions -(ld SP (u16 0)) +(ld SP ZR (u16 0)) ;; set labels (def-label 'some-data @@ -22,13 +22,13 @@ (add R3 (u16 #xFF))) ;; abs jump -(ld PC (label 'main)) +(ld PC ZR (label 'main)) ;; rel jump (add PC (i16 10)) ;; jump forward to a currently undefined label -(ld PC (label 'forward)) +(ld PC ZR (label 'forward)) (def-label 'forward (hlt)) @@ -52,15 +52,21 @@ (emit-word x))) (%when (R1 <= (u16 #xFF)) - (emit-word #xbeef)) + (emit-word #xbeef)) ;; procedures -(%def-proc (println *str) - (param '*str) ;; => R0 - (ld PC SP pop: #t indirect: 1)) +(%proc (println *str) + + (%param *str) ;; => evaluates to R0 + ;;(%svar x 1) ;; allocate a word on the stack + ;;(%svar y 1) ;; allocate another word on the stack + ;;(%soffset y) ;; => evaluates to frame offset 1 + + ;; %proc epilogue fees the %svars + ) ;; procedure calls -(ld R1 (u16 10)) +(ld R1 ZR (u16 10)) (%while (R1 > (u16 0)) (%call println (label 'text-data)) (sub R1 (u16 1))) |
