Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
8 views
SPOS Lab Assignment 2
SPOS
Uploaded by
pamate1130
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save SPOS Lab Assignment 2 (1) For Later
Download
Save
Save SPOS Lab Assignment 2 (1) For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
8 views
SPOS Lab Assignment 2
SPOS
Uploaded by
pamate1130
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save SPOS Lab Assignment 2 (1) For Later
Carousel Previous
Carousel Next
Save
Save SPOS Lab Assignment 2 (1) For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 8
Search
Fullscreen
Aim: Design suitable data structures and implement pass-I of a two-pass macro-processor using OOP features in Java. The output of Pass-I (MNT, MDT and file without any macro definitions) should be input for Pass-IL. Objectives: - To Identify and create the data structures required in the design of macro processor. - To Learn parameter processing in macro = To implement pass IT of macroprocessor Problem Statement: Write a program to create pass-I Macro-processor Outcomes: After completion of this assignment students will be able to: - Understand the Programming language of Java - Understand the concept of Pass-I Macro-processor Software Requirements: Windows OS, JDK1.7 Theory Concepts: MACRO: * Macro allows a sequence of source language code to be defined once & then referred to by name each time itis to be referred. *| Macro, Assembler Preprocessor ‘Macro with macro Definitions and Target program Macro calls Program without macros Macro Preprocessor Macro preprocessor is system software. It is actually a program, which is a part of the assembler program. A macro preprocessor accepts an assembly level program containing macro definitions and calls and translate it into an assembly program which does not contain any macro definition and macro call. Each time this name occurs is a program the sequence of codes is substituted at that point. A macro consist of 1. Name of the macro 2. Set of parameters 3. Body of macro * Macros are typically defined at the start of program, Macro definition consists of 1.MACRO Start 2.MACRO name 3.Sequence of statements(MACRO Body)4.MEND End ‘+ A macro is called by writing the macro name with actual parameter is an assembly program, The macro call has following syntax .
{
] * Macro processor takes a source program containing macro definition & macro calls and translates into an assembly language program without any macro definition or calls. © This program can now be handled over to a conventional assembler to obtain the target language. MACRO DEINITION:- '* Macros are typically defined at the start of a program. + A macro definition consists of 1. MACRO pseudo code 2. MACRO name 3. Sequence of statement 4. MEND pseudo opcode terminating macro definition Structure of a macto Macro instruction definition MACRO ‘start of definition INCR macro name } Sequence to be abbreviated MEND Pend of definition «Example MACRO INCR & ARG ADD AREG,& ARG ADD BRA,& ARG ADD CREG, & ARG MEND MACRO CALL:- Syntax of macro call
{
] MACRO Expansio ‘© During macro expansion each statement forming the body of the macro as picked up one by one sequentially. a. Each statement inside macro may have as it is during expansion. b. The name of a formal parameter which is preceded by the character ‘&’ during macro expansion an ordinary starting is retained without any modification. Formal parameters are replaced by actual parameters value. © When a call is found the call processor sets a pointer the macro definition table pointer to the corresponding macro definition started in MDT. The initial value of MDT is obtained from MDT index.Design of macro processor:~ Pass I: Generate Macro Name Table (MNT) Generate Macro Definition Table (MDT) Generate IC i.e. a copy of source code without macro definitions MNT: eNO ‘Macro Name MDT index MDT: SuNo | MACRO STATEMENT ALA: Tradex] Argument ‘Specification of Database © Pass I data bases 1. The input macro source desk. 2. The output macro source desk copy for use by passes 2. 3. The macro definition table (MDT) used to store the names of defined macros. 4, Macro name table (MDT) used to stare the name of defined macros 5. The Macro definition table counter used to indicate the next available entry in MNT. 6. The macro name table counter counter(MNTC) used to indicate next available entry in MNT. 7. The arguments list array (ALA) used to substitute index markers for dummy arguments before starting a macro definition. Pass II: Replace every occurrence of macro call with macro definition. (Expanded Code) «There are four basic tasks that any macro instruction process must perform: 1, Recognize macro definition: A macro instruction processor must recognize macro definition identified by the MACRO and MEND pseudo-ops. This tasks can be complicated when macro definition appears within macros. When MACROs and MENDs are nested, as the macro processor must recognize the nesting and correctly match the last or or outerMEND with first MACRO. All intervening text, including nested MACROs and MENDs defines a single macto instruction Save the definition: The processor must store the macro instruction definition, which it will need for expanding macro calls. 3. Recognize calls: The processor must recognize the macro calls that appear as operation mnemonics. This suggests that macro names be handled as a type of op-code. 4, Expand calls and substitute arguments: The processor must substitute for dummy or macro definition arguments the corresponding arguments from a macro call; the resulting symbolic text is then substitute for macro call. This text may contain additional macro definition or call. Specification of Database © Pass 2 database: 1. The copy of the input source deck obtained from Pass- I 2. The output expanded source deck to be used as input to the assembler 3. The Macro Definition Table (MDT), created by pass 1 4. The Macro Name Table (MNT), created by pass 1 5. The Macro Definition Table Counter (MNTC), used to indicate the next line of text to be used during macro expansion 6. The Argument List Array (ALA), used to substitute macro call arguments for the index markers in stored macro definition Eg:- Consider the following Macro definition and the tables constructed in pass I for this macro MACRO &LAB INCR — &ARG1,8,ARG2,&ARG3 &LAB MoT ADD 1,&ARG1 ADD 2,8ARG2 ADD 3,BARG3 Index Macro MDT Index Name T INCR T Index Label Instruction | operands ‘ADD 1 ‘ADD 1.42 T #0 2 3 (4 venaALA ‘Argument Dummy name &Lab #0 &Argl a &Arg? 2 &Arg3 B Steps to follow:- 1.Read the ALP word by word using fgete. 2.1 keyword MACRO is found then * Store the arguments in ALA in sequence(0" argument for a label), + Store all the instructions in MDT using dummy names of the arguments(prepared in ALA). + Store the MDT index in a variable temp. + Store name of macro and its MDT index using temp in MNT. 3. Write all the tables onto a file (as these will be required in pass 11) 4.Go to Pass 1 The task of pass II is macro expansion i.e deal with macro calls. For this we use the tables created in pass I of a macto-processor. Whenever a call to a macro is found for eg: LOOP INCR Datal,Data2,Data3 (with respect to the macro definition INCR in previous assignment) Then this call should lead to a macro expansion as follows:- LOOP: ADD 1, Datal ADD 2, Data2 ADD 3, Data3 Here the formal parameters are repla ed by actual parameters. For this ALA has to be updated with new parameter names. ALA ‘Argument ‘Actual Parameters #0 LOOP a Datal @ Data B Data3 Using these values we expand the macro with the help of MNT and MDT.Steps to follow:- 1.Read the source program. 2.1 an macro name is encounterd it means there is a call to the macro so do the following. ‘+ Search for the macro in the MNT. ‘+ Extract its MDT index and go to that index position in MDT. + Update ALA with actual parameters. 3.Read from MDT and replace dummy parameters with actual parameters. 4, Do step 3 till end of macro. PASS-1 Algorithm + Pass] of macro processor makes a line-by-line sean over its input. + Set MDTC = | as well as MNTC = 1 + Read next line from input program, + If it is a MACRO pscudo-op, the entire macro definition except this (MACRO) line is stored in MDT. + The name is entered into Macro Name Table along with a pointer to the first location of MDT entry of the definition. + When the END pseudo-op is encountered all the macro-definitions have been processed, so control is transfered to pass2 PASS-2 Algorithm + This algorithm reads one line of input program at a time. * for each Line it checks if op-code of that line matches any of the MNT entry. + When match is found (i.c. when call is pointer called MDTF to corresponding macro definitions stored in MDT. + The initial value of MDTP is obtained from MDT index field of MNT entry. “The macro expander prepares the ALA consisting of a table of dummy argument indices & corresponding arguments to the call. “Reading proceeds from the MDT, as each successive line is read, The valves form the argument list one substituted for dummy arguments indices in the macro definition. * Reading MEND line in MDT terminates expansion of macro & scanning continues from the input file + When END pseudo-op encountered , the expanded source program is given to the assembler.: >Conclusion: Thus, we have studied and implemented Pass-I and Pass-II of Macro Processor.
You might also like
Two Pass Macroprocessor
PDF
73% (11)
Two Pass Macroprocessor
10 pages
Exp 9 SPCC
PDF
No ratings yet
Exp 9 SPCC
14 pages
SPCC Exp 4
PDF
No ratings yet
SPCC Exp 4
9 pages
UNIT-II_SAB
PDF
No ratings yet
UNIT-II_SAB
73 pages
SPOS Unit 2
PDF
No ratings yet
SPOS Unit 2
67 pages
EXP3SPCC
PDF
No ratings yet
EXP3SPCC
9 pages
Macro 1
PDF
100% (1)
Macro 1
8 pages
Unit 2 Notes and PPTs PDF
PDF
No ratings yet
Unit 2 Notes and PPTs PDF
153 pages
3.macro Processor2016
PDF
No ratings yet
3.macro Processor2016
51 pages
Synopsis Macro
PDF
No ratings yet
Synopsis Macro
4 pages
Macro Macro Processor PDF
PDF
No ratings yet
Macro Macro Processor PDF
53 pages
SS Macro
PDF
No ratings yet
SS Macro
87 pages
Unit Iv
PDF
No ratings yet
Unit Iv
78 pages
Macro PDF
PDF
No ratings yet
Macro PDF
38 pages
Macro Processors: Unit - Iv
PDF
No ratings yet
Macro Processors: Unit - Iv
87 pages
Experiment No. Experiment Name
PDF
No ratings yet
Experiment No. Experiment Name
4 pages
Unit 3 Macros2
PDF
No ratings yet
Unit 3 Macros2
26 pages
UNIT3_CH-1_Macros
PDF
No ratings yet
UNIT3_CH-1_Macros
23 pages
System-Software Unit IV
PDF
100% (8)
System-Software Unit IV
9 pages
Ooad Notes
PDF
No ratings yet
Ooad Notes
23 pages
Macros
PDF
No ratings yet
Macros
35 pages
SPCC Exp2
PDF
No ratings yet
SPCC Exp2
6 pages
Macro Processor
PDF
No ratings yet
Macro Processor
53 pages
Macro_Preprocessor
PDF
No ratings yet
Macro_Preprocessor
75 pages
Macro Preprocessor Part 1
PDF
No ratings yet
Macro Preprocessor Part 1
33 pages
Macro Processor-notes
PDF
No ratings yet
Macro Processor-notes
41 pages
Unit IV System Software
PDF
No ratings yet
Unit IV System Software
10 pages
Module 5
PDF
No ratings yet
Module 5
65 pages
System Programming Lab Manual
PDF
No ratings yet
System Programming Lab Manual
52 pages
ch4 Macro
PDF
No ratings yet
ch4 Macro
53 pages
Macro Processor
PDF
No ratings yet
Macro Processor
55 pages
Macro Processors Chap4
PDF
No ratings yet
Macro Processors Chap4
11 pages
School of CET System Software and Compiler Lab Assignment No.3
PDF
No ratings yet
School of CET System Software and Compiler Lab Assignment No.3
3 pages
LP
PDF
No ratings yet
LP
18 pages
MACRO and ASM-DIRECTIVES (Unit4spmacro-170906062957 PDF
PDF
No ratings yet
MACRO and ASM-DIRECTIVES (Unit4spmacro-170906062957 PDF
62 pages
Systems Programming Notes
PDF
No ratings yet
Systems Programming Notes
62 pages
Sp_Unit 2_ Macro Peocessor_MRD
PDF
No ratings yet
Sp_Unit 2_ Macro Peocessor_MRD
36 pages
Assignment No. A2
PDF
No ratings yet
Assignment No. A2
5 pages
SS Chapter 05
PDF
No ratings yet
SS Chapter 05
53 pages
Macro Preprocessors m5
PDF
No ratings yet
Macro Preprocessors m5
53 pages
UNIT IV Macro Processor
PDF
No ratings yet
UNIT IV Macro Processor
14 pages
Spos - Unit 2
PDF
No ratings yet
Spos - Unit 2
178 pages
System Software Module
PDF
No ratings yet
System Software Module
37 pages
macro processor -class
PDF
No ratings yet
macro processor -class
28 pages
Macro Part1
PDF
No ratings yet
Macro Part1
32 pages
Chapter 4
PDF
No ratings yet
Chapter 4
41 pages
SS Macro Processor
PDF
No ratings yet
SS Macro Processor
24 pages
Chapter Four
PDF
No ratings yet
Chapter Four
30 pages
Macro Processor: (Type Text)
PDF
No ratings yet
Macro Processor: (Type Text)
25 pages
System Software: Dr. Manish Khare Macro Processors
PDF
No ratings yet
System Software: Dr. Manish Khare Macro Processors
33 pages
SP Unit2 RNP
PDF
No ratings yet
SP Unit2 RNP
103 pages
Macro Processor
PDF
100% (2)
Macro Processor
22 pages
SP 11
PDF
No ratings yet
SP 11
50 pages
CH4 - MACROPROCESSORS
PDF
No ratings yet
CH4 - MACROPROCESSORS
18 pages
Ch6 Macro Processors
PDF
No ratings yet
Ch6 Macro Processors
4 pages
Macroprocessor New
PDF
No ratings yet
Macroprocessor New
61 pages
SPOS-Unit 1
PDF
No ratings yet
SPOS-Unit 1
62 pages
Dbms - SQL and PLSQL
PDF
No ratings yet
Dbms - SQL and PLSQL
39 pages
Writeup 12 - Heap Sort
PDF
No ratings yet
Writeup 12 - Heap Sort
3 pages
TOC Que2
PDF
No ratings yet
TOC Que2
2 pages