142/317
6 - STMicroelectronics Programming Tools
If you use the symbol
DISPLAY_WIDTH
several times in your program, and you place the above
declaration at a convenient place in the source text (in general at the beginning), when the dis-
play is later enlarged to 24 characters, this line is the only one you have to change:
DISPLAY_WIDTH EQU 24
for the program to be able to handle the new display size and without risking discrepancies re-
sulting from failing to change all occurances of 16 to 24.
Another use of symbols is in expressions:
DISPLAY_WIDTH EQU 24
DISPLAY_HEIGHT EQU 4
Total_Chars: DC.B (DISPLAY_WIDTH * DISPLAY_HEIGHT)
Here, two symbols are defined:
DISPLAY_WIDTH
and
DISPLAY_HEIGHT
. This does not affect the
memory contents in any way. However the last statement sets a memory byte to a value that
is the product of the two symbols above. Again, when constant data may vary depending on
the program version or other factors, it is advisable to define symbols that in turn give their
value to data in memory. This makes it easier to adapt the program to changes that can occur
later.
6.1.5 Relocation commands
6.1.5.1 What is relocation?
According to the description of the assembler so far, writing a program (besides the logical
analysis it involves) looks pretty straightforward. The program is made of a sequence of in-
structions starting from a specified address and extending towards upper memory. Similarly,
the variables in memory are mapped by increasing addresses from a certain start address.
Actually, things cannot be that simple. A program is almost never contained in a single source
file. The main reason is that this would generally lead to a very big file that would be difficult to
edit, and long to assemble. Another reason, almost as common, is that in an industrial envi-
ronment, a program is seldom written from scratch. Parts of it (and this is good programming
practice) come from previous programs, with some adaptation if necessary. Also, when a pro-
gram is written by a team of people, they cannot all work at the same time on the same source
file.
For all these reasons, a program is divided into source files called Modules, and one or more
modules are written by a certain person, while others are written by other people. This implies
that the structure of the program and its main functions have been thoroughly analyzed, that
Содержание 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 ...