17 if — conditional assembly, If — conditional assembly – Motorola HC12 User Manual
Page 182

User’s Manual
MCUez HC12 Assembler
182
Assembler Directives
MOTOROLA
Assembler Directives
8.17 IF — Conditional Assembly
Syntax:
IF
[
[
ELSE
]
[
ENDIF
Description:
If
the
IF
directive generate code. Assembly continues until the
corresponding
ELSE
or
ENDIF
directive is reached. Then all
statements until the corresponding
ENDIF
directive are
ignored. Nesting of conditional blocks is allowed. The
maximum level of nesting is limited by available memory at
assembly time.
The expected syntax for
"=" | "!=" | " >=" | ">" | "<=" | "<" | "<>"
The
assembly time.
Example:
This is an example of using conditional assembly directives:
Try: EQU 0
IF Try != 0
LDD #1023
ELSE
LDD #0
ENDIF
The value of
TRY
determines the instruction that generates
code. As shown, the
LDD #0
instruction generates code.
Changing the operand of the
EQU
directive to one causes the
LDD #1023
instruction to generate code instead.
This is the listing provided by the assembler for these lines of code:
0000 0000 Try: EQU 0
0000 0000 IF Try != 0
ELSE
000000 CC 0000 LDD #0
ENDIF