beautypg.com

Ifdef (conditional assembly) – Echelon Neuron User Manual

Page 154

background image

IFDEF (Conditional Assembly)

The Neuron assembler provides the following directives for conditional control of

the assembly of blocks of source lines: IF, IFDEF, IFNDEF, ELSE, and

ENDIF.
A conditional assembly block begins with the IF, IFDEF, or IFNDEF directive,

and ends with a matching ENDIF directive. A conditional block can contain at

most one matching ELSE directive.
Conditional assembly directives can be nested. Thus, a group of source-code lines

between an IF directive and a matching ELSE or ENDIF can contain additional

IF, IFDEF, or IFNDEF directives, and ELSE directives, as long as there are an

identical number of matching ENDIF directives. The maximum number of

nested directives is five. The total maximum number of conditional IF, IFDEF,

and IFNDEF directives for a single source file is 256.
Source-code lines that the assembler skips because of conditional assembly must

still conform to the Neuron assembler syntax.

Syntax:
The IFDEF directive requires a symbol as its argument and cannot have a label.

The IFDEF directive must be followed by a matching ENDIF directive.

IFDEF symbol

If the symbol is defined, the Neuron assembler processes the lines following the

directive, up to a matching ELSE directive, if any. If the symbol is not defined,

the Neuron assembler skips all of the lines following the directive, up to a

matching ELSE directive, if any, or to the matching ENDIF directive.
You can define symbols anywhere in the assembly source file using the EQU

directive; see EQU (Equate Symbol). You can also provide a symbol to the

assembler using the --define command from the console; see NAS Command

Switches.

144

Neuron Assembler Directives