... | ... |
@@ -39,7 +39,7 @@ typedef struct { |
39 | 39 |
Uint16 llen, mlen, rlen; |
40 | 40 |
Label labels[0x400]; |
41 | 41 |
Macro macros[0x100]; |
42 |
- Reference refs[0x1000]; |
|
42 |
+ Reference refs[0x400]; |
|
43 | 43 |
char scope[0x40]; |
44 | 44 |
} Program; |
45 | 45 |
|
... | ... |
@@ -175,27 +175,27 @@ makelabel(char *name) |
175 | 175 |
} |
176 | 176 |
|
177 | 177 |
static int |
178 |
-makereference(char *scope, char *label, Uint16 addr) |
|
178 |
+makereference(char *scope, char *label, char rune, Uint16 addr) |
|
179 | 179 |
{ |
180 | 180 |
char subw[0x40], parent[0x40]; |
181 | 181 |
Reference *r; |
182 | 182 |
if(p.rlen == 0x1000) |
183 | 183 |
return error("References limit exceeded", label); |
184 | 184 |
r = &p.refs[p.rlen++]; |
185 |
- if(label[1] == '&') { |
|
186 |
- if(!sublabel(subw, scope, label + 2)) |
|
185 |
+ if(label[0] == '&') { |
|
186 |
+ if(!sublabel(subw, scope, label + 1)) |
|
187 | 187 |
return error("Invalid sublabel", label); |
188 | 188 |
scpy(subw, r->name, 0x40); |
189 | 189 |
} else { |
190 |
- int pos = spos(label + 1, '/'); |
|
190 |
+ int pos = spos(label, '/'); |
|
191 | 191 |
if(pos > 0) { |
192 | 192 |
Label *l; |
193 |
- if((l = findlabel(scpy(label + 1, parent, pos)))) |
|
193 |
+ if((l = findlabel(scpy(label, parent, pos)))) |
|
194 | 194 |
l->refs++; |
195 | 195 |
} |
196 |
- scpy(label + 1, r->name, 0x40); |
|
196 |
+ scpy(label, r->name, 0x40); |
|
197 | 197 |
} |
198 |
- r->rune = label[0]; |
|
198 |
+ r->rune = rune; |
|
199 | 199 |
r->addr = addr; |
200 | 200 |
return 1; |
201 | 201 |
} |
... | ... |
@@ -305,29 +305,29 @@ parse(char *w, FILE *f) |
305 | 305 |
return error("Invalid hex literal", w); |
306 | 306 |
break; |
307 | 307 |
case '_': /* raw byte relative */ |
308 |
- makereference(p.scope, w, p.ptr); |
|
308 |
+ makereference(p.scope, w + 1, w[0], p.ptr); |
|
309 | 309 |
return writebyte(0xff); |
310 | 310 |
case ',': /* literal byte relative */ |
311 |
- makereference(p.scope, w, p.ptr + 1); |
|
311 |
+ makereference(p.scope, w + 1, w[0], p.ptr + 1); |
|
312 | 312 |
return writelitbyte(0xff); |
313 | 313 |
case '-': /* raw byte absolute */ |
314 |
- makereference(p.scope, w, p.ptr); |
|
314 |
+ makereference(p.scope, w + 1, w[0], p.ptr); |
|
315 | 315 |
return writebyte(0xff); |
316 | 316 |
case '.': /* literal byte zero-page */ |
317 |
- makereference(p.scope, w, p.ptr + 1); |
|
317 |
+ makereference(p.scope, w + 1, w[0], p.ptr + 1); |
|
318 | 318 |
return writelitbyte(0xff); |
319 |
- case ':': /* raw short absolute */ |
|
320 |
- case '=': |
|
321 |
- makereference(p.scope, w, p.ptr); |
|
319 |
+ case ':': |
|
320 |
+ case '=': /* raw short absolute */ |
|
321 |
+ makereference(p.scope, w + 1, w[0], p.ptr); |
|
322 | 322 |
return writeshort(0xffff, 0); |
323 | 323 |
case ';': /* literal short absolute */ |
324 |
- makereference(p.scope, w, p.ptr + 1); |
|
324 |
+ makereference(p.scope, w + 1, w[0], p.ptr + 1); |
|
325 | 325 |
return writeshort(0xffff, 1); |
326 | 326 |
case '?': /* JCI */ |
327 |
- makereference(p.scope, w, p.ptr + 1); |
|
327 |
+ makereference(p.scope, w + 1, w[0], p.ptr + 1); |
|
328 | 328 |
return writebyte(0x20) && writeshort(0xffff, 0); |
329 | 329 |
case '!': /* JMI */ |
330 |
- makereference(p.scope, w, p.ptr + 1); |
|
330 |
+ makereference(p.scope, w + 1, w[0], p.ptr + 1); |
|
331 | 331 |
return writebyte(0x40) && writeshort(0xffff, 0); |
332 | 332 |
case '"': /* raw string */ |
333 | 333 |
i = 0; |
... | ... |
@@ -354,7 +354,7 @@ parse(char *w, FILE *f) |
354 | 354 |
return 0; |
355 | 355 |
return 1; |
356 | 356 |
} else { |
357 |
- makereference(p.scope, w - 1, p.ptr + 1); |
|
357 |
+ makereference(p.scope, w, ' ', p.ptr + 1); |
|
358 | 358 |
return writebyte(0x60) && writeshort(0xffff, 0); |
359 | 359 |
} |
360 | 360 |
} |