First pass:
- collect information for numbers, registers and which instructions
contain label references
- encode all instructions that don't contain label references
- Set (temporary) addresses for each instruction
Second pass:
- Collect information about label references (address, offset, size)
- encode all instructions that contain label references
- Update (if necessary) addresses for each instruction
The second pass is iterated 10 times or until no instructions change
size, whichever comes first.
- Add a instruction value that contains the encoding, the address and a
flag to indicate if this instruction contains label references
- Add label value that contains an address
- Add reference value that contains offset, an absolute address and an
operand size
- define types for all value options in the union
- define accessor functions for all the values in the union
Before it kept track of a more specific node that referenced the symbol
in some way. Now it will only keep track of the actual label defining
statements. This is done to facilitate encoding. The encoder can now go
from a symbol name to the statement that defines the symbol.
Restructure the encoder to deal with this and pass the correct statement
to the symbol update function.