all repos — xyw @ 4c18249841b2776d6c6f9b736161acfef350b65c

A minimal virtual machine and assembler for terminals.

Replaced CLR and SET with HLT and NOP.
h3rald h3rald@h3rald.com
Fri, 27 Feb 2026 07:02:58 +0100
commit

4c18249841b2776d6c6f9b736161acfef350b65c

parent

0871170c5656a4e8890a8779e8bb6b17b09896c2

4 files changed, 5 insertions(+), 7 deletions(-)

jump to
M xyw-vscode/syntaxes/xyw.tmLanguage.jsonxyw-vscode/syntaxes/xyw.tmLanguage.json

@@ -140,7 +140,7 @@ }

}, { "comment": "All other instructions with optional xyw modifiers", - "match": "\\b(PSH|POP|CLR|SET|LDB|LDW|STB|STW|INC|DEC|SHL|SHR|ADD|SUB|MUL|DIV|EQU|NEQ|GTH|LTH|AND|IOR|XOR|NOT|SWP|DUP)([xyw]*)\\b", + "match": "\\b(PSH|POP|HLT|NOP|LDB|LDW|STB|STW|INC|DEC|SHL|SHR|ADD|SUB|MUL|DIV|EQU|NEQ|GTH|LTH|AND|IOR|XOR|NOT|SWP|DUP)([xyw]*)\\b", "captures": { "1": { "name": "variable.other.instruction.xyw"
M xyw.cxyw.c

@@ -9,7 +9,7 @@ int xyw_argc = 0;

// Instruction mnemonics definition const char xyw_instructions[][4] = { - "CLR", "SET", "PSH", "POP", + "HLT", "NOP", "PSH", "POP", "LDB", "LDW", "STB", "STW", "INC", "DEC", "SHL", "SHR", "ADD", "SUB", "MUL", "DIV",
M xyw.vimxyw.vim

@@ -43,7 +43,7 @@ " Instructions - JMP, JCN, JSR support x or y (not both) and w

syntax match xywInstruction "\<\(JMP\|JCN\|JSR\)\([xy]\?w\?\)\>" " Instructions - All other instructions with optional xyw modifiers -syntax match xywInstruction "\<\(PSH\|POP\|CLR\|SET\|LDB\|LDW\|STB\|STW\|INC\|DEC\|SHL\|SHR\|ADD\|SUB\|MUL\|DIV\|EQU\|NEQ\|GTH\|LTH\|AND\|IOR\|XOR\|NOT\|SWP\|DUP\)\([xyw]*\)\>" +syntax match xywInstruction "\<\(PSH\|POP\|HLT\|NOP\|LDB\|LDW\|STB\|STW\|INC\|DEC\|SHL\|SHR\|ADD\|SUB\|MUL\|DIV\|EQU\|NEQ\|GTH\|LTH\|AND\|IOR\|XOR\|NOT\|SWP\|DUP\)\([xyw]*\)\>" " Define highlight groups highlight default link xywComment Comment
M xywrun.cxywrun.c

@@ -417,10 +417,8 @@ XYW_DBG(" -- PC: %04X -> %02X (%s) [U:%02X|S:%02X|X:%02X|Y:%02X|XW:%04X|YW:%04X]\n", *pc, xyw_memory[*pc], xyw_instructions[xyw_memory[*pc] & 0x1F], *u, *s, *x, *y, *xw, *yw);

switch (xyw_memory[*pc]) { // clang-format off - /* CLR */ OPC_SR1(0x00, , if (rx||ry) { SET(0); } else { *x = saved_x; *y = saved_y; *xw = saved_xw; *yw = saved_yw; return 0; }); - /* CLR */ OPC_SR1r(0x00, if (w) { *xw = 0; *yw = 0; } else { *x = 0; *y = 0; } ); - /* SET */ OPC_SR1(0x01, , if (w) { SET(0xFFFF); } else { SET(0xFF); }); - /* SET */ OPC_SR1r(0x01, if (w) { *xw = 0xFFFF; *yw = 0xFFFF; } else { *x = 0xFF; *y = 0xFF; } ); + /* HLT */ case 0x00: return 0; + /* NOP */ case 0x01: break; /* PSH */ OPC_SR1(0x02, , if (rx||ry) { PUSH(ARG); } else { (*pc)++; PUSH(READ(*pc)); if (w) { (*pc)++; } }) /* PSH */ OPC_SR1r(0x02, PUSH(a); PUSH(b); ) /* POP */ OPC_SR1(0x03, , if (rx||ry) { SET(POP()); } else { POP(); } );