SlideShare a Scribd company logo
1 of 6
Download to read offline
System Programming
Walchand Institute of Technology
Aim:
Design & implementation of
Theory:
Two pass translation
Two pass translation of an assembly language program can handle forward
references easily. LC processing is performed in the first pass and symbols defined
in the program are entered into the symbol table. The second pass synthesizes the
target form using the address information found in the symbol table. In effect, the
second pass performs synthesis of the target program. The first pass constructs an
intermediate representation of the source program for use by the second pass as
shown in figure. This repre
structures, e.g. the symbol table, and a processed form of the source program. The
latter component is called intermediate code.
Figure: Overview of two pass assembly
Tasks performed by the passes of a two
• Pass I:
1. Separate the symbol, mnemonic, opcode and operand.
Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur
HANDOUT#07
Design & implementation of pass 2 of two pass assembler
Two pass translation of an assembly language program can handle forward
references easily. LC processing is performed in the first pass and symbols defined
in the program are entered into the symbol table. The second pass synthesizes the
the address information found in the symbol table. In effect, the
pass performs synthesis of the target program. The first pass constructs an
intermediate representation of the source program for use by the second pass as
shown in figure. This representation consists of two main components
structures, e.g. the symbol table, and a processed form of the source program. The
latter component is called intermediate code.
Figure: Overview of two pass assembly
Tasks performed by the passes of a two pass assembler are as follows:
Separate the symbol, mnemonic, opcode and operand.
Sunita M. Dol, CSE Dept
Page 1
Two pass translation of an assembly language program can handle forward
references easily. LC processing is performed in the first pass and symbols defined
in the program are entered into the symbol table. The second pass synthesizes the
the address information found in the symbol table. In effect, the
pass performs synthesis of the target program. The first pass constructs an
intermediate representation of the source program for use by the second pass as
sentation consists of two main components—data
structures, e.g. the symbol table, and a processed form of the source program. The
pass assembler are as follows:
Separate the symbol, mnemonic, opcode and operand.
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 2
2. Build Symbol Table.
3. Perform LC Processing.
4. Construct Intermediate Representation.
• Pass II:
1. Process IR to synthesize the target program.
Pass I performs analysis of the source program and the synthesis of the
intermediate representation while Pass II processes the intermediate representation
to synthesize the target program.
Following algorithm is the algorithm for assembler Pass II
Algorithm for Pass II
1. code_area_address := address of code area
pooltable_ptr := 1
location_counter := 0
2. While next statement is not an end statement then
a. Clear machine_code_buffer
b. If an LTORG statement then
i. Process literals in LITTAB[POOLTAB[pooltable_ptr]]……..
LITTAB[POOLTAB[pooltable_ptr + 1] -1 similarly
processing of constants in a DC statement i.e. assemble the
literals in machine_code_buffer.
ii. size := size of memory area required for literals
iii. pooltable_ptr := polltable_ptr +1
c. if a START or ORIGIN statement then
i. location_counter := value specified in operand field
ii. size := 0
d. If a declaration statement then
i. If a DC statement then
Assemble the constant in machine_code_buffer
ii. size := size of memory area required by DC or DS
e. If an imperative statement then
System Programming
Walchand Institute of Technology
i. Get the
ii. Assemble instruction in machine_code_buffer
iii. size := size of instruction
f. If size <> 0 then
i. Move the contents of machine_code_buffer to the address
code_area_address + location_counter
ii. location_counter :=
3. Processing end statement
a. Perform steps 2(b) and 2(f)
b. Write code_area into output file
Figure: Example of converting source program to machine language
Input:
0 (AD, 01) (C, 200)
Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur
Get the operand address from SYMTAB or LITTAB
Assemble instruction in machine_code_buffer
size := size of instruction
If size <> 0 then
Move the contents of machine_code_buffer to the address
code_area_address + location_counter
location_counter := location_counter +size
Processing end statement
Perform steps 2(b) and 2(f)
Write code_area into output file
Figure: Example of converting source program to machine language
(AD, 01) (C, 200)
Sunita M. Dol, CSE Dept
Page 3
operand address from SYMTAB or LITTAB
Assemble instruction in machine_code_buffer
Move the contents of machine_code_buffer to the address
location_counter +size
Figure: Example of converting source program to machine language
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 4
200 (IS, 04) (1) (L, 00)
201 (IS, 05) (1) (S, 00)
202 (IS, 04) (1) (S, 00)
203 (IS, 04) (3) (S, 02)
204 (IS, 01) (3) (L, 01)
205 (IS, 07) (6) (S, 03)
206 (AD, 05)
(L, 00)
(L, 01)
208 (IS, 02) (1) (L, 02)
209 (IS, 07) (1) (S, 04)
210 (IS, 00)
210 (AD, 03) (S, 01) + (C, 2)
204 (IS, 03) (3) (S, 02)
205 (AD, 03) (S, 05) + (C, 1)
211 (DL, 02) (C, 1)
212 (AD, 04) (S, 01)
212 (DL, 02) (C, 2)
214 (AD, 02)
(L, 02)
215
Output:
Intermediate Representation
0 (AD, 01) (C, 200)
200 (IS, 04) (1) (L, 00)
201 (IS, 05) (1) (S, 00)
202 (IS, 04) (1) (S, 00)
203 (IS, 04) (3) (S, 02)
204 (IS, 01) (3) (L, 01)
205 (IS, 07) (6) (S, 03)
206 (AD, 05)
(L, 00)
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 5
(L, 01)
208 (IS, 02) (1) (L, 02)
209 (IS, 07) (1) (S, 04)
210 (IS, 00)
210 (AD, 03) (S, 01) + (C, 2)
204 (IS, 03) (3) (S, 02)
205 (AD, 03) (S, 05) + (C, 1)
211 (DL, 02) (C, 1)
212 (AD, 04) (S, 01)
212 (DL, 02) (C, 2)
214 (AD, 02)
(L, 02)
215
The target code
200) 04 1 206
201) 05 1 211
202) 04 1 211
203) 04 3 212
204) 01 3 207
205) 07 6 208
206) 00 0 005
207) 00 0 001
208) 02 1 214
209) 07 1 202
210) 00 0 000
204) 03 3 212
211)
212)
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 6
214) 00 0 001
Conclusion:
The second pass or Pass-II synthesizes the target form using the address
information found in the symbol table.
The second pass performs synthesis of the target program.
Pass I performs analysis of the source program and the synthesis of the
intermediate representation while Pass II processes the intermediate
representation to synthesize the target program.
Thus the Pass-II of two pass assembler is implemented in C-language

