Everything
5.3.3 Conditional Assembly Directives

These directives specify whether to assemble a specified range of lines.

Table 5.32

Conditional Assembly Directives

Directive

Function

.IF

Specifies the beginning of a conditional assembly block and evaluates the condition.

.ELIF

Evaluates the second or later conditions when multiple conditional blocks are written.

.ELSE

Specifies the beginning of a block to be assembled when all conditions are false.

.ENDIF

Specifies the end of a conditional assembly block.

.IF, .ELIF, .ELSE, .ENDIF

[Format]

.IFΔconditional expression

body

.ELIFΔconditional expression

body

.ELSE

body

.ENDIF

[Description]

The assembler controls assembly of the blocks according to the conditions specified through .IF and .ELIF.

The assembler evaluates the condition specified in the operand of .IF or .ELIF, and assembles the body in the subsequent lines when the condition is true. In this case, the lines before the .ELIF, .ELSE, or .ENDIF directive are assembled.

Any directives that can be used in an assembly-language file can be written in a conditional assembly block.

Conditional assembly is done according to the result of conditional expression evaluation.

[Examples] <Example of conditional expressions>

sym < 1

sym+2 < data1

sym+2 < data1+2

'smp1' == name

<Example of conditional assembly specification>

.IF TYPE==0

.byte "Proto Type Mode"

.ELIF TYPE>0

.byte "Mass Production Mode"

.ELSE

.byte "Debug Mode"

.ENDIF

[Remarks]

Be sure to write a conditional expression in an .IF or .ELIF directive.

Be sure to insert a space character or a tab between the .IF or .ELIF directive and the operand.

Only one conditional expression can be specified for the operand of the .IF or .ELIF directive.

Be sure to use a conditional operator in a conditional expression.

The following operators can be used.

Table 5.33

Conditional Operators of .IF and .ELIF Directives

Conditional Operator

Description

>

The condition is true when the lvalue is greater than the rvalue

<

The condition is true when the lvalue is smaller than the rvalue

>=

The condition is true when the lvalue is equal to or greater than the rvalue

<=

The condition is true when the lvalue is equal to or smaller than the rvalue

==

The condition is true when the lvalue is equal to the rvalue

!=

The condition is true when the lvalue is not equal to the rvalue

A conditional expression is evaluated in signed 32 bits.

Symbols can be used in the left and right sides of a conditional operator.

Expressions can be used in the left and right sides of a conditional operator. For the expression format, refer to the rules described in (2) Expression in section 4.1.5, Coding of Operands.

Strings can be used in the left and right sides of a conditional operator. Be sure to enclose a string within single-quotes (') or double-quotes ("). Strings are compared in character code values.

Examples:

"ABC"<"CBA" -> 414243 < 434241; this condition is true.

"C" < "A" -> 43 < 41; this condition is false.

Space characters and tabs can be written before and after conditional operators.

Conditional expressions can be specified in the operands of the .IF and .ELIF directives.

The assembler does not check if the evaluation result is outside the allowed range.

Forward reference symbols (reference to a symbol that is defined after this directive line) must not be specified.

If a forward reference symbol or an undefined symbol is specified, the assembler assumes the symbol value as 0 when evaluating the expression.