Design Issues & Features: Macro Processor
The most highlighted key issues of a macro processing design are as follows:
- Flexible data structures and databases: They should maintain several data structures to keep track of locations, nesting structures, values of formal and positional parameters, and other important information concerning the source program.
- Attributes of macro arguments: Macro arguments used for expansion have attributes. These attributes include count, type, length, integer, scaling, and number attributes. Attributes can use to make decisions each time a macro expanded. Note that attributes unknown at the time of macro definition and known only when the macro expanded.
- Default arguments: Many assemblers allow the use of default arguments. This means when the actual argument that binds the formal argument null in a certain expansion, the argument will be bound to default value specified in the definition.
- Numeric values of arguments: Although most macro processors treat arguments normally as strings. Some assemblers, like VAX assembler, optionally allow using the value, rather than the name of the argument.
- Comments in macros: Comments printed with macro definition, but they might or might not be with each expansion. Some comments are meant only for definitions, while some expected in the expanded code.
Design Features of Macro Processor
The features of a macro processor design are as follows:
- Associating macro parameters with their arguments: All macro processors support associating macro parameters by position, name, and numeric position in the argument list.
- Delimiting macro parameters: Macro processors use specially defined characters such as delimiters or a scheme where parameters can delimit in a general way. Characters like ‘;’ and ‘.’ used in many macro processor implementations.
- Directives related to arguments: Modern macro processors support arguments that ease the task of writing sophisticated macros. The directive IF-ELSE-ENDIF helps decide whether an argument blank or not, or whether identical or different arguments used. Design Issues & Features: Macro Processor
- Automatic label generation: Directives like IRP and PRINT provide facilities to work with labels. A pair of IRP directives defines a sequence of lines directing the assembler to repeatedly duplicate and assemble the sequence as many times as determined by a compound parameter. The PRINT directive suppresses listing of macro expansions or turns on such a listing.
- Machine-independent features: They include concatenation of macro parameter generation of unique labels, conditional macro expansion, and keyword macro parameters. Design Issues & Features: Macro Processor