Chapter 10 Writing Assembler Control Statements

10.4 Conditional Assembly

The cross assembler provides conditional assembly capabilities. The directives explained in this section are provided for this purpose.

By coding conditional assembly directives in a program, the assembler will select which block to assemble by judging the specified conditions at the time of assembly.

Many conditional assembly directives are used only within macro definitions. The actual program structure of conditional assembly is shown below.

#if

 

expression, identifier, parameter, etc.

 

 

 

block1 to be

assembled if condition is true

 

[#else

block 2 to be

assembled if condition is false]

 

 

 

 

#endif

 

 

 

 

 

 

 

 

NOTE:

The contents of brackets [ ] from #else on can be omitted.

 

 

 

 

 

The basic function of conditional assembly directives are for the assembler to evaluate the condition specified by #if, and then to select the block to assemble based on the result.

Conditional assembly directives are used for the following purposes.

Different object code for different versions can be output with a single source program.

Machine language instructions differ depending on the device type.

Conditional assembly directives can be included in programs being debugged.

Conditional Assembly 189

Page 201
Image 201
Panasonic MN1030 user manual Conditional Assembly, #if, Contents of brackets from #else on can be omitted