SlideShare a Scribd company logo
1 of 21
Assembler Design Options
One and Multi-Pass Assembler
• So far, we have presented the design and
  implementation of a two-pass assembler.
• Here, we will present the design and
  implementation of
  – One-pass assembler
     • If avoiding a second pass over the source program is
       necessary or desirable.
  – Multi-pass assembler
     • Allow forward references during symbol definition.
One-Pass Assembler
• The main problem is about forward reference.
• Eliminating forward reference to data items can be
  easily done.
   – Simply ask the programmer to define variables before
     using them.
• However, eliminating forward reference to
  instruction cannot be easily done.
   – Sometimes your program needs a forward jump.
   – Asking your program to use only backward jumps is
     too restrictive.
Program Example
All variables are defined before they are used.
Two Types
• There are two types of one-pass assembler:
   – Produce object code directly in memory for immediate
     execution
      • No loader is needed
      • Load-and-go for program development and testing
      • Good for computing center where most students reassemble
        their programs each time.
      • Can save time for scanning the source code again
   – Produce the usual kind of object program for later
     execution
Internal Implementation
• The assembler generate object code instructions as
  it scans the source program.
• If an instruction operand is a symbol that has not
  yet been defined,the operand address is omitted
  when the instruction is assembled.
• The symbol used as an operand is entered into the
  symbol table.
• This entry is flagged to indicate that the symbol is
  undefined yet.
Internal Implementation (cont’d)
• The address of the operand field of the instruction
  that refers to the undefined symbol is added to a
  list of forward references associated with the
  symbol table entry.
• When the definition of the symbol is encountered,
  the forward reference list for that symbol is
  scanned, and the proper address is inserted into
  any instruction previously generated.
Processing Example




After scanning line 40
Processing Example (cont’d)




After scanning line 160
Processing Example (cont’d)
• Between scanning line 40 and 160:
   – On line 45, when the symbol ENDFIL is defined, the
     assembler places its value in the SYMTAB entry.
   – The assembler then inserts this value into the
     instruction operand field (at address 201C).
   – From this point on, any references to ENDFIL would
     not be forward references and would not be entered into
     a list.
• At the end of the processing of the program, any
  SYMTAB entries that are still marked with *
  indicate undefined symbols.
   – These should be flagged by the assembler as errors.
Multi-Pass Assembler
• If we use a two-pass assembler, the following
  symbol definition cannot be allowed.
            ALPHA      EQU      BETA
            BETA       EQU      DELTA
            DELTA RESW 1
• This is because ALPHA and BETA cannot be
  defined in pass 1. Actually, if we allow multi-pass
  processing, DELTA is defined in pass 1, BETA is
  defined in pass 2, and ALPHA is defined in pass
  3, and the above definitions can be allowed.
• This is the motivation for using a multi-pass
  assembler.
Multi-Pass Assembler(cont’d)
• It is unnecessary for a multi-pass assembler
  to make more than two passes over the
  entire program.
• Instead, only the parts of the program
  involving forward references need to be
  processed in multiple passes.
• The method presented here can be used to
  process any kind of forward references.
Multi-Pass Assembler
            Implementation
• Use a symbol table to store symbols that are not
  totally defined yet.
• For a undefined symbol, in its entry,
   – We store the names and the number of undefined
     symbols which contribute to the calculation of its value.
   – We also keep a list of symbols whose values depend on
      the defined value of this symbol.
• When a symbol becomes defined, we use its value
  to reevaluate the values of all of the symbols that
  are kept in this list.
• The above step is performed recursively.
Forward Reference Example
Forward Reference Processing

        But one symbol is unknown yet



        Defined




       Not defined yet
                                  After first line
After second line


But two symbols are unknown yet


   Now defined
After third line
After 4’th line




Start knowing values
Start knowing values




                       After 5’th line


                       All symbols are
                       defined and their
                       values are known
                       now.

More Related Content

What's hot

Compiler Design
Compiler DesignCompiler Design
Compiler Design
Mir Majid
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loaders
Tech_MX
 
2.2. language evaluation criteria
2.2. language evaluation criteria2.2. language evaluation criteria
2.2. language evaluation criteria
annahallare_
 

What's hot (20)

Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
 
Types of Compilers
Types of CompilersTypes of Compilers
Types of Compilers
 
Passes of compilers
Passes of compilersPasses of compilers
Passes of compilers
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
 
System Programming Overview
System Programming OverviewSystem Programming Overview
System Programming Overview
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loaders
 
2.2. language evaluation criteria
2.2. language evaluation criteria2.2. language evaluation criteria
2.2. language evaluation criteria
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
 
Loaders
LoadersLoaders
Loaders
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 
P code
P codeP code
P code
 
