165/317
6 - STMicroelectronics Programming Tools
95 000C
96 000C R C60000 ld A, d3
97
98 InitVariables:
99 000F R AE00 ld X, #{low SIZE_RAM}
The first column is the number of the line of source text. Here, the line 94 appears four times
because the source text contains the invocation of the macro
MyCode that is expanded with
three more lines.
The second column is the address. In the example, the first lines belong to the segment
DATA
that is absolute and starts from address 90h. The last label defined there is at address 94h.
Then, the segment is changed to a relocatable one. The addresses start from zero again,
since the exact address of the segment is not known yet.
The fourth column is the machine language. For example, in line 94, the source text
inc
CounterLo
is translated into 3C90. This is possible since the address of CounterLo is known
as 90h. On the contrary, in lines 91, 92, 96 and 99, the addresses of the objects
d1, d2, d3 and
the expression
low SIZE_RAM are not known at assembly time, since they are declared in an-
other module. There, the address field of the instruction is left at zero, and a letter
R is added
in the third column, to indicate that this address is relocatable.
The fifth column contains the exact reproduction of the corresponding source text.
6.2 LINKER AND ASCII-HEX CONVERTER
Note:
For the invocation of the linker and the command-line options, refer to the ST7 Software
Tools User Manual, paragraph 5.2.
6.2.1 The linking process
Once all source files have been assembled, we have a collection of object files that must be
merged so as to give a whole, single, and complete file where nothing is left undefined and
that can be transferred to the program memory of the microcontroller.
This operation is performed by the linker. The linker is another translator that reads all the ob-
ject files, concatenates them so that all the code and data definitions coming from the various
source files are put in sequence to occupy continuous blocks of memory. Then, all the global
declarations have their addresses calculated and kept in a table with their symbolic names.
The last step is to update each of the external (or relocatable) references, those marked with
a
R in the assembly listing file, with the final value of the corresponding symbol, taken from the
table.
The result of this work is called the executable object file and is written to the output file with
the extension
.COD.