From 66de46b3525d1bb611e3ac587331a5f14846d7c9 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Mon, 2 Jan 2023 14:15:54 -0800 Subject: [PATCH] (uxnasm)Added support for JMI, JCI and JSI --- etc/polycat.tal | 16 ++++++++-------- src/uxn11.c | 2 +- src/uxnasm.c | 19 ++++++++++++++----- src/uxncli.c | 2 +- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/etc/polycat.tal b/etc/polycat.tal index 354ed12..e4d8152 100644 --- a/etc/polycat.tal +++ b/etc/polycat.tal @@ -36,7 +36,7 @@ #ff ;draw-tail/last STA ( set screen mode auto-x ) #05 .Screen/auto DEO - ,draw-polycat JSR + draw-polycat BRK @@ -53,8 +53,8 @@ BRK ;body .Screen/addr DEO2 #81 .Screen/sprite DEO ( eye/tail ) - #00 ,draw-eye JSR - #00 ,draw-tail JSR + #00 draw-eye + #00 draw-tail JMP2r @@ -62,16 +62,16 @@ JMP2r .Mouse/x DEI2 .cat/x LDZ2 GTH2 #50 SFT .Mouse/y DEI2 .cat/y LDZ2 GTH2 #60 SFT - ADD ,draw-eye JSR + ADD draw-eye .cat/timer LDZ INC [ DUP ] .cat/timer STZ - #04 SFT ,draw-tail JSR - ,draw-cursor JSR + #04 SFT draw-tail + draw-cursor BRK @draw-eye ( quad -- ) - DUP ,&last LDR NEQ ,&changed JCN + DUP ,&last LDR NEQ ?&changed POP JMP2r &changed ( only redraw on change ) DUP @@ -86,7 +86,7 @@ JMP2r @draw-tail ( frame -- ) - STHk ,&last LDR NEQ ,&changed JCN + STHk ,&last LDR NEQ ?&changed POPr JMP2r &changed ( only redraw on change ) STHr #00 OVR ;frames ADD2 LDA diff --git a/src/uxn11.c b/src/uxn11.c index b1754ef..a137766 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -57,7 +57,7 @@ static void console_deo(Uint8 *d, Uint8 port) { FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr : - 0; + 0; if(fd) { fputc(d[port], fd); fflush(fd); diff --git a/src/uxnasm.c b/src/uxnasm.c index a3e901a..4fac642 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -328,6 +328,14 @@ parse(char *w, FILE *f) makereference(p.scope, w, p.ptr); if(!writeshort(0xffff, 1)) return 0; break; + case '!': /* JMI */ + makereference(p.scope, w, p.ptr); + if(!writebyte(0x20) || !writeshort(0xffff, 0)) return 0; + break; + case '?': /* JCI */ + makereference(p.scope, w, p.ptr); + if(!writebyte(0x40) || !writeshort(0xffff, 0)) return 0; + break; case '"': /* raw string */ i = 0; while((c = w[++i])) @@ -355,8 +363,11 @@ parse(char *w, FILE *f) if(!parse(m->items[i], f)) return 0; return 1; - } else - return error("Unknown token", w); + } else { + makereference(p.scope, w - 1, p.ptr); + if(!writebyte(0x60) || !writeshort(0xffff, 0)) + return 0; + } } return 1; } @@ -405,15 +416,13 @@ resolve(void) p.data[r->addr + 1] = l->addr & 0xff; l->refs++; break; - case ';': + default: if(!(l = findlabel(r->name))) return error("Unknown absolute reference", r->name); p.data[r->addr + 1] = l->addr >> 0x8; p.data[r->addr + 2] = l->addr & 0xff; l->refs++; break; - default: - return error("Unknown reference", r->name); } } return 1; diff --git a/src/uxncli.c b/src/uxncli.c index 07274f0..4a4538c 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -38,7 +38,7 @@ static void console_deo(Uint8 *d, Uint8 port) { FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr : - 0; + 0; if(fd) { fputc(d[port], fd); fflush(fd);