49/317
3 - Programming a microcontroller
Here again, the format of all the above mentioned files is chosen by the assembler's manufac-
turer, and differs from one to another.
03-asm
3.1.2.3 Linker
If the whole application program is small, it is easy to put the source text into a single file. The
assembler then produces an object file that contains the whole machine code ready for use.
This is called absolute assembling.
However, there are very few applications so simple that their source text occupies only a few
pages. In most cases, the total source text amounts to thousands of lines that may represent
hundreds of pages. In such a case, it would be impractical to edit a single large source file. Not
only would the assembly process take a long time but this time would be spent whenever a
change was made to the text.
It would be better to divide the whole text into several files, and to assemble them separately.
This way, a change would affect only one of the files, which can be quickly re-assembled.
Working this way requires additional features:
A means of telling that a particular source file references a data variable or a label that is
defined in another source file, in order to prevent the assembler from merely stopping and
issuing an error message saying that something referred to has not been found defined in
the same source file.
A tool to glue all the generated object files into a single object file, ready for use.
The first issue is addressed by additional syntax features that typically provide declarative
statements such as “External” and “Public”. The “External” statement declares that a certain
label referenced in the source file will intentionally not be found there, since it comes from an-
other source file. The “Public” statement declares that a label (or a variable) defined in this file
will be referenced by another source file.
File.asm
Source file
Assembler
File.obj
File.lst
Relocatable object file
Listing file
Assembler invocation