all repos — xyw @ 523f6dd495365a28d5d74a0b57a225170ce7dd4c

A minimal virtual machine and assembler for terminals.

Fixed examples to use HLT and RTS instructions properly.
h3rald h3rald@h3rald.com
Fri, 27 Feb 2026 17:52:57 +0100
commit

523f6dd495365a28d5d74a0b57a225170ce7dd4c

parent

646f057cb6472175f8030b4dcc8ecb45d8581cf1

M examples/factorial16.xywexamples/factorial16.xyw

@@ -4,7 +4,7 @@ ; Main program: calculate and print factorial of 7

$0007 fact JSRw putdw JSRw NL -end JMPw +HLT ; Factorial subroutine ; a16 -[xy]-

@@ -29,5 +29,3 @@ PSHxw

RTS .include "lib/putdw.xyw" - -.label end
M examples/factorial8.xywexamples/factorial8.xyw

@@ -4,7 +4,7 @@ ; Main program: calculate and print factorial of 5

$05 fact JSRw putd JSRw NL -end JMPw +HLT ; Factorial subroutine ; a8 -[xy]-

@@ -27,5 +27,3 @@ PSHx

RTS .include "lib/putd.xyw" - -.label end
M examples/helloworld.xywexamples/helloworld.xyw

@@ -1,6 +1,6 @@

; main program hello print JSRw -end JMPw +HLT ; a16 -- ; printing subroutine

@@ -19,4 +19,3 @@

; store null-terminated string .label hello .string "Hello, World!\n" -.label end
M examples/korobeiniki.xywexamples/korobeiniki.xyw

@@ -27,7 +27,7 @@ $01 beeper.level STB

; Repeat unless we are at the end of the song PSHxw end-song LTHw play JCNw ; Terminate - $00 system.state STB + HLT .label start-song
M examples/on-error.xywexamples/on-error.xyw

@@ -5,7 +5,7 @@ on_error system.on_error STW

; Main program $10 $00 DIV -end JMPw +HLT ; on_error handler ; --

@@ -25,5 +25,3 @@ .label div-by-zero-error

.string "Error: Division by zero.\n" .label unknown-error .string "Error: Unknown error.\n" - -.label end
M examples/print-args.xywexamples/print-args.xyw

@@ -3,7 +3,7 @@

; Set on_argument event handler print-args terminal.on_argument STW ; End program -end JMPw +HLT ; on_argument event handler ; -[x]-

@@ -24,5 +24,3 @@ ; Print new line

.label print-args.end NL RTS - -.label end
M examples/print-stdin.xywexamples/print-stdin.xyw

@@ -3,7 +3,7 @@

; Set on_keypress event handler print-key terminal.on_keypress STW ; End program -end JMPw +HLT ; on_keypress event handler ; --

@@ -12,6 +12,4 @@ ; Print typed character

terminal.input LDB PUTC ; Print new line NL - BRK - -.label end + RTS
M examples/time.xywexamples/time.xyw

@@ -3,7 +3,7 @@

; Main program print-clock JSRw set-timer JSRw -end JMPw +HLT .include "lib/putd.xyw"

@@ -49,5 +49,3 @@ RTS

.label put-zero $30 PUTC put-digit JMPw - -.label end