.macro


Executes a macro definition by assigning the macro name specified in the symbol field to a series of statements described between .macro directive and the .endm directive.

[Syntax]

Symbol field

Mnemonic field

Operand field

Comment field

macro-name
.macro
   :
Macro body
   :
[formal-parameter[, ... ]] 
[; comment]

[Function]

-

The .macro directive executes a macro definition by assigning the macro name specified in the symbol field to a series of statements (called a macro body) described between this directive and the .endm directive.

[Use]

-

Define a series of frequently used statements in the source program with a macro name. After its definition only describe the defined macro name, and the macro body corresponding to the macro name is expanded.

[Description]

-

If the .endm directive corresponding to .macro directive does not exist, an error occurs.

-

For the macro name to be described in the symbol field, see the conventions of symbol description in "(2) Symbol".

-

To call macro, describe the defined macro name in the mnemonic field. If a macro that is undefined at the point is called, an error occurs.

-

For the formal parameter(s) to be described in the operand field, the same rules as the conventions of symbol description will apply.

-

Formal parameters are valid only within the macro body.

-

The number of formal parameters must be the same as the number of actual parameters. Otherwise, an error occurs.

-

The maximum number of formal parameters that can be used depends on the amount of memory.

-

The number of macros that can be defined within a single source module is not specifically limited. In other words, macros may be defined as long as there is memory space available.

-

If a macro is called before it has been defined, an error will be output.

-

The only actual parameters that can be specified in the macro call are label names, symbol names, numbers, registers, and instruction mnemonics.
If a label expression (LABEL-1), a label beginning with a reference symbol (#LABEL), or base register specification ([gp]) or the like is specified, then a message will be output depending on the actual parameter specified, and assembly will halt.

-

A line of a sentence can be designated in the macro-body. The part of a sentence, such as operand, cannot be allowed.

-

An error will be output if a macro is defined in the macro body of a macro definition, but processing will continue (the content up to the corresponding ".endm" directive is ignored). Referencing a macro name will cause a definition error.

[Example]

ADMAC   .macro  PARA1, PARA2    ; (1)
        mov     PARA1, r12
        add     PARA2, r12
        .endm                   ; (2)
 
        ADMAC   0x10, 0x20      ; (3)

(1)

A macro is defined by specifying macro name "ADMAC" and two formal parameters "PARA1" and "PARA2".

(2)

This directive indicates the end of the macro definition.

(3)

Macro "ADMAC" is referenced.