A251 User's Guide
Macro Processor
A macro processor enables you to define and to use macros in your
assembly programs. When you define a macro, you provide text (usually
assembly code) that you want to associate with a macro name. Then,
when you want to include the macro text in your assembly program, you
provide the name of the macro. The assembler replaces the macro name
with the text specified in the macro definition.
Macros provide several advantages when writing assembly
programs.
-
The frequent use of macros can reduce programmer-induced
errors.
A macro allows you to define instruction sequences that are used
repetitively throughout your program. Subsequent use of the macro
faithfully provides the same results each time. A macro reduces the
likelihood of errors introduced in repetitive programming
sequences. Of course, introduction of an error into a macro
definition causes that error to propagate through the program
wherever the macro is used.
-
The scope of symbols used in a macro is limited to that macro.
You need not be concerned about using a previously used symbol
name.
-
Macros are well-suited for creating simple code tables.
Producing tables by hand is both tedious and error-prone.
A macro may be thought of as a subroutine call with the exception
that the code in the subroutine is included in–line at the point of
the macro call. However, macros should not be used to replace
subroutines.
Each invocation of a subroutine requires only the code necessary
to call the subroutine. Each invocation of a macro includes the
assembly code associated with the macro in–line in the assembly
program. This can cause a program's size to grow rapidly if a large
macro is used frequently.
In a static environment, a subroutine is a better choice since
program size can be considerably reduced. But in time-critical,
dynamic programs, macros speed the execution of algorithms or other
frequently-called statements without the penalty of the procedure
calling overhead.
Use the following guidelines when deciding between macros or
subroutines:
-
Subroutines are best when certain procedures are frequently
executed or when the use of memory must be kept to a minimum.
-
Macros are best when maximum processor speed is required and
when the amount of memory consumed is less important.
-
Macros reduce the amount of typing required to enter short,
repetitive blocks of assembly code.
The A251 Macro Assembler provides three different macro
languages:
-
Standard Assembler
Macros are similar to many other macro assemblers. They
allow you to define macros that look like standard assembler
instructions.
-
MPL Macros are compatible
with the Intel ASM-251 Assembler. They allow you to retranslate
existing source files that were initially written for this macro
assembler.
-
C Preprocessor Macros are
compatible with the C preprocessor. They allow you to use the same
include files in your C and assembler source code.
The following table lists the assembler directives that may be
used to enable or disable macro processing.
| Directive |
Standard
Macros |
MPL
Macros |
C Preprocessor
Macros |
| MPL |
|
Enabled |
Disabled |
| MACRO |
Enabled |
|
Enabled |
| NOMPL |
|
Disabled |
Enabled |
| NOMACRO |
Disabled |
Disabled |
Enabled |