all repos — xyw @ 648bdb2a57690f31ef43cab8c3f858f42edbbf2f

A minimal virtual machine and assembler for terminals.

More macro usage.
h3rald h3rald@h3rald.com
Fri, 06 Feb 2026 08:34:54 +0100
commit

648bdb2a57690f31ef43cab8c3f858f42edbbf2f

parent

9f4ba1cb0a2a468ccc1f1af4ed7a54cbb10c87c5

4 files changed, 10 insertions(+), 10 deletions(-)

jump to
M examples/factorial16.xywexamples/factorial16.xyw

@@ -15,7 +15,7 @@ .label fact.loop

; Need to work with 16-bit comparisons ; but JCN only works with 8-bit values, so remove high byte first PSHyw $00 $00 EQUw LBYTE fact.end0 JCNw - PSHyw $00 $01 EQUw SWP POP fact.end1 JCNw + PSHyw $00 $01 EQUw LBYTE fact.end1 JCNw ; Decrement y and multiply DECyw PSHxw PSHyw MULxw POPxw fact.loop JMPw
M examples/helloworld.xywexamples/helloworld.xyw

@@ -12,7 +12,7 @@ ; store top of stack to register XW

POPxw .label print.loop ; dereference address in XW and print - LDBxw terminal.output STB + LDBxw PUTC ; increment address, dereference ; go back to loop unless zero INCxw LDBxw print.loop JCNw
M examples/print-args.xywexamples/print-args.xyw

@@ -9,19 +9,19 @@ ; on_argument event handler

.label print-args terminal.input POPx ; If end of argument, print new line and end - LDBx $1D EQU print-args.end JCNw - LDBx $1E EQU print-args.next JCNw + LDBx arg.end EQU print-args.end JCNw + LDBx arg.sep EQU print-args.next JCNw ; Print typed character - LDBx terminal.output STB + LDBx PUTC RTS ; Print argument separator (, ) .label print-args.next - $2C terminal.output STB - $20 terminal.output STB + $2C PUTC + SP RTS ; Print new line .label print-args.end - $0A terminal.output STB + NL RTS .label end
M examples/print-stdin.xywexamples/print-stdin.xyw

@@ -9,9 +9,9 @@

; on_keypress event handler .label print-key ; Print typed character - terminal.input LDB terminal.output STB + terminal.input LDB PUTC ; Print new line - $0A terminal.output STB + NL BRK .label end