all repos — xyw @ 395628d9ec3313e89f559477056eaba72e1e1ad7

A minimal virtual machine and assembler for terminals.

Minor refactoring
h3rald h3rald@h3rald.com
Thu, 05 Feb 2026 16:19:06 +0100
commit

395628d9ec3313e89f559477056eaba72e1e1ad7

parent

64345b1903b465ca0ec1c960896ecc206baa02f9

2 files changed, 11 insertions(+), 17 deletions(-)

jump to
M examples/print16.xywexamples/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.xywexamples/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