A directive that opens the definition of a macro.
Syntax:
|
Example:
|
Print:.MACRO ... ; macro with any number of parameters |
Put:.MACRO chr; macro with a specific parameter |
Description:
Directive .MACRO is used to define macros. Label before directive .MACRO is the name of the macro definition and is placed in the macro name dictionary (separated from the name dictionary of the remaining labels).
In favor of the Directive .MACRO magicians have macro parameter names and ellipses (...). The name of the parameter can be used in the macro definition. This parameter is required when you call a macro. The ellipse (...) symbolizes any number of parameters (including none).
You can use their names or sequence numbers preceded by '%' to deter parameters. The numbered parameters are from 1. Parameter number 0 (%0) has a special meaning - a macro has been exported to the number of parameters.
In the macro call with a name, we place commas separated by an express that corresponds to the next parameters. These expressions are interpreted and evaluated by the assembler.
All labels that begin with a period (.) used in the macro definition are local and not externally available. The remaining labels are global. In the drop-down macro definition, you can denote global labels, local program labels, and local macros.
Example of use:
Put: .MACRO chr ; character printing LDA #chr ; thru ‘chr’ JSR sys_put_char .ENDM ; call: Put 'A'
Print: .MACRO ... ; printing .cnt .= 0 ; parameter counter .REPEAT %0 .cnt .= .cnt + 1 .IF .PARAMTYPE(%.cnt) == 2 ; text type parameter? JSR sys_print_text ; .BYTE .STRLEN(%.cnt), %.cnt .ELSE ; numeric parameter -> address LDA #>%.cnt ; older address byte LDX #<%.cnt ; JSR sys_print .ENDIF .ENDR .ENDM