From 225faa73f0647b5efae22e20456a13fc93b5d6f0 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 6 Mar 2024 08:49:16 -0800 Subject: [PATCH] (uxnasm) Stop after hitting refcount limit --- projects/examples/demos/res.rom | Bin 0 -> 1353 bytes src/uxnasm.c | 36 ++++++++++++-------------------- 2 files changed, 13 insertions(+), 23 deletions(-) create mode 100644 projects/examples/demos/res.rom diff --git a/projects/examples/demos/res.rom b/projects/examples/demos/res.rom new file mode 100644 index 0000000000000000000000000000000000000000..65445bf01bcd5d36026b4b213a9866cb2491d113 GIT binary patch literal 1353 zcmZuv&ub)A5U!rgG-GVCBb%Lh(ZO_&Lr-v{=_Q#=PiT6Q$r{*o*$u4AULPoZkS697 z<}kE{;6EUX7ZIK}ZwdxHcnSWPljl9|K~VJIf}nWI_|@y|3a-VYU;X&%`|1^K)_>#r zz&K~TI56u!vj_ie_6OYAHgquLwSl2JzdA70CXaPR8LCRI`jSM8K(RA2bZCLqfcLfY zm!UQE7$RNqbmcxVeHqlQ@vO;}M%|~j^Fpp6MEY+;rJ_&Zh-U`&@b6 zIv?=||7Kr%lAWR>#4Iu#zuq$LXbYLoeX56=IM|*4+3ApELo=VR`E)bnXk^^Im@(K& zudgf1yxP{4rCt#9C0FD3+daH5mdN?LjNG{22}02HzbN1Jo_4l7x$u6{3CL$k zfP(ZXQx`gxs}XZoxGtA~3oblommA$_{{=fky^HRy{6M|NH?F3&ouOIyRlJws z(L3TT?+h1s@e_E9FRo~+mGsdnXifEN%elAF$_>q$hJI+W9;Jr9Z}QnF-&zEpZLM4kQbzm;P=fCe{q`fA752+J%6O~gTuQ!G`@Em-~C%R z_TTj1y5sL%zwRS-`^Fo01A1awj5K9gR;Kdv9EVh@6L+eJvRp;k0mXTI{OHFM613P- zTPf9EqT?8Md<Z^CH<;EEQNv!PkAo# zUOUMP&!a+5U5OK|r-Cm87Dd2ka^y~3FD48ohX^&16_rSNNI)J(0;EbEQn-)aJ<=&D z5EOX(G|S{5j~9Y>l4B$J1p0caHRiInrc~=ANXov@meB;mMA3v?G4!G57`>Q9tf1NB z^M|w9jIxuWK%>kHOROFMHa^L>Z461#PlN|c6cZho)kB*ia6LSK3_b+ll6oRIyBFw9 ktnP&77uE%)+ofcTEr== 0x800) + if(p.refs_len >= 0x1000) return error_asm("References limit exceeded", label); r = &p.refs[p.refs_len++]; if(label[0] == '{') { @@ -372,30 +372,22 @@ parse(char *w, FILE *f) return error_asm("Invalid hex literal", w); break; case '_': /* raw byte relative */ - makereference(p.scope, w + 1, w[0], p.ptr); - return writebyte(0xff); + return writebyte(0xff) && makereference(p.scope, w + 1, w[0], p.ptr); case ',': /* literal byte relative */ - makereference(p.scope, w + 1, w[0], p.ptr + 1); - return writelitbyte(0xff); + return writelitbyte(0xff) && makereference(p.scope, w + 1, w[0], p.ptr + 1); case '-': /* raw byte absolute */ - makereference(p.scope, w + 1, w[0], p.ptr); - return writebyte(0xff); + return writebyte(0xff) && makereference(p.scope, w + 1, w[0], p.ptr); case '.': /* literal byte zero-page */ - makereference(p.scope, w + 1, w[0], p.ptr + 1); - return writelitbyte(0xff); + return writelitbyte(0xff) && makereference(p.scope, w + 1, w[0], p.ptr + 1); case ':': fprintf(stderr, "Deprecated rune %s, use =%s\n", w, w + 1); case '=': /* raw short absolute */ - makereference(p.scope, w + 1, w[0], p.ptr); - return writeshort(0xffff, 0); + return writeshort(0xffff, 0) && makereference(p.scope, w + 1, w[0], p.ptr); case ';': /* literal short absolute */ - makereference(p.scope, w + 1, w[0], p.ptr + 1); - return writeshort(0xffff, 1); + return writeshort(0xffff, 1) && makereference(p.scope, w + 1, w[0], p.ptr + 1); case '?': /* JCI */ - makereference(p.scope, w + 1, w[0], p.ptr + 1); - return writebyte(0x20) && writeshort(0xffff, 0); + return writebyte(0x20) && writeshort(0xffff, 0) && makereference(p.scope, w + 1, w[0], p.ptr + 1); case '!': /* JMI */ - makereference(p.scope, w + 1, w[0], p.ptr + 1); - return writebyte(0x40) && writeshort(0xffff, 0); + return writebyte(0x40) && writeshort(0xffff, 0) && makereference(p.scope, w + 1, w[0], p.ptr + 1); case '"': /* raw string */ i = 0; while((c = w[++i])) @@ -424,10 +416,8 @@ parse(char *w, FILE *f) if(!parse(m->items[i], f)) return 0; return 1; - } else { - makereference(p.scope, w, ' ', p.ptr + 1); - return writebyte(0x60) && writeshort(0xffff, 0); - } + } else + return writebyte(0x60) && writeshort(0xffff, 0) && makereference(p.scope, w, ' ', p.ptr + 1); } return 1; } @@ -538,7 +528,7 @@ main(int argc, char *argv[]) if(argc == 1) return error_top("usage", "uxnasm [-v] input.tal output.rom"); if(argv[1][0] == '-' && argv[1][1] == 'v') - return !fprintf(stdout, "Uxnasm - Uxntal Assembler, 3 Mar 2024.\n"); + return !fprintf(stdout, "Uxnasm - Uxntal Assembler, 6 Mar 2024.\n"); if(!(src = fopen(setlocation(argv[1]), "r"))) return !error_top("Invalid input", argv[1]); p.entry = argv[1];