Multi Pass Assembly - Chysn/VIC20-wAx2 GitHub Wiki
Handling Forward Reference Overflow
Direct Mode
It's possible that, during the course of assembly, the forward reference table exceeds the allowed unresolved references. If this happens during direct mode assembly, wAx will throw a ?SYMBOL ERROR. This will alert you that you should examine the symbol table and either
- Resolve one or more forward references
- Clear the symbol table
- Where possible, use the forward reference symbol by changing your operand to @&
- Use a literal address
Multi-Pass Assembly with BASIC
When the forward reference table is exceeded in the course of a BASIC program, wAx does not throw an error. This is because a BASIC program can check for this condition and do a second pass, resulting in successful assembly.
Such a BASIC program would look like this:
10 .@- ; CLEAR SYMBOL TABLE
20 .* 1800
30 FOR I = 1 TO 25
40 .A * LDA @F
50 NEXT I
60 .A * @F BRK
70 IF UR% THEN 20
80 PRINT "DONE!"
After 12 iterations of the FOR/NEXT loop, the forward reference table is exceeded, and there's no place to store the 13th-25th references. So wAx increments the BASIC variable UR% (unresolved reference count). Line 70 checks for unresolved references and, if there are any, goes back for a second pass. On the second pass, the value of the symbol @F is now known, and the assembly may finish.
You won't need to do this check for every program. If you're concerned about the number of forward references, you can check the symbol table after assembly. If the last line of the symbol table has a ? value, like this
.@
* 194e ?02
then you have unresolvable references, and you should add the BASIC code to make a second assembler pass.