151/317
6 - STMicroelectronics Programming Tools
drive the data copy loop in the piece of code above, you get your variables initialized in a con-
venient and error-free way.
6.1.5.6 Referencing symbols and labels between modules
Declaring external symbols
If a program is split into several modules, you have to use special declarations in the modules
to tell the assembler that some symbols are not defined in the current module, but in another
one, and that this is not a mistake; otherwise the assembler would produce an error message.
In addition, saying that a symbol is external, makes the assembler take special care of this
symbol by building a list of external symbols and of the place where they are used in the cur-
rent module. This list will be used by the linker that will resolve the addresses of theses sym-
bols, and correct the object file of that module with the right addresses at the places men-
tioned in the list.
The syntax of the declaration of external symbols is as in the example below:
EXTERNAL Value1.b, Value2.w
where two identifiers are declared external. Each identifier is given a type, that is either byte,
word or long. This applies to the address of the identifier, that is either contained in a byte
(when the identifier is located in page zero) or in a word (when the identifier must be accessed
using extended addressing mode).
Caution:
These suffixes do not mean that these data are of the byte or word type, i.e. that they
store bytes or words; it is their address that is either a byte or a word.
Byte or word identifiers are symbols or labels; long identifiers can only be generated using the
EQU
pseudo-op.
Declaring global symbols
The notion of external symbols goes together with that of global symbols. For a symbol, de-
fined in a module, to be referenced in one or more other modules, it is necessary to declare
them as global. This action may seem superfluous, as you might expect that all symbols de-
fined in a module be should global in nature, and thus be accessible from everywhere.
Though this could be, it would actually be more an impediment than a comfort. Large pro-
grams have many symbols defined, and this would lead to both an overload of the linker, and
also a risk of collision between names defined in different modules.
In a team project, each programmer is responsible for a part of the total program. He is as-
signed a precise job to do, by writing a piece of code that performs a specified function that
has a specified set of data as the input and produces another set of specified data as the
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...