mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-30 17:53:01 +00:00
Relative labels should not incr references to parent label
This commit is contained in:
parent
51c6e90754
commit
2b80b85baf
1 changed files with 12 additions and 10 deletions
22
src/uxnasm.c
22
src/uxnasm.c
|
@ -185,13 +185,15 @@ makelabel(char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
addref(Label *l)
|
addref(Label *l, Uint8 rel)
|
||||||
{
|
{
|
||||||
int pos = cpos(l->name, '/');
|
if(rel) {
|
||||||
if(pos != -1) {
|
int pos = cpos(l->name, '/');
|
||||||
char root[64];
|
if(pos != -1) {
|
||||||
Label *rl = findlabel(scpy(l->name, root, pos));
|
char root[64];
|
||||||
++rl->refs;
|
Label *rl = findlabel(scpy(l->name, root, pos));
|
||||||
|
++rl->refs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ++l->refs;
|
return ++l->refs;
|
||||||
}
|
}
|
||||||
|
@ -244,19 +246,19 @@ parsetoken(char *w)
|
||||||
if(l->addr > 0xff)
|
if(l->addr > 0xff)
|
||||||
return error("Address is not in zero page", w);
|
return error("Address is not in zero page", w);
|
||||||
pushbyte(l->addr, 1);
|
pushbyte(l->addr, 1);
|
||||||
return addref(l);
|
return addref(l, 1);
|
||||||
} else if(w[0] == ',' && (l = findlabel(w + 1))) { /* relative */
|
} else if(w[0] == ',' && (l = findlabel(w + 1))) { /* relative */
|
||||||
int off = l->addr - p.ptr - 3;
|
int off = l->addr - p.ptr - 3;
|
||||||
if(off < -126 || off > 126)
|
if(off < -126 || off > 126)
|
||||||
return error("Address is too far", w);
|
return error("Address is too far", w);
|
||||||
pushbyte((Sint8)off, 1);
|
pushbyte((Sint8)off, 1);
|
||||||
return addref(l);
|
return addref(l, 0);
|
||||||
} else if(w[0] == ':' && (l = findlabel(w + 1))) { /* raw */
|
} else if(w[0] == ':' && (l = findlabel(w + 1))) { /* raw */
|
||||||
pushshort(l->addr, 0);
|
pushshort(l->addr, 0);
|
||||||
return addref(l);
|
return addref(l, 1);
|
||||||
} else if(w[0] == ';' && (l = findlabel(w + 1))) { /* absolute */
|
} else if(w[0] == ';' && (l = findlabel(w + 1))) { /* absolute */
|
||||||
pushshort(l->addr, 1);
|
pushshort(l->addr, 1);
|
||||||
return addref(l);
|
return addref(l, 1);
|
||||||
} else if(findopcode(w) || scmp(w, "BRK", 4)) { /* opcode */
|
} else if(findopcode(w) || scmp(w, "BRK", 4)) { /* opcode */
|
||||||
pushbyte(findopcode(w), 0);
|
pushbyte(findopcode(w), 0);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue