all repos — xyw @ 497bc63c4362c37253d20c8b479a176a60068f45

A minimal virtual machine and assembler for terminals.

Implementing system device.
h3rald h3rald@h3rald.com
Sat, 31 Jan 2026 15:21:09 +0100
commit

497bc63c4362c37253d20c8b479a176a60068f45

parent

ee2dec819ec31f6f371966de2630a0a248def377

3 files changed, 20 insertions(+), 1 deletions(-)

jump to
A devices/system.c

@@ -0,0 +1,14 @@

+#include <stdio.h> +#include "../xyw.h" + +#define SYSTEM_RANDOM 0x05 + +xyw_byte system_input(xyw_byte *data, xyw_byte addr, xyw_byte *error) +{ + if (addr == SYSTEM_RANDOM) + { + // TODO + } + (void)error; + return data[addr]; +}
A devices/system.h

@@ -0,0 +1,4 @@

+#include "../xyw.h" + +void system_output(xyw_byte *data, xyw_byte addr, xyw_byte *error); +xyw_byte system_input(xyw_byte *data, xyw_byte addr, xyw_byte *error);
M xywrun.cxywrun.c

@@ -20,7 +20,8 @@ #define SYSTEM_ERROR 0xff01

#define SYSTEM_S 0xff02 #define SYSTEM_U 0xff03 #define SYSTEM_PAGE 0xff04 -#define SYSTEM_ON_ERROR 0xff05 +#define SYSTEM_RANDOM 0xff05 +#define SYSTEM_ON_ERROR 0xff06 #ifdef _WIN32 #include <conio.h>