Unit 3
Unit 3Unit 3
Unit 3
 
COMPILER DESIGN OPTIONS
COMPILER DESIGN OPTIONSCOMPILER DESIGN OPTIONS
COMPILER DESIGN OPTIONS
 
Design of a two pass assembler
Design of a two pass assemblerDesign of a two pass assembler
Design of a two pass assembler
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
 

Viewers also liked (7)

Assembler design option
Assembler design optionAssembler design option
Assembler design option
 
Smqa unit ii
Smqa unit   iiSmqa unit   ii
Smqa unit ii
 
System Programming Unit III
System Programming Unit IIISystem Programming Unit III
System Programming Unit III
 
System Programming Unit IV
System Programming Unit IVSystem Programming Unit IV
System Programming Unit IV
 
Assembler
AssemblerAssembler
Assembler
 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
 

Similar to Assembler design options

classVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptxclassVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptx
ssusere336f4
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
iamluqman0403
 
Part II: Assembly Fundamentals
Part II: Assembly FundamentalsPart II: Assembly Fundamentals
Part II: Assembly Fundamentals
Ahmed M. Abed
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
Abha Damani
 

Similar to Assembler design options (20)

Unit 1 psp
Unit 1 pspUnit 1 psp
Unit 1 psp
 
Assembler
AssemblerAssembler
Assembler
 
Sp2 4
Sp2 4Sp2 4
Sp2 4
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
classVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptxclassVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptx
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & Recovery
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
 
Part II: Assembly Fundamentals
Part II: Assembly FundamentalsPart II: Assembly Fundamentals
Part II: Assembly Fundamentals
 
CPP03 - Repetition
CPP03 - RepetitionCPP03 - Repetition
CPP03 - Repetition
 
System software module 1 presentation file
System software module 1 presentation fileSystem software module 1 presentation file
System software module 1 presentation file
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
Basic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartBasic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chart
 
C language
C languageC language
C language
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Error Detection & Recovery.pptx
Error Detection & Recovery.pptxError Detection & Recovery.pptx
Error Detection & Recovery.pptx
 
algorithm
algorithmalgorithm
algorithm
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
 
Lessons in Linear Algebra at Scale with Apache Spark : Let's Make the Sparse ...
Lessons in Linear Algebra at Scale with Apache Spark : Let's Make the Sparse ...Lessons in Linear Algebra at Scale with Apache Spark : Let's Make the Sparse ...
Lessons in Linear Algebra at Scale with Apache Spark : Let's Make the Sparse ...
 

More from Mohd Arif

Bootp and dhcp
Bootp and dhcpBootp and dhcp
Bootp and dhcp
Mohd Arif
 
Arp and rarp
Arp and rarpArp and rarp
Arp and rarp
Mohd Arif
 
User datagram protocol
User datagram protocolUser datagram protocol
User datagram protocol
Mohd Arif
 
Project identification
Project identificationProject identification
Project identification
Mohd Arif
 
Project evalaution techniques
Project evalaution techniquesProject evalaution techniques
Project evalaution techniques
Mohd Arif
 
Presentation
PresentationPresentation
Presentation
Mohd Arif
 
Pointers in c
Pointers in cPointers in c
Pointers in c
Mohd Arif
 
Peer to-peer
Peer to-peerPeer to-peer
Peer to-peer
Mohd Arif
 
Overview of current communications systems
Overview of current communications systemsOverview of current communications systems
Overview of current communications systems
Mohd Arif
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdp
Mohd Arif
 
Objectives of budgeting
Objectives of budgetingObjectives of budgeting
Objectives of budgeting
Mohd Arif
 
Network management
Network managementNetwork management
Network management
Mohd Arif
 
Networing basics
Networing basicsNetworing basics
Networing basics
Mohd Arif
 
Iris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platformIris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platform
Mohd Arif
 
Ip sec and ssl
Ip sec and  sslIp sec and  ssl
Ip sec and ssl
Mohd Arif
 
Ip security in i psec
Ip security in i psecIp security in i psec
Ip security in i psec
Mohd Arif
 
Intro to comp. hardware
Intro to comp. hardwareIntro to comp. hardware
Intro to comp. hardware
Mohd Arif
 
H.323 vs. cops interworking
H.323 vs. cops interworkingH.323 vs. cops interworking
H.323 vs. cops interworking
Mohd Arif
 

More from Mohd Arif (20)

Bootp and dhcp
Bootp and dhcpBootp and dhcp
Bootp and dhcp
 
Arp and rarp
Arp and rarpArp and rarp
Arp and rarp
 
User datagram protocol
User datagram protocolUser datagram protocol
User datagram protocol
 
