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

Data and functional modeling
Data and functional modelingData and functional modeling
Data and functional modeling
Slideshare
Ā 
Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loader
babyparul
Ā 
32 dynamic linking nd overlays
32 dynamic linking nd overlays32 dynamic linking nd overlays
32 dynamic linking nd overlays
myrajendra
Ā 

What's hot (20)

System software - macro expansion,nested macro calls
System software - macro expansion,nested macro callsSystem software - macro expansion,nested macro calls
System software - macro expansion,nested macro calls
Ā 
Design of a two pass assembler
Design of a two pass assemblerDesign of a two pass assembler
Design of a two pass assembler
Ā 
Data and functional modeling
Data and functional modelingData and functional modeling
Data and functional modeling
Ā 
Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
Ā 
Code generation
Code generationCode generation
Code generation
Ā 
Pass Structure of Assembler
Pass Structure of AssemblerPass Structure of Assembler
Pass Structure of Assembler
Ā 
UML Diagrams
UML DiagramsUML Diagrams
UML Diagrams
Ā 
Token, Pattern and Lexeme
Token, Pattern and LexemeToken, Pattern and Lexeme
Token, Pattern and Lexeme
Ā 
Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loader
Ā 
Unit 3
Unit 3Unit 3
Unit 3
Ā 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
Ā 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
Ā 
Unit 4 sp macro
Unit 4 sp macroUnit 4 sp macro
Unit 4 sp macro
Ā 
Direct linking loaders
Direct linking loadersDirect linking loaders
Direct linking loaders
Ā 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
Ā 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
Ā 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set Architecture
Ā 
32 dynamic linking nd overlays
32 dynamic linking nd overlays32 dynamic linking nd overlays
32 dynamic linking nd overlays
Ā 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
Ā 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
Ā 

Viewers also liked

Smqa unit ii
Smqa unit   iiSmqa unit   ii
Smqa unit ii
Manoj Patil
Ā 
System Programming Unit III
System Programming Unit IIISystem Programming Unit III
System Programming Unit III
Manoj Patil
Ā 
System Programming Unit IV
System Programming Unit IVSystem Programming Unit IV
System Programming Unit IV
Manoj Patil
Ā 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
Manoj Patil
Ā 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
Manoj Patil
Ā 

Viewers also liked (6)

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
Ā 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
Ā 
Assembler
AssemblerAssembler
Assembler
Ā 
System Programming Unit II
System Programming Unit IISystem Programming Unit II
System Programming Unit II
Ā 

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
Ā 
algorithm
algorithmalgorithm
algorithm
kokilabe
Ā 

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
Ā 
Loaders
LoadersLoaders
Loaders
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
Ā 
Heap sort
Heap sortHeap sort
Heap sort
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
Ā 
Loaders
LoadersLoaders
Loaders
Ā 
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
Ā 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(ā˜Žļø+971_581248768%)**%*]'#abortion pills for sale in dubai@
Ā 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
Ā 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
Ā 

Recently uploaded (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Ā 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Ā 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Ā 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Ā 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
Ā 
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
Ā 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
Ā 
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
Ā 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Ā 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
Ā 
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
Ā 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Ā 
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
Ā 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Ā 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Ā 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Ā 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Ā 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Ā 
Scaling API-first ā€“ The story of a global engineering organization
Scaling API-first ā€“ The story of a global engineering organizationScaling API-first ā€“ The story of a global engineering organization
Scaling API-first ā€“ The story of a global engineering organization
Ā 

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.