More Related Content

What's hot (20)

Handout#10
Handout#10Handout#10
Handout#10
 
Handout#03
Handout#03Handout#03
Handout#03
 
Handout#12
Handout#12Handout#12
Handout#12
 
Handout#09
Handout#09Handout#09
Handout#09
 
Assignment4
Assignment4Assignment4
Assignment4
 
Handout#01
Handout#01Handout#01
Handout#01
 
Chapter2
Chapter2Chapter2
Chapter2
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
 
C notes
C notesC notes
C notes
 
Chap02
Chap02Chap02
Chap02
 
Introduction of C++ By Pawan Thakur
Introduction of C++ By Pawan ThakurIntroduction of C++ By Pawan Thakur
Introduction of C++ By Pawan Thakur
 
C LANGUAGE NOTES
C LANGUAGE NOTESC LANGUAGE NOTES
C LANGUAGE NOTES
 
C programming languag for cse students
C programming languag for cse studentsC programming languag for cse students
C programming languag for cse students
 
Uniti classnotes
Uniti classnotesUniti classnotes
Uniti classnotes
 
Solutions manual for c++ programming from problem analysis to program design ...
Solutions manual for c++ programming from problem analysis to program design ...Solutions manual for c++ programming from problem analysis to program design ...
Solutions manual for c++ programming from problem analysis to program design ...
 
