5.21 MACRO

Begin macro.

The MACRO directive tells the Assembler that this is the start of a Macro. The MACRO directive takes the Macro name as parameter. When the name of the Macro is written later in the program, the Macro definition is expanded at the place it was used. A Macro can take up to 10 parameters. These parameters are referred to as @0-@9 within the Macro definition. When issuing a Macro call, the parameters are given as a comma separated list. The Macro definition is terminated by an ENDMACRO directive.

By default, only the call to the Macro is shown on the listfile generated by the Assembler. In order to include the macro expansion in the listfile, a LISTMAC directive must be used. A macro is marked with a + in the opcode field of the listfile.

Syntax
.MACRO macroname
Example
.MACRO SUBI16 ; Start macro definition 
subi @1,low(@0) ; Subtract low byte 
sbci @2,high(@0) ; Subtract high byte 
.ENDMACRO ; End macro definition

.CSEG ; Start code segment 
SUBI16 0x1234,r16,r17 ; Sub.0x1234 from r17:r16