commit 518b7ed
zzo38
·
2026-10-21 17:45:38 +0000 UTC
parent 32a81c7
Add a few features into the assembler: named comment blocks, @ labels that start with a sublabel name setting the scope correctly, and making label names starting with / working correctly in other contexts.
1 files changed,
+6,
-1
M
uxnasm.c
M
uxnasm.c
+6,
-1
1@@ -135,6 +135,11 @@ static Label *
2 findlabel(char *name)
3 {
4 int i;
5+ char x[0x80];
6+ if(*name=='/') {
7+ snprintf(x,0x80,"%s%s",p.scope,name);
8+ name=x;
9+ }
10 for(i = 0; i < p.llen; i++)
11 if(scmp(p.labels[i].name, name, 0x40))
12 return &p.labels[i];
13@@ -473,7 +478,6 @@ parse(char *w, FILE *f)
14 if(spec_rune[*w]) goto defa;
15 switch(w[0]) {
16 case '(': /* comment */
17- if(slen(w) != 1) fprintf(stderr, "-- Malformed comment: %s\n", w);
18 i = 1; /* track nested comment depth */
19 while(fscanf(f, "%63s", word) == 1) {
20 if(slen(word) != 1)
21@@ -524,6 +528,7 @@ parse(char *w, FILE *f)
22 if(!makelabel(w + 1))
23 return error("Invalid label", w);
24 scpy(w + 1, p.scope, 0x40);
25+ for(i=0;p.scope[i];i++) if(p.scope[i]=='/') p.scope[i]=0;
26 break;
27 case '&': /* sublabel */
28 if(!makelabel(sublabel(subw, p.scope, w + 1)))