The absolute value of a symbol can be obtained by simply naming the symbol. However, as AVR32 symbols have 32-bit values, most symbols have values that are outside the range of any instructions.
Instructions that take a PC-relative offset, e.g. lddpc
or
rcall
, can also reference a symbol by simply naming the symbol
(no explicit calculations necessary). In this case, the assembler or
linker subtracts the address of the instruction from the symbol's value
and inserts the result into the instruction. Note that even though an
overflow is less likely to happen for a relative reference than for an
absolute reference, the assembler or linker will generate an error if
the referenced symbol is too far away from the current location.
Relative references can be used for data as well. For example:
lddpc r0, 2f 1: add r0, pc ... .align 2 2: .int some_symbol - 1b
Here, r0 will end up with the run-time address of some_symbol even if the program was loaded at a different address than it was linked (position-independent code).
hi(
symbol)
lo(
symbol)
@got