From 7f83828988c2efab56f37c1711cbf6118be8234f Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 8 Mar 2025 00:48:20 +0200 Subject: Refactor, improve --- atk16_schasm/main.scm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'atk16_schasm/main.scm') 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))) -- cgit v1.3