Skip to content
ksherlock edited this page Jan 12, 2017 · 4 revisions

$E2 RELOC - This is a relocation record, used in the relocation dictionary of a load segment. It is used to patch an address in a load segment with a reference to another address in the same load segment. It contains two 1-byte counts followed by two offsets. The first count is the number of bytes to be relocated, and the second count is a bit-shift operator, telling how many times to shift the relocated address before inserting the result into memory. If the bit-shift operator is positive, then the number is shifted to the left, filling vacated bit positions with 0’s. If the bit-shift operator is negative, then the number is shifted right.

The first offset gives the location (relative to the start of the segment) of the number that is to be relocated. The second offset is the location of the reference relative to the start of the segment; that is, it is the value that the number would have if the segment it’s in started at address $000000. For example, suppose the segment includes the following lines:

$0035 label anop
...
$0400       lda label+4

which corresponds to the following values:

$E2 operation code
$02 number of bytes to be relocated
$00 bit-shift operator
$00000401 offset of value from start of segment
$00000039 value if segment started at $000000

Certain types of arithmetic expressions are illegal in a relocatable segment. Specifically, any expression that cannot be evaluated (relative to the start of the segment) by the assembler cannot be used. The expression LAB|4 can be evaluated, for example, since the RELOC record includes a bit-shift operator; however LAB|4+4 cannot be used, because the assembler would have to know the absolute value of LAB in order to perform the bit-shift operation before adding 4 to it. Similarly, the value of LAB*4 depends on the absolute value of LAB, and cannot be evaluated relative to the start of the segment, so multiplication is illegal in expressions in relocatable segments.

Clone this wiki locally