User manual

Assembler directives ST Assembler-Linker
64/89 Doc ID 11392 Rev 4
Description
Sometimes it is necessary to have different versions of a program or macro. This can
be achieved by completely SEPARATE programs / macros, but this solution has the
associated problem that changes to any part of the program common to all the
versions requires all of them being changed, which can be tedious.
Conditional assembly offers the solution of controlled 'switching off' assembly of the
source code, depending on the value of the numeric expressions.
The structure is known as 'IF/ELSE/ENDIF': see the example for the format.
The #ELSE statement is optional. If the expression resolves to 0 the expression is
assumed to have a 'false' result: the source code between the false #IF and the next
#ENDIF (or #ELSE if supplied) will not be assembled.
If the #ELSE is supplied, the code following the #ELSE will be assembled only if the
condition is false.
Conditionals may be nested up to 15 levels: when nesting them, keep in mind that
each #IF must have a #ENDIF at its level, and that #ENDIFs and #ELSEs refer to the
last unterminated #IF.
Example
#IF{1eq1}
%out true
#FALSE
%out false
#ENDIF
See also #ENDIF, #ELSE, #IF1, #IF2
Table 43. #IF1 Conditional
Purpose Conditional on being in pass #1.
Format #IF1
Description
This directive works just like #IF except it has no argument and only evaluates itself as
true if the assembler is on its first pass through the source code. Can use #ELSE and
requires #ENDIF.
Example
#IF1
%OUT “Starting Assembly”
#ENDIF
See also #IF2, #ELSE, #IF, #ENDIF
Table 44. #IF2
Purpose Conditional on being in pass #2.
Format #IF2
Description
This directive works just like #IF except it has no argument and evaluates itself as true
only if the assembler is on its second pass through the source code.
Example
#IF2
%OUT “GONE through PASS-1 OK”
#ENDIF
See also #IF1, #IF, #ENDIF, #ELSE
Table 42. #IF