SlideShare una empresa de Scribd logo
1 de 7
Descargar para leer sin conexión
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
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
first 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:
• Pass I:
1. Separate the symbol, mnemonic, opcode and operand.
Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur
HANDOUT#06
Design & implementation of pass 1 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
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
first 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
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
target form using the address information found in the symbol table. In effect, the
first 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—data
structures, e.g. the symbol table, and a processed form of the source program. The
Tasks performed by the passes of a two 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.
Pass I uses the following data structures:
OPTAB : A table of machine opcodes and related information
SYMTAB : Symbol table
LITTAB : A table of literals used in the program.
• OPTAB contains the fields mnemonic opcode, class and mnemonic info.
The class indicates whether the opcode corresponds to an IS (Imperative
statement), DL(Declaration statement) or AD (Assembler directives). If an
imperative statement then the mnemonic info field contains the pair
(mnemonic opcode, instruction length) else it contains the id of a routine to
handle the declaration or directive statement.
• SYTAB entry contains the fields address and length.
• LITTAB entry contains the fields literal and address.
Processing of an assembly statement:
• Begins with the processing of label field.
• If label fields contains a symbol, the symbol and the value in LC is
copied into a new entry of SYMTAB.
• For OPTAB entry, the class field of entry is examined to determine
whether the mnemonics belongs to the class of imperative, declaration or
assembler directive statements.
• In case of imperative statement, the length the machine instructions is
simply added to LC and length is also entered in the SYMTAB.
• For declaration or assembler directives statements, the routine is
mentioned in the mnemonic info field is called to perform appropriate
processing of the statement.
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 3
• The pass I use the LITTAB (Literal Table) to collect all literals used in a
program. Awareness of different literal pools is maintained using the
auxiliary table POOLTAB. This table contains the literal number of the
starting literal of each literal pool. At any stage, the current literal pool is
the last pool in LITTAB. On encountering an LTORG statement or END
statement, literals in the current pool are allocated addresses starting with
the current value in LC and LC is appropriately incremented.
Algorithm for Pass I
1. location_counter := 0
pooltable_ptr := 1
POOLTAB[1] := 1
litertable_ptr := 1
2. While next statement is not end statement
a. If label is present then
this_label := symbol in label field
Enter (this_label, location_counter) in SYMTAB
b. If LTROG statement then
i. Process literals LITTAB[POOLTAL[pooltable_ptr]]…
LITTAB[literaltable_ptr -1] to allocate memory and put the
address in the address field. Update location_counter
accordingly.
ii. Pooltable_ptr := pooltable_ptr + 1
iii. POOLTAB[pooltable_ptr] := literaltable_ptr
c. If START or ORIGIN statement then
location_counter := value specified in the operand field
d. If an EQU statement then
i. this_address := value of < address specification
ii. Correct symbol table entry
This_label (this_label, this_address)
e. If a declaration statement then
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 4
i. code := code of the declaration statement
ii. size := size of memory area required by DS or DC
iii. location_counter := location_counter + size
iv. Generate IC (DL, code)
f. If an imperative statement then
i. code := machine opcode from OPTAB
ii. location_counter := location_counter + instruction length from
OPTAB
iii. If operand is literal then
this_literal := literal in operand field
LITTAB [literaltable_ptr] := this_literal
Literaltable_ptr := literaltable_ptr + 1
Else (i.e. operand is a symbol)
this_entry := SYMTAB entry number of operands
Generate IC (IS, code) (S, this_entry)
3. Processing of end statement
i. Perform step(2)
ii. Generate intermediate code IC (AD, 02)
iii. Go to Pass II.
System Programming
Walchand Institute of Technology
Figure: Example to generate intermediate representation using Pass I of two pass
Input:
START 200
MOVER
MOVEM
LOOP MOVER
MOVER
ADD
BC
LTORG
='5'
='1'
NEXT SUB
BC
Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur
Figure: Example to generate intermediate representation using Pass I of two pass
assembler
START 200
MOVER AREG, ='5'
MOVEM AREG, A
MOVER AREG, A
MOVER CREG, B
CREG, ='1'
ANY, NEXT
LTORG
AREG, ='1'
LT, BACK
Sunita M. Dol, CSE Dept
Page 5
Figure: Example to generate intermediate representation using Pass I of two pass
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 6
LASTSTOP
ORIGIN LOOP+2
MULT CREG, B
ORIGIN LAST+1
A DS 1
BACK EQU LOOP
B DS 2
END
='1'
Output:
Symbol Table
0 A 211 1
1 LOOP 202 1
2 B 212 2
3 NEXT 208 1
4 BACK 202 1
5 LAST 210 1
6 =’1’ 215 1
Literal Table
0 =’5’ 206 1
1 =’1’ 207 1
2 =’1’ 214 1
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)
System Programming Sunita M. Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 7
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
Conclusion:
Location counter processing is performed in the pass-I and symbols defined
in the program are entered into the symbol table.
Pass-I performs the analysis of source program.
Pass I:
Separate the symbol, mnemonic, opcode and operand.
Build Symbol Table.
Perform LC Processing.
Construct Intermediate Representation.
Thus the pass-I of two pass assembler is implemented in C-language.

