all repos — xyw @ eef2d4ae11690a014987ad0cd1b4240ecabd4ec5

A minimal virtual machine and assembler for terminals.

Fixes + added some macros.
h3rald h3rald@h3rald.com
Mon, 02 Feb 2026 14:16:54 +0100
commit

eef2d4ae11690a014987ad0cd1b4240ecabd4ec5

parent

1b9c6625a9cdd0854290b3ea922279a1991fbe94

3 files changed, 13 insertions(+), 2 deletions(-)

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

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

#include <time.h> #include <stdlib.h> +#include <stdio.h> #include "../xyw.h" #define SYSTEM_STATE 0x00
M examples/helloworld.xywexamples/helloworld.xyw

@@ -3,6 +3,7 @@ .include "devices.xyw"

; main program hello print JSRw +end JMPw ; a16 -- ; printing subroutine

@@ -20,3 +21,4 @@

; store null-terminated string .label hello .string "Hello, World!\n" +.label end
M xywrun.cxywrun.c

@@ -248,17 +248,25 @@ #define ADDR(ad) w ? ad : (DIRECT_PAGE | ad)

// Push a value to stack #define PUSH(n) do { if (w) { us_pushw(n); } else { us_push(n); } } while(0) // Pop value from stack -#define POP() (w ? us_popw() : (xyw_word)us_pop()) +#define POP() (w ? us_popw() : us_pop()) +// Get argument from x register or stack +#define ARGX (rx ? (w ? *xw : *x) : (w ? us_popw() : us_pop())) +// Get argument from y register or stack +#define ARGY (ry ? (w ? *yw : *y) : (w ? us_popw() : us_pop())) // Get argument from x or y register or stack -#define ARG (rx ? (w ? *xw : *x) : (ry ? (w ? *yw : *y) : (w ? us_popw() : us_pop()))) +#define ARG (rx ? ARGX : (ry ? ARGY : POP())) +//#define ARG (rx ? (w ? *xw : *x) : (ry ? (w ? *yw : *y) : (w ? us_popw() : us_pop()))) // Set value to x register or push to stack #define SETX(v) rx ? (w ? (*xw = v) : (*x = v)) : (w ? us_pushw(v) : us_push(v)) // Set value to y register or push to stack #define SETY(v) ry ? (w ? (*yw = v) : (*y = v)) : (w ? us_pushw(v) : us_push(v)) // Set value to x or y register or push to stack #define SET(v) do { if (rx) { SETX(v); } else if (ry) { SETY(v); } else { PUSH(v); } } while(0) + // Read a value from memory #define READ(addr) (w ? readw(addr) : read(addr)) +// Read top of the user stack +#define TOP READ(USER_STACK_START + (*u) - (w ? 2 : 1)) //// Initialize devices