Minor refactoring
h3rald h3rald@h3rald.com
Thu, 05 Feb 2026 16:19:06 +0100
2 files changed,
11 insertions(+),
17 deletions(-)
M
examples/print16.xyw
→
examples/print16.xyw
@@ -1,11 +1,7 @@
-.include "devices.xyw" +; .include "devices.xyw" -$321 print16 JSRw -$0A terminal.output STB -end JMPw - ; Printing subroutine -; a16 -- | [xw] +; a16 -- | [x] .label print16 POPxw ; If value is less than 10, print single digit
M
examples/print8.xyw
→
examples/print8.xyw
@@ -1,20 +1,18 @@
-; Assumes .include "devices.xyw" +; .include "devices.xyw" ; Printing subroutine -; a8 -- | [xy] +; a8 -- | [x] .label print8 POPx ; If value is less than 10, print single digit - PSHx $A LTH print8.single JCNw - ; Divide by 10: stack becomes [remainder, quotient] - PSHx $A DIV - ; Save remainder to y for later - SWP POPy - ; Call print8 recursively with quotient (still on stack) + PSHx $0A LTH print8.single JCNw + ; Divide by 10: stack becomes [remainder, quotient] with quotient on TOP + PSHx $0A DIV + ; Call print8 recursively with quotient (on top, consumed by POPx) print8 JSRw - ; Print the saved remainder - PSHy $30 ADD terminal.output STB - CLRxy + ; Remainder is still on stack, print it + $30 ADD terminal.output STB + CLRx RTS .label print8.single ; Print single digit