Lab Manual –Systems Programming & Operating Systems Lab Dept.
of Computer Engineering
ASSIGNMENT NO.04
TITLE: IMPLEMENTATION OF PASS – II OF TWO PASS
MACRO-PROCESSOR
PROBLEM STATEMENT: Write a Java program for pass-II of a two-pass macro-processor.
OBJECTIVES:
• To understand macro facility, features and its use in assembly language programming.
• To study how the macro definition is processed and how macro call results in the expansion
of code.
SOFTWARE & HARDWARE REQUIREMENTS:
1. 64-bit Open source Linux or its derivative
2. Eclipse
3. JDK
THEORY:
Macro Pass – II (Macro Calls & Expansion)
The algorithm for Pass- II tests mnemonic of each line to see if it is a name in the MNT.
When a call is found, the call processor sets a pointer, the Macro Definition Table Pointer
(MDTP), to the corresponding macro definition stored in MDT.
The initial value of MDT is obtained from the “MDT index” field of the MNT entry.
The macro expander prepares the Argument List Array (ALA) consisting of a table of dummy
argument indices and corresponding arguments to the call.
As each successive line is read, the values from the argument list are substituted for dummy
argument indices in the macro definition. Reading of the MEND line in the MDT terminates
expansion of the macro, and scanning continues from the input file. When the END is
encountered, the expanded source program is transferred to the assembler for further
processing.
Macro Processor Pass – II Data Structures
1. The input file (Output of Pass - I)
2. The output file (To store Target Program)
3. The Macro Definition Table (MDT), created by Pass – I
4. The Macro Name Table (MNT), created by Pass – I
5. The Macro Definition Table Pointer (MDTP), used to indicate the next line of text to be used
during macro expansion
International Institute of Information Technology, Hinjawadi, Pune. Page 1
Lab Manual –Systems Programming & Operating Systems Lab Dept. of Computer Engineering
6. The Argument List Array (ALA), used to substitute macro call arguments for the index
markers in the stored macro definition
PASS II Output
CONCLUSION:
International Institute of Information Technology, Hinjawadi, Pune. Page 2
Lab Manual –Systems Programming & Operating Systems Lab Dept. of Computer Engineering
FAQs
1. What is meant by macro time variable?
2. What are the three main data structures used by our macro processor?
3. How many parameters can a macro have?
4. What is the difference between attributes of symbols and of macro arguments?
5. What should be printed in the object code field when a macro definition is listed?
International Institute of Information Technology, Hinjawadi, Pune. Page 3