Más contenido relacionado

La actualidad más candente (20)

Handout#02
Handout#02Handout#02
Handout#02
 
Handout#11
Handout#11Handout#11
Handout#11
 
Handout#09
Handout#09Handout#09
Handout#09
 
Assignment4
Assignment4Assignment4
Assignment4
 
Handout#12
Handout#12Handout#12
Handout#12
 
Assignment5
Assignment5Assignment5
Assignment5
 
Handout#01
Handout#01Handout#01
Handout#01
 
Compiler unit 4
Compiler unit 4Compiler unit 4
Compiler unit 4
 
C language
C languageC language
C language
 
The smartpath information systems c plus plus
The smartpath information systems  c plus plusThe smartpath information systems  c plus plus
The smartpath information systems c plus plus
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
 
C programming languag for cse students
C programming languag for cse studentsC programming languag for cse students
C programming languag for cse students
 
Introduction to C Language - Version 1.0 by Mark John Lado
Introduction to C Language - Version 1.0 by Mark John LadoIntroduction to C Language - Version 1.0 by Mark John Lado
Introduction to C Language - Version 1.0 by Mark John Lado
 
C language
C languageC language
C language
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
C notes
C notesC notes
C notes
 
C language (Collected By Dushmanta)
C language  (Collected By Dushmanta)C language  (Collected By Dushmanta)
C language (Collected By Dushmanta)
 
Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Basic c programming and explanation PPT1
Basic c programming and explanation PPT1
 
Introduction of C++ By Pawan Thakur
Introduction of C++ By Pawan ThakurIntroduction of C++ By Pawan Thakur
Introduction of C++ By Pawan Thakur
 
Lecture 21 22
Lecture 21 22Lecture 21 22
Lecture 21 22
 

Similar a Handout#06

Assembler - System Programming
Assembler - System ProgrammingAssembler - System Programming
Assembler - System ProgrammingRadhika Talaviya
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03desta_gebre
 
Workshop Assembler
Workshop AssemblerWorkshop Assembler
Workshop AssemblerTuhin_Das
 
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
 
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
 
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
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in detailskazi_aihtesham
 
Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computerKamal Acharya
 
Compiler gate question key
Compiler gate question keyCompiler gate question key
Compiler gate question keyArthyR3
 
loaders-and-linkers.pdfhhhhhccftyghgfggy
loaders-and-linkers.pdfhhhhhccftyghgfggyloaders-and-linkers.pdfhhhhhccftyghgfggy
loaders-and-linkers.pdfhhhhhccftyghgfggyrahulyadav957181
 
A Novel Efficient VLSI Architecture for IEEE 754 Floating point multiplier us...
A Novel Efficient VLSI Architecture for IEEE 754 Floating point multiplier us...A Novel Efficient VLSI Architecture for IEEE 754 Floating point multiplier us...
A Novel Efficient VLSI Architecture for IEEE 754 Floating point multiplier us...IJERA Editor
 
The process of programming
 The process of programming The process of programming
The process of programmingKopi Maheswaran
 
1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdfSemsemSameer1
 

Similar a Handout#06 (20)

assembler-ppt.pdf
assembler-ppt.pdfassembler-ppt.pdf
assembler-ppt.pdf
 
Assembler - System Programming
Assembler - System ProgrammingAssembler - System Programming
Assembler - System Programming
 
Assembler
AssemblerAssembler
Assembler
 
First pass of assembler
First pass of assemblerFirst pass of assembler
First pass of assembler
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
 
Workshop Assembler
Workshop AssemblerWorkshop Assembler
Workshop Assembler
 
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
 
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
 
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
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
 
Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
 
SPOS UNIT1 PPTS (1).pptx
SPOS UNIT1 PPTS (1).pptxSPOS UNIT1 PPTS (1).pptx
SPOS UNIT1 PPTS (1).pptx
 
Compiler gate question key
Compiler gate question keyCompiler gate question key
Compiler gate question key
 
Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
 
loaders-and-linkers.pdfhhhhhccftyghgfggy
loaders-and-linkers.pdfhhhhhccftyghgfggyloaders-and-linkers.pdfhhhhhccftyghgfggy
loaders-and-linkers.pdfhhhhhccftyghgfggy
 
A Novel Efficient VLSI Architecture for IEEE 754 Floating point multiplier us...
A Novel Efficient VLSI Architecture for IEEE 754 Floating point multiplier us...A Novel Efficient VLSI Architecture for IEEE 754 Floating point multiplier us...
A Novel Efficient VLSI Architecture for IEEE 754 Floating point multiplier us...
 
The process of programming
 The process of programming The process of programming
The process of programming
 
1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf
 

Más de Sunita Milind Dol (17)

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
 
Assignment3
Assignment3Assignment3
Assignment3
 
Assignment2
Assignment2Assignment2
Assignment2
 

Último

Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgsaravananr517913
 
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
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
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
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 

