443
edits
-
Changes
no edit summary
==== MACRO ====
:This pseudo-op defines a macro. It should be either preceded or followed by the macro name, then optionally followed by a comma-separated list of formal parameters. The lines of code following the MACRO pseudo-op up to the next ENDM pseudo-op will be stored as the body of the macro. The macro name may subsequently be used in the opcode part of an assembler statement, followed by actual parameters. The text of the body of the macro will be substituted at that point, with any use of the formal parameters substituted with thecorresponding actual parameter. For example:
print MACRO string
999: db string,'$'
When used, this macro will expand to the 3 instructions
in the body of the macro, with the actual parameters substituted for func and arg. Thus print 'hello world' expands to
999: db 'hello world','$'
through as a single argument. This would expand to the following code:
999: db 'hello world',13,10,'$'
ZAS supports two forms of macro declaration for compatibility with older versions of ZAS and other Z80 assemblers. The macro name may be declared either in the labelfield before the MACRO pseudo-op, or in the operand fieldafter the MACRO pseudo-op. Thus these two MACRO declarations are equivalent:
bdos MACRO func,arg
for each expansion of a macro. Any symbols listed after the
LOCAL directive will have a unique assembler-generated symbol substituted for them when the macro is expanded. For
example:
copy MACRO source,dest,count
nocopy: pop bc
(recptr),buf,(recsize) will expand to:
??0001: pop bc
if invoked a second time, the label nocopy would expand to
The REPT pseudo-op defines a temporary macro which is
then expanded a number of times, as determined by its argu-mentargument. For example:
REPT 3