Chapter 7 Type of Source Statements
Macro Control Statements 123
7.5 Macro Control Statements
Macro control statements reduce coding effort by replacing strings coded in source statements with other
strings. This enables low-level assembly language for a program block to be abstracted as a macro
name.
Macros are coded in two formats: macro definitions and macro calls.
A macro definition defines a macro name and macro body. The macro body uses multiple machine lan-
guage instructions to construct a single program process.
A macro call is just a macro name coded as a source statement. The assembler will replace it with all
the machine language instructions coded in the macro body. This process is called macro expansion.
The basic difference between a macro call and a subroutine call is that a macro call actually outputs ma-
chine language instructions as source statements, with arguments used to output different machine lan-
guage instructions for each call.
The example below shows macro control statements.
*macro definition-------------------------------
adr_set macro data, reg
mov reg, A0
mov data, D0
mov D0, (A0)
endm
.
.
.
*macro call-------------------------------------
adr_set data1, reg1
.
.
.
adr_set data2, reg2
.
.
.