S5U1C62000A MANUAL
EPSON
67
(S1C60/62 FAMILY ASSEMBLER PACKAGE)
CHAPTER 5: ASSEMBLER
5.7.3 Macro Instructions (#macro ... #endm)
Any statement string can be left defined as a macro using the macro instruction (#macro), and the content
of that definition can be invoked from different parts of the program with the macro name. Unlike a
subroutine, the part that is invoking a macro is replaced with the content of the definition.
Instruction format
#macro
<Macro name>
[<Dummy parameter>] [,<Dummy parameter>] ...
<Statement string>
#endm
<Macro name>:
• The first character is limited to a–z, A–Z, ? and _.
• The second and the subsequent characters can use a–z, A–Z, 0–9, ? and _.
• Uppercase and lowercase characters are discriminated. (#macro itself is not case sensitive.)
• One or more spaces or tabs are necessary between the instruction and the macro name.
<Dummy parameter>:
• Dummy parameter symbols for macro definition. They are described when a macro to be defined
needs parameters.
• One or more spaces or tabs are necessary between the macro name and the first parameter symbol.
When describing multiple parameters, a comma (,) is necessary between one parameter and another.
• The same symbols as for a macro name are available.
• The number of parameters are limited according to the free memory space.
<Statement string>:
• The following statements can be described:
- Basic instruction (mnemonic and operand)
- Conditional assembly instruction
- Internal branch label
*
- Comments
• The following statements cannot be described:
- Assembler pseudo-instructions (excluding conditional assembly instruction)
- Other labels than internal branch labels
- Macro invocation
∗
Internal branch label
A macro is spread over to several locations in the source. Therefore, if you describe a label in a macro,
a double definition will result, with an error issued. So, use internal branch labels which are only
valid within a macro.
• The number of internal-branch labels are limited according to the free memory space.
• The same symbols as for a macro name are available.
Sample definition:
#define C_RESET
0b1101
#macro
WAIT
COUNT
ld
a,COUNT
rst
f,C_RESET
LOOP:
nop5
jp
LOOP
#endm