commit 50838e3
zzo38
·
2023-04-06 17:43:49 +0000 UTC
parent b79d6d3
Add label-sized padding.
M
asm.doc
+8,
-6
1@@ -39,12 +39,14 @@ The following standard tokens are available:
2 The name of a previously defined macro without % in front will call that
3 macro, as though its definition is substituted in its place.
4
5- | and a number will set the current address to that number. Any address
6- is possible, but you cannot assemble anything in the zero page nor can
7- anything be assembled out of order, although you can skip any space.
8-
9- $ and a number will advance the address by that number. (The padding will
10- be all zeros if not filled in.)
11+ | and a number or label name will set the current address to that number
12+ (or to the address of that label). Any address is possible, but you cannot
13+ assemble anything in the zero page nor can anything be assembled out of
14+ order, although you can skip any space.
15+
16+ $ and a number or label name will advance the address by that number (or
17+ by the address of that label). (The padding will be all zeros if not
18+ filled in.)
19
20 @ and a name will make a label with that name. If the label name starts
21 with a uppercase letter, then warnings about that label being unused are
M
uxnasm.c
+22,
-6
1@@ -389,14 +389,30 @@ parse(char *w, FILE *f)
2 return error("Invalid macro", w);
3 break;
4 case '|': /* pad-absolute */
5- if(!sihx(w + 1))
6- return error("Invalid padding", w);
7- p.ptr = shex(w + 1);
8+ if(sihx(w + 1))
9+ p.ptr = shex(w + 1);
10+ else if(w[1] == '&') {
11+ if(!sublabel(subw, p.scope, w + 2) || !(l = findlabel(subw)))
12+ return error("Invalid padding", w);
13+ p.ptr = l->addr;
14+ } else {
15+ if(!(l = findlabel(w + 1)))
16+ return error("Invalid padding", w);
17+ p.ptr = l->addr;
18+ }
19 break;
20 case '$': /* pad-relative */
21- if(!sihx(w + 1))
22- return error("Invalid padding", w);
23- p.ptr += shex(w + 1);
24+ if(sihx(w + 1))
25+ p.ptr += shex(w + 1);
26+ else if(w[1] == '&') {
27+ if(!sublabel(subw, p.scope, w + 2) || !(l = findlabel(subw)))
28+ return error("Invalid padding", w);
29+ p.ptr += l->addr;
30+ } else {
31+ if(!(l = findlabel(w + 1)))
32+ return error("Invalid padding", w);
33+ p.ptr += l->addr;
34+ }
35 break;
36 case '@': /* label */
37 if(!makelabel(w + 1))