Chapter 10 Writing Assembler Control Statements

10.3.1 #define

Syntax

#define

[replacement_string] [; comment]

Functional description

This directive causes the assembler to replace the identifier with the replacement_string on all further lines.

The #define directive differs from the #equ directive in that a string can be specified. Furthermore, when used in conjunction with the #undef directive, redefinition is possible.

Coding rules

Any string can be coded for the replacement_string. The string can include spaces and tabs. If the replacement_string is omitted, the identifier will be defined as a null character.

Everything after a semicolon (;) is considered a comment. Therefore semicolons cannot be included in the replacement_string.

The same identifier cannot just be redefined with another #define directive. When used in conjunction with the #undef directive, redefinition is possible. Refer to section 10.4, "#undef", for details.

If the replacement_string is omitted, the identifier will be defined as a null character.

Usage example

Source file contents are shown below. The first line replaces data with the character 5. The next line is an example of changing a mnemonic, so mov data,D0 can be coded as load.

#define

data

5

 

#define

load

mov

data, D0

_CODE

section

CODE, PUBLIC,2

 

main

 

mov

data, D0

 

load

 

end

 

 

 

 

Identifier Definement 187

Page 199
Image 199
Panasonic MN1030 user manual 10.3.1 #define, #define Replacementstring comment, #define Data Load Mov Data, D0