all repos — xyw @ d6a026e82655345ce070fe1c747828d33c74ea23

A minimal virtual machine and assembler for terminals.

Updated macros; minor fixes.
h3rald h3rald@h3rald.com
Thu, 30 Jul 2026 10:13:00 +0200
commit

d6a026e82655345ce070fe1c747828d33c74ea23

parent

b67253f6f73d3ba7adbc04f5798fff54c4af0a1c

3 files changed, 38 insertions(+), 26 deletions(-)

jump to
M devices/beeper.cdevices/beeper.c

@@ -34,10 +34,11 @@ * Build requirements (see Makefile):

* Windows -> nothing extra (winmm is linked via #pragma comment; * MinGW users should add -lwinmm) * macOS -> -framework AudioToolbox -framework CoreFoundation - * Linux -> -lasound, if the ALSA headers are available at compile + * Linux or BSD -> -lasound, if the ALSA headers are available at compile * time (see XYW_HAVE_ALSA below); otherwise falls back * to the OSS backend, same as *BSD - * *BSD/other -> nothing extra (uses /dev/dsp) + * If no audio backend is available, using the beeper will trigger a + * BEEPER_ERROR_DEVICE error. */ static void beep_play_tone(double frequency_hz, unsigned long duration_ms, double volume, xyw_byte *error);
M devices/file.cdevices/file.c

@@ -233,7 +233,7 @@ #else

DIR *dir = opendir(path); struct dirent *entry; struct stat st; - char full_path[FILE_MAX_PATH + 256 + 2]; + char full_path[FILE_MAX_PATH * 2 + 2]; if (!dir) {
M examples/lib/macros.xywexamples/lib/macros.xyw

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

;;; Devices -;system +; system .macro system.state $00 .macro system.error $01 .macro system.page $02

@@ -8,13 +8,13 @@ .macro system.random $03

.macro system.on_error $04 .macro system.image_exec $06 -;terminal +; terminal .macro terminal.input $10 .macro terminal.output $11 .macro terminal.on_keypress $12 .macro terminal.on_argument $14 -;clock +; clock .macro clock.year $20 .macro clock.month $22 .macro clock.monthday $23

@@ -25,7 +25,7 @@ .macro clock.second $27

.macro clock.timer $28 .macro clock.on_timer $2A -;file +; file .macro file.path $30 .macro file.type $32 .macro file.size $33

@@ -35,7 +35,7 @@ .macro file.read $39

.macro file.write $3B .macro file.operation $3D -;beeper +; beeper .macro beeper.pitch $40 .macro beeper.length $42 .macro beeper.level $44

@@ -56,35 +56,46 @@ .macro arg.end $1D

;;; Errors -;system -.macro error.system.division_by_zero $01 -.macro error.system.stack_underflow $02 -.macro error.system.stack_overflow $03 -.macro error.system.exec_depth $04 -.macro error.system.image_not_found $05 -.macro error.system.image_read_error $06 +; system +.macro error.system.division_by_zero $01 +.macro error.system.user_stack_overflow $02 +.macro error.system.user_stack_underflow $03 +.macro error.system.system_stack_overflow $04 +.macro error.system.system_stack_underflow $05 +.macro error.execution_depth_exceeded $06 +.macro error.system.image_not_found $07 +.macro error.system.image_read_error $08 +.macro error.system.image_too_large $09 +.macro error.system.invalid_opcode $0A + +; terminal +.macro error.terminal_not_tty $11 -;file -.macro error.file.not_found $31 -.macro error.file.access_denied $32 -.macro error.file.invalid_op $33 -.macro error.file.io_error $34 +; file +.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.path_too_long $35 +.macro error.file.buffer_out_of_range $36 -;beeper -.macro error.beeper.device $41 -.macro error.beeper.memory $42 -.macro error.beeper.playback $43 +; beeper +.macro error.beeper.device $41 +.macro error.beeper.memory $42 +.macro error.beeper.playback $43 ;;; File operations .macro file.op.read $01 .macro file.op.write $02 .macro file.op.append $03 .macro file.op.delete $04 +.macro file.op.copy $05 +.macro file.op.move $06 ;;; File types .macro file.type.unspecified $00 -.macro file.type.file $01 -.macro file.type.directory $02 +.macro file.type.file $01 +.macro file.type.directory $02 ;;; Beeper notes .macro ps $0000 ; pause (no sound)