Programming in c
Programming in cProgramming in c
Programming in c
 
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
C notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit orderC notes by m v b  reddy(gitam)imp  notes  all units notes  5 unit order
C notes by m v b reddy(gitam)imp notes all units notes 5 unit order
 
C language
C languageC language
C language
 
best notes in c language
best notes in c languagebest notes in c language
best notes in c language
 
Operators and Expressions in C#
Operators and Expressions in C#Operators and Expressions in C#
Operators and Expressions in C#
 

Similar to Design & implementation of pass 2 of two pass assembler

Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programmingMakerere university
 
System programmin practical file
System programmin practical fileSystem programmin practical file
System programmin practical fileAnkit Dixit
 
Compiler gate question key
Compiler gate question keyCompiler gate question key
Compiler gate question keyArthyR3
 
B.sc cs-ii-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed controlB.sc cs-ii-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed controlRai University
 
The process of programming
 The process of programming The process of programming
The process of programmingKopi Maheswaran
 
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed controlBca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed controlRai University
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03desta_gebre
 
loaders-and-linkers.pdfhhhhhccftyghgfggy
loaders-and-linkers.pdfhhhhhccftyghgfggyloaders-and-linkers.pdfhhhhhccftyghgfggy
loaders-and-linkers.pdfhhhhhccftyghgfggyrahulyadav957181
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in detailskazi_aihtesham
 
basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed controlRai University
 
Mca i-u-3-basic computer programming and micro programmed control
Mca i-u-3-basic computer programming and micro programmed controlMca i-u-3-basic computer programming and micro programmed control
Mca i-u-3-basic computer programming and micro programmed controlRai University
 
Assembler - System Programming
Assembler - System ProgrammingAssembler - System Programming
Assembler - System ProgrammingRadhika Talaviya
 
assembler_full_slides.ppt
assembler_full_slides.pptassembler_full_slides.ppt
assembler_full_slides.pptAshwini864432
 

Similar to Design & implementation of pass 2 of two pass assembler (20)

assembler-ppt.pdf
assembler-ppt.pdfassembler-ppt.pdf
assembler-ppt.pdf
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programming
 
First pass of assembler
First pass of assemblerFirst pass of assembler
First pass of assembler
 
Assembler
AssemblerAssembler
Assembler
 
System programmin practical file
System programmin practical fileSystem programmin practical file
System programmin practical file
 
Compiler gate question key
Compiler gate question keyCompiler gate question key
Compiler gate question key
 
B.sc cs-ii-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed controlB.sc cs-ii-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed control
 
Assembler
AssemblerAssembler
Assembler
 
Assembler
AssemblerAssembler
Assembler
 
The process of programming
 The process of programming The process of programming
The process of programming
 
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed controlBca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
 
loaders-and-linkers.pdfhhhhhccftyghgfggy
loaders-and-linkers.pdfhhhhhccftyghgfggyloaders-and-linkers.pdfhhhhhccftyghgfggy
loaders-and-linkers.pdfhhhhhccftyghgfggy
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
 
basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed control
 
Mca i-u-3-basic computer programming and micro programmed control
Mca i-u-3-basic computer programming and micro programmed controlMca i-u-3-basic computer programming and micro programmed control
Mca i-u-3-basic computer programming and micro programmed control
 
Assembler - System Programming
Assembler - System ProgrammingAssembler - System Programming
Assembler - System Programming
 
Assembler
AssemblerAssembler
Assembler
 
assembler_full_slides.ppt
assembler_full_slides.pptassembler_full_slides.ppt
assembler_full_slides.ppt
 

More from Sunita Milind Dol (18)

9.Joins.pdf
9.Joins.pdf9.Joins.pdf
9.Joins.pdf
 
8.Views.pdf
8.Views.pdf8.Views.pdf
8.Views.pdf
 
