5 conditional assembly instructions – Epson S5U1C63000A User Manual

Page 84

Advertising
background image

CHAPTER 4: ASSEMBLER

70

EPSON

S5U1C63000A MANUAL

(S1C63 FAMILY ASSEMBLER PACKAGE)

4.7.5 Conditional Assembly Instructions

(#ifdef ... #else ... #endif, #ifndef... #else ... #endif)

A conditional assembly instruction determines whether assembling should be performed within the
specified range, dependent on whether the specified name (Define name) is defined or not.

Instruction formats

Format 1)

#ifdef

<Name>
<Statement string 1>

[#else

<Statement string 2> ]

#endif

If the name is defined, <Statement string 1> will be subjected to the assembling.
If the name is not defined, and #else ... <Statement string 2> is described, then <Statement string 2>
will be subjected to the assembling. #else ... <Statement string 2> can be omitted.

Format 2)

#ifndef

<Name>
<Statement string 1>

[#else

<Statement string 2> ]

#endif

If the name is not defined, <Statement string 1> will be subjected to the assembling.
If the name is defined, and #else ... <Statement string 2> is described, <Statement string 2> will be
subjected to the assembling. #else ... <Statement string 2> can be omitted.

<Name>:

Conforms to the restrictions on Define name. (See #define.)

<Statement string>:

All statements, excluding conditional assembly instructions, can be described.

Sample description:

#ifdef

TYPE1

ld

%x,0x12

#else

ld

%x,0x13

#endif

#ifndef

SMALL

#define

STACK1 0x31

#endif

Name definition

Name definition needs to have been completed by either of the following methods, prior to the
execution of a conditional assembly instruction:

(1) Definition using the start-up option (-d) of the assembler.

Example:

as63 -d TYPE1 sample.s

(2) Definition in the source file using the #define instruction.

Example:

#define TYPE1

The #define statement is valid even in a file to be included, provided that it goes before the
conditional assembly instruction that uses its Define name. A name defined after a conditional
assembly instruction will be regarded as undefined.

When a name is going to be used only in conditional assembly, no substitute character string
needs to be specified.

Advertising