all repos — xyw @ 9c362232dc125ebcfd7e1badd0421e89b2e6092b

A minimal virtual machine and assembler for terminals.

Minor doc improvements.
h3rald h3rald@h3rald.com
Wed, 11 Feb 2026 17:15:21 +0100
commit

9c362232dc125ebcfd7e1badd0421e89b2e6092b

parent

79672637f5164782bdacb12a66370fe1a211ff58

M examples/factorial16.xywexamples/factorial16.xyw

@@ -7,7 +7,7 @@ NL

end JMPw ; Factorial subroutine -; a16 -- | [xy] +; a16 -[xy]- .label fact ; Save argument to both registers POPxyw
M examples/factorial8.xywexamples/factorial8.xyw

@@ -7,7 +7,7 @@ NL

end JMPw ; Factorial subroutine -; a8 -- | [xy] +; a8 -[xy]- .label fact ; Save argument to both registers POPxy
M examples/korobeiniki.xywexamples/korobeiniki.xyw

@@ -1,7 +1,7 @@

-.include "lib/macros.xyw" - ;;; Korobeiniki - Traditional Russian folk song -;;; Main melody - "Type A" Tetris Theme +;;; Main melody - "Type A" (Tetris Theme) + +.include "lib/macros.xyw" ; note duration macros .macro n2 $00C0 ; half note
M examples/lib/macros.xywexamples/lib/macros.xyw

@@ -10,10 +10,10 @@ .macro system.random $05

.macro system.on_error $06 ;terminal -.macro terminal.input $10 -.macro terminal.output $11 -.macro terminal.on_keypress $12 -.macro terminal.on_argument $14 +.macro terminal.input $10 +.macro terminal.output $11 +.macro terminal.on_keypress $12 +.macro terminal.on_argument $14 ;clock .macro clock.year $20

@@ -44,10 +44,11 @@

;;; Utilities .macro MOD DIV POP .macro LBYTE SWP POP -.macro PUTC $11 STB +.macro PUTC terminal.output STB ;;; ASCII Characters .macro NL $0A PUTC +.macro CR $0D PUTC .macro SP $20 PUTC ;;; Argument separators

@@ -55,14 +56,14 @@ .macro arg.sep $1E

.macro arg.end $1D ;;; Errors -.macro error.file.not_found $31 +.macro error.file.not_found $31 .macro error.file.access_denied $32 -.macro error.file.invalid_op $33 -.macro error.file.io_error $34 +.macro error.file.invalid_op $33 +.macro error.file.io_error $34 ;;; File operations -.macro file.op.read $01 -.macro file.op.write $02 +.macro file.op.read $01 +.macro file.op.write $02 .macro file.op.append $03 .macro file.op.delete $04
M examples/lib/putd.xywexamples/lib/putd.xyw

@@ -1,7 +1,7 @@

; .include "lib/macros.xyw" ; Print an 8bit integer as decimal -; a8 -- | [x] +; a8 -[x]- .label putd POPx ; If value is less than 10, print single digit
M examples/lib/putdw.xywexamples/lib/putdw.xyw

@@ -1,7 +1,7 @@

; .include "lib/macros.xyw" ; Print a 16bit integer as decimal -; a16 -- | [x] +; a16 -[x]- .label putdw POPxw ; If value is less than 10, print single digit
M examples/lib/puts.xywexamples/lib/puts.xyw

@@ -1,7 +1,7 @@

; .include "lib/macros.xyw" ; Print a string starting at address -; a16 -- | [xw] +; a16 -[xw]- .label puts POPxw .label puts.loop
M examples/on-error.xywexamples/on-error.xyw

@@ -8,6 +8,7 @@ $10 $00 DIV

end JMPw ; on error handler +; -- .label on_error system.error LDB $01 EQU on_error.div-by-zero.print JCNw unknown-error puts JSRw
M examples/print-args.xywexamples/print-args.xyw

@@ -6,6 +6,7 @@ ; End program

end JMPw ; on_argument event handler +; -[x]- .label print-args terminal.input POPx ; If end of argument, print new line and end

@@ -13,15 +14,18 @@ LDBx arg.end EQU print-args.end JCNw

LDBx arg.sep EQU print-args.next JCNw ; Print typed character LDBx PUTC + CLRx RTS ; Print argument separator (, ) .label print-args.next $2C PUTC SP + CLRx RTS ; Print new line .label print-args.end NL + CLRx RTS .label end
M examples/print-stdin.xywexamples/print-stdin.xyw

@@ -7,6 +7,7 @@ ; End program

end JMPw ; on_keypress event handler +; -- .label print-key ; Print typed character terminal.input LDB PUTC
M examples/time.xywexamples/time.xyw

@@ -1,7 +1,5 @@

.include "lib/macros.xyw" -.macro CR $0D PUTC - ; Main program print-clock JSRw set-timer JSRw

@@ -42,11 +40,12 @@ ZEROPADx JSRw

RTS ; Print an 8bit integer as decimal, with leading zero if less than 10 -; a8 -- | [x] +; a8 -[x]- .label ZEROPADx POPx PSHx $0A LTH put-zero JCNw .label put-digit PSHx putd JSRw + CLRx RTS .label put-zero $30 PUTC