7. Nested Subqueries.pdf
7. Nested Subqueries.pdf7. Nested Subqueries.pdf
7. Nested Subqueries.pdf
 
6. Aggregate Functions.pdf
6. Aggregate Functions.pdf6. Aggregate Functions.pdf
6. Aggregate Functions.pdf
 
5. Basic Structure of SQL Queries.pdf
5. Basic Structure of SQL Queries.pdf5. Basic Structure of SQL Queries.pdf
5. Basic Structure of SQL Queries.pdf
 
4. DML.pdf
4. DML.pdf4. DML.pdf
4. DML.pdf
 
3. DDL.pdf
3. DDL.pdf3. DDL.pdf
3. DDL.pdf
 
2. SQL Introduction.pdf
2. SQL Introduction.pdf2. SQL Introduction.pdf
2. SQL Introduction.pdf
 
1. University Example.pdf
1. University Example.pdf1. University Example.pdf
1. University Example.pdf
 
Assignment12
Assignment12Assignment12
Assignment12
 
Assignment10
Assignment10Assignment10
Assignment10
 
Assignment9
Assignment9Assignment9
Assignment9
 
Assignment8
Assignment8Assignment8
Assignment8
 
Assignment7
Assignment7Assignment7
Assignment7
 
Assignment6
Assignment6Assignment6
Assignment6
 
Assignment5
Assignment5Assignment5
Assignment5
 
Assignment3
Assignment3Assignment3
Assignment3
 
Assignment2
Assignment2Assignment2
Assignment2
 

Recently uploaded

Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 