Project identification
Project identificationProject identification
Project identification
 
Project evalaution techniques
Project evalaution techniquesProject evalaution techniques
Project evalaution techniques
 
Presentation
PresentationPresentation
Presentation
 
Pointers in c
Pointers in cPointers in c
Pointers in c
 
Peer to-peer
Peer to-peerPeer to-peer
Peer to-peer
 
Overview of current communications systems
Overview of current communications systemsOverview of current communications systems
Overview of current communications systems
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdp
 
Objectives of budgeting
Objectives of budgetingObjectives of budgeting
Objectives of budgeting
 
Network management
Network managementNetwork management
Network management
 
Networing basics
Networing basicsNetworing basics
Networing basics
 
Lists
ListsLists
Lists
 
Iris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platformIris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platform
 
Ip sec and ssl
Ip sec and  sslIp sec and  ssl
Ip sec and ssl
 
Ip security in i psec
Ip security in i psecIp security in i psec
Ip security in i psec
 
Intro to comp. hardware
Intro to comp. hardwareIntro to comp. hardware
Intro to comp. hardware
 
Heap sort
Heap sortHeap sort
Heap sort
 
H.323 vs. cops interworking
H.323 vs. cops interworkingH.323 vs. cops interworking
H.323 vs. cops interworking
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Assembler design options

  • 2. One and Multi-Pass Assembler • So far, we have presented the design and implementation of a two-pass assembler. • Here, we will present the design and implementation of – One-pass assembler • If avoiding a second pass over the source program is necessary or desirable. – Multi-pass assembler • Allow forward references during symbol definition.
  • 3. One-Pass Assembler • The main problem is about forward reference. • Eliminating forward reference to data items can be easily done. – Simply ask the programmer to define variables before using them. • However, eliminating forward reference to instruction cannot be easily done. – Sometimes your program needs a forward jump. – Asking your program to use only backward jumps is too restrictive.
  • 5.
  • 6. All variables are defined before they are used.
  • 7. Two Types • There are two types of one-pass assembler: – Produce object code directly in memory for immediate execution • No loader is needed • Load-and-go for program development and testing • Good for computing center where most students reassemble their programs each time. • Can save time for scanning the source code again – Produce the usual kind of object program for later execution
  • 8. Internal Implementation • The assembler generate object code instructions as it scans the source program. • If an instruction operand is a symbol that has not yet been defined,the operand address is omitted when the instruction is assembled. • The symbol used as an operand is entered into the symbol table. • This entry is flagged to indicate that the symbol is undefined yet.
  • 9. Internal Implementation (cont’d) • The address of the operand field of the instruction that refers to the undefined symbol is added to a list of forward references associated with the symbol table entry. • When the definition of the symbol is encountered, the forward reference list for that symbol is scanned, and the proper address is inserted into any instruction previously generated.
  • 12. Processing Example (cont’d) • Between scanning line 40 and 160: – On line 45, when the symbol ENDFIL is defined, the assembler places its value in the SYMTAB entry. – The assembler then inserts this value into the instruction operand field (at address 201C). – From this point on, any references to ENDFIL would not be forward references and would not be entered into a list. • At the end of the processing of the program, any SYMTAB entries that are still marked with * indicate undefined symbols. – These should be flagged by the assembler as errors.
  • 13. Multi-Pass Assembler • If we use a two-pass assembler, the following symbol definition cannot be allowed. ALPHA EQU BETA BETA EQU DELTA DELTA RESW 1 • This is because ALPHA and BETA cannot be defined in pass 1. Actually, if we allow multi-pass processing, DELTA is defined in pass 1, BETA is defined in pass 2, and ALPHA is defined in pass 3, and the above definitions can be allowed. • This is the motivation for using a multi-pass assembler.
  • 14. Multi-Pass Assembler(cont’d) • It is unnecessary for a multi-pass assembler to make more than two passes over the entire program. • Instead, only the parts of the program involving forward references need to be processed in multiple passes. • The method presented here can be used to process any kind of forward references.
  • 15. Multi-Pass Assembler Implementation • Use a symbol table to store symbols that are not totally defined yet. • For a undefined symbol, in its entry, – We store the names and the number of undefined symbols which contribute to the calculation of its value. – We also keep a list of symbols whose values depend on the defined value of this symbol. • When a symbol becomes defined, we use its value to reevaluate the values of all of the symbols that are kept in this list. • The above step is performed recursively.
  • 17. Forward Reference Processing But one symbol is unknown yet Defined Not defined yet After first line
  • 18. After second line But two symbols are unknown yet Now defined
  • 20. After 4’th line Start knowing values
  • 21. Start knowing values After 5’th line All symbols are defined and their values are known now.