152/317
6 - STMicroelectronics Programming Tools
output. Besides this, he is free to organize his work as he likes – though some writing style
rules might have been given to the team for sake of homogeneity of style and ease of mainte-
nance afterwards. The consequence is that he may define as many symbols he wants in his
module, and he is free to choose their nam es. This is because these symbols will not be
known outside of his module; they are called private, or local, symbols. The input and output
symbols, on the contrary, have been specified both for their names and for their types, values,
etc. These symbols are global, and may be used by everybody in the team since everybody
knows them.
If there were no local symbols, each time one programmer wished to create a new symbol, he
would have to consult all his colleagues to ensure that a symbol of the same name had not yet
been created.
The syntax of the declaration of global symbols is as in the example below:
PUBLIC Value1, Value2
where two identifiers are declared public. Unlike in the
EXTERN
directive, each identifier already
has a type, that is either byte, word or long and that has been defined with the identifier itself.
The following example will show the difference between the type of the identifier and the type
of the object it represents.
PUBLIC Value1, Value2, Constant1
Constant1.l EQU 1350000
; a large value that does not fit a word
SEGMENT 'DATA_Page0'
Value1.b
DS.W 1
; a word data in page zero
SEGMENT 'DATA_Extended'
Value2.w
DS.B 1
; a byte data in extended memory
Value1
is a word variable, that is, the data requires two successive bytes for its storage; how-
ever, since this data is located in a segment that is meant to be located in page zero, the type
of the public symbol is byte. Conversely,
Value2
is a byte variable, that is, only one byte is
needed to store the value. But this variable is located anywhere in memory, and requires ex-
tended addressing. The label
Value2
must thus be given the word type.
These subtleties are required because the assembler does not know about the location of var-
iables in memory at assembly time, since the segments are relocatable and will be assigned
absolute addresses only at link time. Without these declarations we could not use short ad-