SLAU131Y October 2004 – June 2021
Normally, any reference to a symbol refers to its run-time address. However, it may be necessary at run time to refer to a load-time address. Specifically, the code that copies a section from its load address to its run address must have access to the load address. The .label directive defines a special symbol that refers to the section's load address. Thus, whereas normal symbols are relocated with respect to the run address, .label symbols are relocated with respect to the load address. See Create a Load-Time Address Label for more information on the .label directive.
Moving a Function from Slow to Fast Memory at Run Time and Linker Command File for show the use of the .label directive to copy a section from its load address in EXT_MEM to its run address in P_MEM. Figure 9-3 illustrates the run-time execution of Moving a Function from Slow to Fast Memory at Run Time.
If you use the table operator, the .label directive is not needed. See Section 9.9.4.1.
* Define a section to be copied from load to run address
.sect ".fir"
.label fir_src
fir:
* < code here> ;code for section
.label fir_end
* Copy .fir section from load address to run address
.text
MOV &fir_s,R11
MOV &fir_e,R12
MOV #fir,R13
LOOP: CMP R11,R12
JL Copy_Done
MOV @R11+,0(R13)
INC R13
JMP LOOP
Copy_Done:
* Jump to fir routine, now at run address
JMP fir
fir_s .word fir_src
fir_e .word fir_end
/*****************************************************/
/* PARTIAL LINKER COMMAND FILE FOR FIR EXAMPLE */
/*****************************************************/
MEMORY
{
MEM1: origin = 0x2000, length 0x0500
MEM2: origin = 0x3000, length 0x0500
}
SECTIONS
{
.text: load = MEM1
.fir: load = MEM2, run = MEM1
}
See Section 9.7.1 for information about referring to linker symbols in C/C++ code.