EasyManua.ls Logo

ST ST7 - Conditional Assembly

ST ST7
317 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
154/317
6 - STMicroelectronics Programming Tools
SEGMENT 'DATA_Page0'
BYTES
Value1 DS.W 1 ; a word data in page zero
SEGMENT 'DATA_Extended'
WORDS
Value2 DS.B 1 ; a byte data in extended memory
The lines containing the SEGMENT pseudo-op may appear either before or after the line with the
BYTES, WORDS or LONGS pseudo-op.
6.1.6 Conditional assembly
Conditional assembly is a convenience that all assemblers and compilers provide that helps
write a program that can allow variants, for example to accommodate various hardware con-
figurations.
It is frequent that a product actually exists in a family of variants that only differ by a few de-
tails. Writing as many programs as the number of variants is cumbersome and leads to mis-
takes when a change is made in a part that is common to all variants, but that has been for-
gotten in one of the variants.
For these types of situations, conditional assembly provide an efficient way of mastering the
updates of all versions simultaneously.
Conditional assembly uses structures IF...ENDIF or IF...ELSE...ENDIF like in high-level lan-
guages. The general syntax is:
There are several types of conditions. Most use expressions evaluated from symbols that may
or may not be defined in the current module. Thus, changing only one symbol may switch the
groups of lines that are assembled is as many places of the source text as the number of such
IF... structures.
#IF <condition>
one or more lines of source text...
#ENDIF
#IF <condition>
one or more lines of source text...
#ELSE
one or more lines of source text...
#ENDIF
If the condition is satisfied, the lines between
IF and ENDIF are processed by the
assembler. Otherwise, they are ignored, like
comments.
If the condition is satisfied, the lines between
IF and ELSE are processed by the assembler.
Otherwise, the lines between ELSE and
ENDIF are processed by the assembler. The
other group of lines is ignored, like comments.

Table of Contents

Related product manuals