all repos — xyw @ 6e543f2563e531f1dcdc42d8b9776078e4da0576

A minimal virtual machine and assembler for terminals.

examples/cmdexec.xyw

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
.include "lib/macros.xyw"

; Set command to execute
cmd file.path STW
; Capture output to buffer
output file.read STW
$0100 file.length STW
; Execute command
file.op.exec file.operation STB
; Print OS based on output 
output linux contains JSRw print-linux JCNw
output bsd contains JSRw print-bsd JCNw
output darwin contains JSRw print-macos JCNw
output mingw contains JSRw print-windows JCNw
output windows contains JSRw print-windows JCNw
unknown puts JSRw NL
.label halt
HLT

.label print-windows
  windows puts JSRw NL
  halt JMPw

.label print-linux 
  linux puts JSRw NL
  halt JMPw

.label print-bsd 
  bsd puts JSRw NL
  halt JMPw

.label print-macos 
  macos puts JSRw NL
  halt JMPw
  
.include "lib/puts.xyw"
.include "lib/contains.xyw"

.label output
.reserve $0100
.label cmd
.string "uname -s"
.label linux
.string "Linux"
.label bsd
.string "BSD"
.label darwin
.string "Darwin"
.label mingw
.string "MinGW"
.label windows
.string "Windows"
.label macos 
.string "macOS"
.label unknown 
.string "Unknown"