all repos — xyw @ 2556c0a4be125638f5839fa7cb990a0b13e1405c

A minimal virtual machine and assembler for terminals.

Fixed d6.xyw, updated DIV operation to return modulo as well.
h3rald h3rald@h3rald.com
Fri, 30 Jan 2026 15:03:18 +0100
commit

2556c0a4be125638f5839fa7cb990a0b13e1405c

parent

79f1e633e660d676ed207bf5b80e2377db82b144

2 files changed, 5 insertions(+), 11 deletions(-)

jump to
M examples/d6.xywexamples/d6.xyw

@@ -1,18 +1,12 @@

.include "devices.xyw" ; Get random number and calculate modulo 6 -clock.random LDBw $6 modulo JSRw +clock.random LDB $6 DIV POP ; Print result+1 and new line -$31 ADD terminal.output STBw -$0d terminal.output STBw +$31 ADD terminal.output STB +$0A terminal.output STB ; Terminate -$0 system.state STBw +$0 system.state STB -; Calculate the modulo -; a b -- a%b -.label modulo - POPy POPx - PSHx PSHy PSHx PSHy DIV MUL SUB - RTS
M xywrun.cxywrun.c

@@ -295,7 +295,7 @@ /* SHR */ OPC_SR1(0x0B, xyw_byte b = us_pop(), PUSH(ARG >> b));

/* ADD */ OPC_SR2(0x0C, PUSH(a + b)); /* SUB */ OPC_SR2(0x0D, PUSH(a - b)); /* MUL */ OPC_SR2(0x0E, PUSH(a * b)); - /* DIV */ OPC_SR2(0x0F, PUSH(a / b)); + /* DIV */ OPC_SR2(0x0F, PUSH(a % b); PUSH(a / b)); /* EQU */ OPC_SR2(0x10, PUSH(a == b)); /* NEQ */ OPC_SR2(0x11, PUSH(a != b)); /* GTH */ OPC_SR2(0x12, PUSH(a > b));