all repos — xyw @ 8aaa333e3496dd357da4457bdb2f781ae1a685c6

A minimal virtual machine and assembler for terminals.

Added osdetect subroutine.
h3rald h3rald@h3rald.com
Mon, 10 Aug 2026 04:42:42 +0000
commit

8aaa333e3496dd357da4457bdb2f781ae1a685c6

parent

ff2041e3ed78ca47d3fd347c8b65e7927e1c6bd1

1 files changed, 58 insertions(+), 0 deletions(-)

jump to
A examples/lib/osdetect.xyw

@@ -0,0 +1,58 @@

+; UNTESTED +; .include "lib/macros.xyw" +; .include "lib/lowcase.xyw" +; .include "lib/contains.xyw" + +; Pushes address to OS identifier +; -- a16 +.label osdetect + ; Set command to execute + osdetect.cmd file.path STW + ; Capture output to buffer + osdetect.output file.read STW + $0040 file.length STW + ; Execute command + file.op.exec file.operation STB + ; Convert to lowercase + osdetect.output lowcase JSRw + ; Write OS identifier to address + osdetect.output osdetect.linux contains JSRw + osdetect.res.linux JCNw + osdetect.output osdetect.mingw contains JSRw + osdetect.res.windows JCNw + osdetect.output osdetect.windows contains JSRw + osdetect.res.windows JCNw + osdetect.output osdetect.darwin contains JSRw + osdetect.res.macos JCNw + osdetect.output osdetect.bsd contains JSRw + osdetect.res.bsd JCNw + ; Unknown OS + osdetect.unknown RTS + ; results + .label osdetect.res.linux + osdetect.linux RTS + .label osdetect.res.windows + osdetect.windows RTS + .label osdetect.res.macos + osdetect.macos RTS + .label osdetect.res.bsd + osdetect.bsd RTS + ; strings + .label osdetect.output + .reserve $0040 + .label osdetect.cmd + .string "uname -s" + .label osdetect.linux + .string "linux" + .label osdetect.bsd + .string "bsd" + .label osdetect.darwin + .string "darwin" + .label osdetect.mingw + .string "mingw" + .label osdetect.windows + .string "windows" + .label osdetect.macos + .string "macos" + .label osdetect.unknown + .string "unknown"