Browse code

Fixed addr being reset in include's pass1

Andrew Alderwick authored on 28/08/2021 06:51:48
Showing 1 changed files
... ...
@@ -36,6 +36,7 @@ typedef struct {
36 36
 } Program;
37 37
 
38 38
 Program p;
39
+static Uint16 addr = 0;
39 40
 
40 41
 /* clang-format off */
41 42
 
... ...
@@ -170,7 +171,7 @@ makemacro(char *name, FILE *f)
170 171
 }
171 172
 
172 173
 static int
173
-makelabel(char *name, Uint16 addr)
174
+makelabel(char *name)
174 175
 {
175 176
 	Label *l;
176 177
 	if(findlabel(name))
... ...
@@ -303,7 +304,6 @@ static int
303 304
 pass1(FILE *f)
304 305
 {
305 306
 	int ccmnt = 0;
306
-	Uint16 addr = 0;
307 307
 	char w[64], scope[64], subw[64];
308 308
 	while(fscanf(f, "%63s", w) == 1) {
309 309
 		if(skipblock(w, &ccmnt, '(', ')')) continue;
... ...
@@ -317,11 +317,11 @@ pass1(FILE *f)
317 317
 			if(!makemacro(w + 1, f))
318 318
 				return error("Pass 1 - Invalid macro", w);
319 319
 		} else if(w[0] == '@') {
320
-			if(!makelabel(w + 1, addr))
320
+			if(!makelabel(w + 1))
321 321
 				return error("Pass 1 - Invalid label", w);
322 322
 			scpy(w + 1, scope, 64);
323 323
 		} else if(w[0] == '&') {
324
-			if(!makelabel(sublabel(subw, scope, w + 1), addr))
324
+			if(!makelabel(sublabel(subw, scope, w + 1)))
325 325
 				return error("Pass 1 - Invalid sublabel", w);
326 326
 		} else if(scmp(w, "include", 8)) {
327 327
 			if(!doinclude(f, pass1))