commit 00ed056e512c7fa1b07ded3ed57974f033f4891c
parent edfa734817607c40f2d05c07081ff82b66d122f3
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date: Tue, 4 Apr 2023 20:02:33 -0700
(uxnasm) Added support for label sized pads
Diffstat:
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/uxnasm.c b/src/uxnasm.c
@@ -253,6 +253,7 @@ parse(char *w, FILE *f)
{
int i;
char word[0x40], subw[0x40], c;
+ Label *l;
Macro *m;
if(slen(w) >= 63)
return error("Invalid token", w);
@@ -278,14 +279,30 @@ parse(char *w, FILE *f)
return error("Invalid macro", w);
break;
case '|': /* pad-absolute */
- if(!sihx(w + 1))
- return error("Invalid padding", w);
- p.ptr = shex(w + 1);
+ if(sihx(w + 1))
+ p.ptr = shex(w + 1);
+ else if(w[1] == '&') {
+ if(!sublabel(subw, p.scope, w + 2) || !(l = findlabel(subw)))
+ return error("Invalid sublabel", w);
+ p.ptr = l->addr;
+ } else {
+ if(!(l = findlabel(w + 1)))
+ return error("Invalid label", w);
+ p.ptr = l->addr;
+ }
break;
case '$': /* pad-relative */
- if(!sihx(w + 1))
- return error("Invalid padding", w);
- p.ptr += shex(w + 1);
+ if(sihx(w + 1))
+ p.ptr += shex(w + 1);
+ else if(w[1] == '&') {
+ if(!sublabel(subw, p.scope, w + 2) || !(l = findlabel(subw)))
+ return error("Invalid sublabel", w);
+ p.ptr += l->addr;
+ } else {
+ if(!(l = findlabel(w + 1)))
+ return error("Invalid label", w);
+ p.ptr += l->addr;
+ }
break;
case '@': /* label */
if(!makelabel(w + 1))