beautypg.com

If (conditional assembly) – Echelon Neuron User Manual

Page 153

background image

IF (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 IF directive requires a constant expression as its argument and cannot have

a label. The IF directive must be followed by a matching ENDIF directive.

IF const_expr

If the expression evaluates to a non-zero value, the Neuron assembler processes

the lines following the directive, up to a matching ELSE directive, if any. If the

expression evaluates to zero, 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.

Neuron Assembly Language Reference

143