0% found this document useful (0 votes)
282 views

School of CET System Software and Compiler Lab Assignment No.3

The document describes the design of Pass 1 of a two-pass macroprocessor, including initializing counters for the macro definition table (MDT) and macro name table (MNT), reading instructions and handling macro definitions by entering data into the MDT, MNT, and argument list array (ALA) structures, and processing all instructions until reaching the end macro (MEND) instruction. The key data structures used are the MDT to store macro instructions, MNT to map macro names to their MDT locations, and ALA to replace dummy arguments with indices.

Uploaded by

utkarsha shirole
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
282 views

School of CET System Software and Compiler Lab Assignment No.3

The document describes the design of Pass 1 of a two-pass macroprocessor, including initializing counters for the macro definition table (MDT) and macro name table (MNT), reading instructions and handling macro definitions by entering data into the MDT, MNT, and argument list array (ALA) structures, and processing all instructions until reaching the end macro (MEND) instruction. The key data structures used are the MDT to store macro instructions, MNT to map macro names to their MDT locations, and ALA to replace dummy arguments with indices.

Uploaded by

utkarsha shirole
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

School of CET

System Software and Compiler lab


Assignment No.3
TY BTech CSE
Assignment Title: Design of Pass 1 of Two Pass Macroprocessor.

Aim: Design suitable data structure & implement pass 1 of Two Pass Macroprocessor.

Objective: Design suitable data structure & implement pass 1 of Two Pass
Macroprocessor. Input should consist of a one macro definition and one macro call and
few assembly language instructions.

Theory:

Write about

1. Description about the macroprocessor.


2. Data structures required for 2 pass macroprocessor.
3. Flowchart for Pass I.

Algorithm for Pass 1:

Step 1: /* Initialization of counters for MDT and MNT * /

Step 2: Read Next Instruction (and divide it into it's various field as label,
mnemonic (opcode arguments).

Step 3: / * Check for macro definition start * /


if opcode = MACRO goto Step 5
else /* this is not macro definition * /
go to step 4.

Step 4: (a) Write copy of instruction to output of Pass-I


(b) Check whether opcode = END or not
(c) if OPCODE "* END goto Step 2
(d) if OPCODE = END goto Pass-2 i.e. End of this algorithm for Pass- I.
Step 5: /* Start of macro definition is identified. Now Pass-I will process
contents of macro definition after pseudo op MACRO to MEND * /
(a) Read Next Instruction.
(*definitely this is macro name instruction therefore as a processing of this
instruction an entry will be made in MNT, ALA will be prepared for this
macro, this macro name instruction will be entered in MDT * /
(b) Enter <macro-name, MDTC> into MNT at MNTC
/* current available rows in MDT and MNT are MDTC and MNTC, so
macro name and it's starting MDT index i.e. current value of
MDTC is entered in MNT at available row i.e. MNTC * /
(c) MNTC ~ MNTC + 1 /* To point next available row in MNT * /
(d) Prepare Argument List Array
/* ALA is partially constructed by Pass-I to assign universal
integer index to dummy arguments * /
(e) Enter macroname instruction in MDT at MDTC.
(1) MDTC ~ MDTC + 1.
/* In step 5, macro name instruction (instruction just after MACRO pseudo op in
macro definition and on this instruction name of the macro and corresponding dummy
arguments are specified) is processed * /

Step 6: /* Process other instructions in macro definition inducing MEND


Instruction * /
(a) Read next card
(b) Substitute Index notations for dummy-arguments.
(c) Enter this instruction (where dummy arguments are replaced by integer
indices) into MDT.
(d) MDTC ~ MDTC + 1
(e) if OPCODE of this instruction is MEND then goto Step 2.
else goto Step 6 a.

The data structures associated with Macro Processor:

Input: Assembly Language Program.

Output:
1. Program without Macro Definition (Pass-I)

2. Macro Definition Table (MDT)


Index MDT- Instruction

3. Macro Name Table (MNT)

Index Macro Name MDT- Index

4. Argument List Array (ALA).


Index Dummy Argument

Conclusion: The function of Pass 1 in a Macro Processor studied.

Platform: Linux (Java)

Conclusion: The function of Pass 1 in assembler are studied along with errors coming in
each pass.

Platform: Linux (JAVA)

You might also like