uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 2b80b85bafd5aa586ca41350198587038c44f5d2
parent 51c6e90754d6889b22f00cb62c2fb4e41d45a050
Author: neauoire <aliceffekt@gmail.com>
Date:   Sat, 25 Sep 2021 09:39:27 -0700

Relative labels should not incr references to parent label

Diffstat:
Msrc/uxnasm.c | 22++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/uxnasm.c b/src/uxnasm.c @@ -185,13 +185,15 @@ makelabel(char *name) } static int -addref(Label *l) +addref(Label *l, Uint8 rel) { - int pos = cpos(l->name, '/'); - if(pos != -1) { - char root[64]; - Label *rl = findlabel(scpy(l->name, root, pos)); - ++rl->refs; + if(rel) { + int pos = cpos(l->name, '/'); + if(pos != -1) { + char root[64]; + Label *rl = findlabel(scpy(l->name, root, pos)); + ++rl->refs; + } } return ++l->refs; } @@ -244,19 +246,19 @@ parsetoken(char *w) if(l->addr > 0xff) return error("Address is not in zero page", w); pushbyte(l->addr, 1); - return addref(l); + return addref(l, 1); } else if(w[0] == ',' && (l = findlabel(w + 1))) { /* relative */ int off = l->addr - p.ptr - 3; if(off < -126 || off > 126) return error("Address is too far", w); pushbyte((Sint8)off, 1); - return addref(l); + return addref(l, 0); } else if(w[0] == ':' && (l = findlabel(w + 1))) { /* raw */ pushshort(l->addr, 0); - return addref(l); + return addref(l, 1); } else if(w[0] == ';' && (l = findlabel(w + 1))) { /* absolute */ pushshort(l->addr, 1); - return addref(l); + return addref(l, 1); } else if(findopcode(w) || scmp(w, "BRK", 4)) { /* opcode */ pushbyte(findopcode(w), 0); return 1;