Último (20)

🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
 
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
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
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...
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
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
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
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
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 

Handout#06

  • 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 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 first 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: • Pass I: 1. Separate the symbol, mnemonic, opcode and operand. Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur HANDOUT#06 Design & implementation of pass 1 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 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 first 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 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 target form using the address information found in the symbol table. In effect, the first 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—data structures, e.g. the symbol table, and a processed form of the source program. The Tasks performed by the passes of a two 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. Pass I uses the following data structures: OPTAB : A table of machine opcodes and related information SYMTAB : Symbol table LITTAB : A table of literals used in the program. • OPTAB contains the fields mnemonic opcode, class and mnemonic info. The class indicates whether the opcode corresponds to an IS (Imperative statement), DL(Declaration statement) or AD (Assembler directives). If an imperative statement then the mnemonic info field contains the pair (mnemonic opcode, instruction length) else it contains the id of a routine to handle the declaration or directive statement. • SYTAB entry contains the fields address and length. • LITTAB entry contains the fields literal and address. Processing of an assembly statement: • Begins with the processing of label field. • If label fields contains a symbol, the symbol and the value in LC is copied into a new entry of SYMTAB. • For OPTAB entry, the class field of entry is examined to determine whether the mnemonics belongs to the class of imperative, declaration or assembler directive statements. • In case of imperative statement, the length the machine instructions is simply added to LC and length is also entered in the SYMTAB. • For declaration or assembler directives statements, the routine is mentioned in the mnemonic info field is called to perform appropriate processing of the statement.
  • 3. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 3 • The pass I use the LITTAB (Literal Table) to collect all literals used in a program. Awareness of different literal pools is maintained using the auxiliary table POOLTAB. This table contains the literal number of the starting literal of each literal pool. At any stage, the current literal pool is the last pool in LITTAB. On encountering an LTORG statement or END statement, literals in the current pool are allocated addresses starting with the current value in LC and LC is appropriately incremented. Algorithm for Pass I 1. location_counter := 0 pooltable_ptr := 1 POOLTAB[1] := 1 litertable_ptr := 1 2. While next statement is not end statement a. If label is present then this_label := symbol in label field Enter (this_label, location_counter) in SYMTAB b. If LTROG statement then i. Process literals LITTAB[POOLTAL[pooltable_ptr]]… LITTAB[literaltable_ptr -1] to allocate memory and put the address in the address field. Update location_counter accordingly. ii. Pooltable_ptr := pooltable_ptr + 1 iii. POOLTAB[pooltable_ptr] := literaltable_ptr c. If START or ORIGIN statement then location_counter := value specified in the operand field d. If an EQU statement then i. this_address := value of < address specification ii. Correct symbol table entry This_label (this_label, this_address) e. If a declaration statement then
  • 4. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 4 i. code := code of the declaration statement ii. size := size of memory area required by DS or DC iii. location_counter := location_counter + size iv. Generate IC (DL, code) f. If an imperative statement then i. code := machine opcode from OPTAB ii. location_counter := location_counter + instruction length from OPTAB iii. If operand is literal then this_literal := literal in operand field LITTAB [literaltable_ptr] := this_literal Literaltable_ptr := literaltable_ptr + 1 Else (i.e. operand is a symbol) this_entry := SYMTAB entry number of operands Generate IC (IS, code) (S, this_entry) 3. Processing of end statement i. Perform step(2) ii. Generate intermediate code IC (AD, 02) iii. Go to Pass II.
  • 5. System Programming Walchand Institute of Technology Figure: Example to generate intermediate representation using Pass I of two pass Input: START 200 MOVER MOVEM LOOP MOVER MOVER ADD BC LTORG ='5' ='1' NEXT SUB BC Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Figure: Example to generate intermediate representation using Pass I of two pass assembler START 200 MOVER AREG, ='5' MOVEM AREG, A MOVER AREG, A MOVER CREG, B CREG, ='1' ANY, NEXT LTORG AREG, ='1' LT, BACK Sunita M. Dol, CSE Dept Page 5 Figure: Example to generate intermediate representation using Pass I of two pass
  • 6. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 6 LASTSTOP ORIGIN LOOP+2 MULT CREG, B ORIGIN LAST+1 A DS 1 BACK EQU LOOP B DS 2 END ='1' Output: Symbol Table 0 A 211 1 1 LOOP 202 1 2 B 212 2 3 NEXT 208 1 4 BACK 202 1 5 LAST 210 1 6 =’1’ 215 1 Literal Table 0 =’5’ 206 1 1 =’1’ 207 1 2 =’1’ 214 1 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)
  • 7. System Programming Sunita M. Dol, CSE Dept Walchand Institute of Technology, Solapur Page 7 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 Conclusion: Location counter processing is performed in the pass-I and symbols defined in the program are entered into the symbol table. Pass-I performs the analysis of source program. Pass I: Separate the symbol, mnemonic, opcode and operand. Build Symbol Table. Perform LC Processing. Construct Intermediate Representation. Thus the pass-I of two pass assembler is implemented in C-language.