Page 149 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 149
126 Chapter 5 Advanced Assemblers, Linkers, and Downloaders
IFGT OFFSET-1
LEAX OFFSET,X
ELSE
IFEQ OFFSET-1
INX
ENDC ; matches IFEQ
ENDC ; matches IFGT
tests the predefined symbol OFFSET. If OFFSET is greater than one, a LEAX
instruction is used; if it is one, a shorter INX instruction is used, and if it is zero, no
code is generated.
The conditional IFDEF directive is often used to be sure that a symbolic name is
defined before it is used in an assembler line, such as another conditional directive, to
avoid generating an error message. The IFNDEF directive is particularly useful in
INCLUDE files described in a later section on documentation.
The IFC and IFNC conditional directives are able to test strings of characters to see
if they are exactly matching. The former assembles lines to the ENDC or ELSE directive
if the strings match; the latter assembles the lines if the strings don't match. It finds
special use in macros, discussed in the next section where an example is given.
One of the principal uses of conditional assembly directives is for debugging
programs. For example, a number of program segments following each IFDEF MODE
up to the matching ENDC can be inserted or deleted from a program by just inserting the
EQU directive defining MODE. All of these directives allow the programmer to uniformly
control how the program is converted to object code at assembly time.
Another significant use of conditional assembly is the maintenance of programs for
several different target microcomputers. Some code can be conditionally assembled for
certain target microcontrollers, but not for other microcontrollers.
Table 53. Conditional Directives