all repos — xyw @ 8e8d91d36f3689745d535f61f3dc52c025bd719d

A minimal virtual machine and assembler for terminals.

Added oneof, length, lengthw subroutines; added .reserve to vim
syntax.
h3rald h3rald@h3rald.com
Fri, 14 Aug 2026 03:24:11 +0000
commit

8e8d91d36f3689745d535f61f3dc52c025bd719d

parent

b993d56d0cf0068dd3c0721833e48e1f165eed85

4 files changed, 48 insertions(+), 1 deletions(-)

jump to
A examples/lib/length.xyw

@@ -0,0 +1,16 @@

+; .include "lib/macros.xyw" + +; returns the length of a string (max: 255) +; a16 -[xxw]- a8 +.label length + POPxw ; store start address + $00 POPx ; counter + .label length.loop + ; if at end of string, go to end + LDBxw $00 EQU length.end JCNw + ; otherwise increment address and counter + INCxw + INCx + length.loop JMPw + .label length.end + PSHx RTS
A examples/lib/lengthw.xyw

@@ -0,0 +1,13 @@

+; returns the length of a string (max: 255) +; a16 -[xwyw]- b16 +.label lengthw + POPxw ; store start address + $0000 POPyw ; counter + .label lengthw.loop + ; if at end of string, go to end + LDBxw $00 EQU lengthw.end JCNw + ; otherwise increment address and counter + INCxyw + lengthw.loop JMPw + .label lengthw.end + PSHyw RTS
A examples/lib/oneof.xyw

@@ -0,0 +1,18 @@

+; .include "lib/macros.xyw" + +; Checks if char a16 is one of chars in b16 (string) +; a16 b16 -[xwyw]- a8 +.label oneof + POPyw + POPxw + .label oneof.loop + ; if at end of string, then no char is matching + LDByw $00 EQU oneof.fail JCNw + ; if char matches, ok + LDBxyw EQU oneof.ok JCNw + INCyw oneof.loop JMPw + .label oneof.fail + $00 RTS + .label oneof.ok + $01 RTS +
M xyw.vimxyw.vim

@@ -11,7 +11,7 @@ " Comments

syntax match xywComment ";.*$" " Directives -syntax match xywDirective "\.\(include\|label\|macro\|string\|byte\)\>" +syntax match xywDirective "\.\(include\|label\|macro\|string\|byte\|reserve\)\>" " Label definitions (name after .label) syntax match xywLabelDef "\(\.label\s\+\)\@<=[a-zA-Z_][a-zA-Z0-9_.\-]*"