Design & implementation of pass 2 of two pass assembler

  • 1. System Programming Walchand Institute of Technology Aim: Design & implementation of Theory: Two pass translation Two pass translation of an assembly language program can handle forward references easily. LC processing is performed in the first pass and symbols defined in the program are entered into the symbol table. The second pass synthesizes the target form using the address information found in the symbol table. In effect, the second pass performs synthesis of the target program. The first pass constructs an intermediate representation of the source program for use by the second pass as shown in figure. This repre structures, e.g. the symbol table, and a processed form of the source program. The latter component is called intermediate code. Figure: Overview of two pass assembly Tasks performed by the passes of a two • Pass I: 1. Separate the symbol, mnemonic, opcode and operand. Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur HANDOUT#07 Design & implementation of pass 2 of two pass assembler Two pass translation of an assembly language program can handle forward references easily. LC processing is performed in the first pass and symbols defined in the program are entered into the symbol table. The second pass synthesizes the the address information found in the symbol table. In effect, the pass performs synthesis of the target program. The first pass constructs an intermediate representation of the source program for use by the second pass as shown in figure. This representation consists of two main components structures, e.g. the symbol table, and a processed form of the source program. The latter component is called intermediate code. Figure: Overview of two pass assembly Tasks performed by the passes of a two pass assembler are as follows: Separate the symbol, mnemonic, opcode and operand. Sunita M. Dol, CSE Dept Page 1 Two pass translation of an assembly language program can handle forward references easily. LC processing is performed in the first pass and symbols defined in the program are entered into the symbol table. The second pass synthesizes the the address information found in the symbol table. In effect, the pass performs synthesis of the target program. The first pass constructs an intermediate representation of the source program for use by the second pass as sentation consists of two main components—data structures, e.g. the symbol table, and a processed form of the source program. The pass assembler are as follows: Separate the symbol, mnemonic, opcode and operand.
  • 2. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 2 2. Build Symbol Table. 3. Perform LC Processing. 4. Construct Intermediate Representation. • Pass II: 1. Process IR to synthesize the target program. Pass I performs analysis of the source program and the synthesis of the intermediate representation while Pass II processes the intermediate representation to synthesize the target program. Following algorithm is the algorithm for assembler Pass II Algorithm for Pass II 1. code_area_address := address of code area pooltable_ptr := 1 location_counter := 0 2. While next statement is not an end statement then a. Clear machine_code_buffer b. If an LTORG statement then i. Process literals in LITTAB[POOLTAB[pooltable_ptr]]…….. LITTAB[POOLTAB[pooltable_ptr + 1] -1 similarly processing of constants in a DC statement i.e. assemble the literals in machine_code_buffer. ii. size := size of memory area required for literals iii. pooltable_ptr := polltable_ptr +1 c. if a START or ORIGIN statement then i. location_counter := value specified in operand field ii. size := 0 d. If a declaration statement then i. If a DC statement then Assemble the constant in machine_code_buffer ii. size := size of memory area required by DC or DS e. If an imperative statement then
  • 3. System Programming Walchand Institute of Technology i. Get the ii. Assemble instruction in machine_code_buffer iii. size := size of instruction f. If size <> 0 then i. Move the contents of machine_code_buffer to the address code_area_address + location_counter ii. location_counter := 3. Processing end statement a. Perform steps 2(b) and 2(f) b. Write code_area into output file Figure: Example of converting source program to machine language Input: 0 (AD, 01) (C, 200) Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Get the operand address from SYMTAB or LITTAB Assemble instruction in machine_code_buffer size := size of instruction If size <> 0 then Move the contents of machine_code_buffer to the address code_area_address + location_counter location_counter := location_counter +size Processing end statement Perform steps 2(b) and 2(f) Write code_area into output file Figure: Example of converting source program to machine language (AD, 01) (C, 200) Sunita M. Dol, CSE Dept Page 3 operand address from SYMTAB or LITTAB Assemble instruction in machine_code_buffer Move the contents of machine_code_buffer to the address location_counter +size Figure: Example of converting source program to machine language
  • 4. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 4 200 (IS, 04) (1) (L, 00) 201 (IS, 05) (1) (S, 00) 202 (IS, 04) (1) (S, 00) 203 (IS, 04) (3) (S, 02) 204 (IS, 01) (3) (L, 01) 205 (IS, 07) (6) (S, 03) 206 (AD, 05) (L, 00) (L, 01) 208 (IS, 02) (1) (L, 02) 209 (IS, 07) (1) (S, 04) 210 (IS, 00) 210 (AD, 03) (S, 01) + (C, 2) 204 (IS, 03) (3) (S, 02) 205 (AD, 03) (S, 05) + (C, 1) 211 (DL, 02) (C, 1) 212 (AD, 04) (S, 01) 212 (DL, 02) (C, 2) 214 (AD, 02) (L, 02) 215 Output: Intermediate Representation 0 (AD, 01) (C, 200) 200 (IS, 04) (1) (L, 00) 201 (IS, 05) (1) (S, 00) 202 (IS, 04) (1) (S, 00) 203 (IS, 04) (3) (S, 02) 204 (IS, 01) (3) (L, 01) 205 (IS, 07) (6) (S, 03) 206 (AD, 05) (L, 00)
  • 5. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 5 (L, 01) 208 (IS, 02) (1) (L, 02) 209 (IS, 07) (1) (S, 04) 210 (IS, 00) 210 (AD, 03) (S, 01) + (C, 2) 204 (IS, 03) (3) (S, 02) 205 (AD, 03) (S, 05) + (C, 1) 211 (DL, 02) (C, 1) 212 (AD, 04) (S, 01) 212 (DL, 02) (C, 2) 214 (AD, 02) (L, 02) 215 The target code 200) 04 1 206 201) 05 1 211 202) 04 1 211 203) 04 3 212 204) 01 3 207 205) 07 6 208 206) 00 0 005 207) 00 0 001 208) 02 1 214 209) 07 1 202 210) 00 0 000 204) 03 3 212 211) 212)
  • 6. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 6 214) 00 0 001 Conclusion: The second pass or Pass-II synthesizes the target form using the address information found in the symbol table. The second pass performs synthesis of the target program. Pass I performs analysis of the source program and the synthesis of the intermediate representation while Pass II processes the intermediate representation to synthesize the target program. Thus the Pass-II of two pass assembler is implemented in C-language