Define a relocatable section using the SECTION directive. See the following listing for an example of defining relocatable sections.
constSec: SECTION ; Relocatable constant data section. cst1: DC.B $A6 cst2: DC.B $BC dataSec: SECTION ; Relocatable data section. var: DS.B 1
In the previous portion of code, the label cst1 will be located at an offset 0 from the section constSec start address, and label cst2 will be located at an offset 1 from the section constSec start address. See the following listing:
2 2 constSec: SECTION ; Relocatable 3 3 000000 A6 cst1: DC.B $A6 4 4 000001 BC cst2: DC.B $BC 5 5 6 6 dataSec: SECTION ; Relocatable 7 7 000000 var: DS.B 1
Locate program assembly source code in a separate relocatable section, as listed in the following listing:
XDEF entry codeSec: SECTION ; Relocatable code section. entry: LDA cst1 ; Load value in cst1 ADD cst2 ; Add value in cst2 STA var ; Store in var BRA entry
In the previous portion of code, the LDA instruction is located at an offset 0 from the codeSec section start address, and ADD instruction at an offset 3 from the codeSec section start address.
In order to avoid problems during linking or execution from an application, an assembly file should at least: