I've spent a lot of time thinking about the form that label definitions would take. I considered everything from staying with the original concept (ten labels 0-9, with each having one address and one forward reference), all the way up to dynamic labels of up to four characters. I considered single-character label names as aliases for 0-9, and a whole bunch of other things. Ultimately, though, the label system was guided by the following principles:
(1) Low memory footprint. A dynamic four-character table would grow pretty fast. I wanted the table to be unobtrusive, preferably under 64 bytes.
(2) Expendable. I didn't want it to be necessary for the symbol table to be retained in memory after assembly. It should be easy to clear out and start over. If you don't use the symbolic features, the symbol table memory will never be accessed.
(3) Visually distinct from code
(4) Low or zero necessity for error messages
(5) If the label set is small, label redefinition should be easy and meaningful
The current--and probably final--system is as follows:
* There are ten labels for symbols, 0-9, prefixed with - (minus). The minus sigil is used by xa for labels, so it's recognizable (to me) as a label.
* The labels can be used as forward or backward references
* Up to eight forward references can be unresolved at a time
* Each label can be used as a forward reference any number of times (up to eight)
* When a symbol's address is resolved, it releases one of the eight forward reference records
* Re-defining a label is possible. I would tend to re-use -0 for local loops, as I use -loop in xa
* The forward reference resolution checks the addressing mode of its instruction so it can resolve symbols for relative branches, absolute and indirect code, and immediate instructions, while throwing errors for implied mode and unrecognized instructions.
* For immediate or zeropage (including ,X and ,Y) mode instructions, you can specify H or L after the label (again, for both forward and backward references)
I added another feature, which allows you to chop up your memory into BASIC staging areas as you see fit. I plan on having my main program under development at $1000, but I'll have BASIC tests or utilities in other places in Block 5, where I'll have 8K. I'm providing a way to switch BASIC on the fly.
Anyway, here's a demo of forward reference resolution with immediate mode, high and low. Obviously, if the setup routine were longer, you could see the practicality.
Of course, you can always define symbols directly like this, although I don't see me doing it this way very much. Note that you can relocate this code by changing *nnnn at the beginning. The * in line 5 initializes the symbol table. This is what I meant when I said it must be "expendable."
This weekend I'll be spanning this across a pair of 2716s for insertion into an 8K RAM cartridge