Macro Processor Design Options
Recursive Macro Expansion [ Macro Processor Design Options ]
For an efficient preprocessing and expansion, preprocessors use a language that supports recursion and allow the use of variables and data structure for recursive expansions. The support for handling global expansion variables together with local variables is highly desirable.
General-purpose Macro Processors [ Macro Processor Design Options ]
Modern macro processors are more generic and not restricted to any specific language Facilities to call and process them are possible with macro languages. Although most macro is used in assembler language, they are used with higher-level languages as well and need to learn a different macro language for programming macros. Although desirable, yet such type of general macro facility is hard since each language follows its own way of doing tasks.
Macro Processing within Language Translators [ Macro Processor Design Options ]
It is essential that all macro definitions be processed, symbols are resolved, and calls be explained before a program is sent to language translators such as assemblers. Therefore, macro processing must be a preprocessing step for language assembling. Therefore, integrating macro processing within translation activity is highly desirable.
Line-by-Line Macro Processor [ Macro Processor Design Options ]
Design options that avoid making an extra pass over the source program is another interesting aspect to look into. Performing macro processing line by line enables sharing of data structures, utility functions, and procedures, and supporting diagnostic messages. Line-by-line macro processor environment reads source program, processes macro definitions, expands macro call, and finally transfers output lines to translators like assemblers or compilers.
- A self-relocating program is a program which can perform the relocation of its own address sensitive instructions.
- It contains the following two provisions for this purpose:
A table of information concerning the address sensitive instructions exists as a part of the program.
Code to perform the relocation of address sensitive instructions also exists as a part of the program. This called the relocating logic.
- The start address of the relocating logic specified as the execution start address of the program.
- Thus the relocating logic gains control when the program loaded in memory for the execution.
- It uses the load address and the information concerning address sensitive instructions to perform its own relocation.
- Execution control now transferred to the relocated program.
- A self –relocating program can execute in any area of the memory.
- This is very important in time-sharing operating systems where the load address of a program is likely to be different for different executions.