Download M68ICS08GP

Transcript
CASM08W Assembler Interface
Assembler Directives
5.7.5 MACRO
A macro is a named block of text to be assembled. Similar in some ways to an
included file, the macro allows labels and parameter values.
The MACRO directive begins the macro definition. The name of the macro is
the parameter value for the MACRO directive. All subsequent code, until the
assembler encounters the MACROEND directive, is considered the macro
definition.
Assembler directives may not be used within a macro, nor does the definition
require parameter names. Instead, the macro definition includes the sequential
indicators %n for the nth parameter values of the macro call. The assembler will
ignore parameter values on the MACRO directive line, so such values may be
helpful for internal documentation.
Example:
This macro example illustrates a macro that divides the accumulator value
by 4:
$MACRO divide_by_4
asr a
asr a
$MACROEND
;starts macro definition
;divides accumulator by 2
;divides quotient by 2
;ends macro definition
This macro example illustrates a macro that creates a time delay:
$MACRO delay
loop:
count
ldaa #$01
deca
bne loop
$MACROEND
In this macro, the CASM08W assembler ignores the parameter count on the
MACRO directive line. The parameter count merely indicates the role of the
parameter value passed to the macro. That value is substituted for the sequential
indicator %1. The first time this macro is called, the CASM08W assembler
changes the label loop, on lines 3 and 4, to loop:0001. If the calling line
delay 100t
invokes this macro, the loop would occur 100 times. The suffix t represents the
decimal base.
M68ICS08GP In-Circuit Simulator — Rev. 1.0
MOTOROLA
CASM08W Assembler Interface
Operator’s Manual
103