SPRU513Y August 2001 – June 2022 SM320F28335-EP
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 SLOW_MEM to its run address in FAST_MEM. Figure 9-4 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 SLOW_MEM to FAST_MEM
;---------------------------------------------------------
.sect ".fir"
.label fir_src ; load address of section
fir: ; run address of section
<code here> ; code for the section
.label fir_end ; load address of section end
;---------------------------------------------------------
; copy .fir section from SLOW_MEM to FAST_MEM
;---------------------------------------------------------
.text
MOV XAR6, fir_src
MOV XAR7, #fir
RPT #(fir_end - fir_src - 1)
k PWRITE *XAR7, *XAR6++
;---------------------------------------------------------
; jump to section, now in FAST_MEM
;---------------------------------------------------------
B fir
/*******************************************************************/
/* PARTIAL LINKER COMMAND FILE FOR FIR EXAMPLE */
/*******************************************************************/
MEMORY
{
PAGE 0 : FAST_MEM : origin = 0x00000800, length = 0x00002400
PAGE 0 : PROG : origin = 0x00002C00, length = 0x0000D200
PAGE 1 : SLOW_MEM : origin = 0x00000800, length = 0x0000F800
}
SECTIONS
{
.text: load = PROG PAGE 0
.fir: load = SLOW_MEM PAGE 1, run = FAST_MEM PAGE 0
}
See Section 9.7.1 for information about referring to linker symbols in C/C++ code.