SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Chapter 2 Assemblers
-- 2.4 Assembler Design Options
Outline

 One-pass assemblers
 Multi-pass assemblers
 Two-pass assembler with overlay structure
Load-and-Go Assembler
 Load-and-go assembler generates their object code
 in memory for immediate execution.
 No object program is written out, no loader is needed.
 It is useful in a system oriented toward program
 development and testing such that the efficiency of
 the assembly process is an important consideration.
 Programs are re-assembled nearly every time they
 are run, efficiency of the assembly process is an
 important consideration.
One-Pass Assemblers
 Scenario for one-pass assemblers
   Generate their object code in memory for immediate execution –
   load-and-go assembler
   External storage for the intermediate file between two passes is
   slow or is inconvenient to use
 Main problem - Forward references
   Data items
   Labels on instructions
 Solution
   Require that all areas be defined before they are referenced.
   It is possible, although inconvenient, to do so for data items.
   Forward jump to instruction items cannot be easily eliminated.
      Insert (label, address_to_be_modified) to
      SYMTAB
      Usually, address_to_be_modified is stored in a
      linked-list
Sample program for a one-pass assembler
Figure 2.18, pp. 94
Forward Reference
in One-pass Assembler
 Omits the operand address if the symbol has not yet been
 defined
 Enters this undefined symbol into SYMTAB and indicates that it
 is undefined
 Adds the address of this operand address to a list of forward
 references associated with the SYMTAB entry
 When the definition for the symbol is encountered, scans the
 reference list and inserts the address.
 At the end of the program, reports the error if there are still
 SYMTAB entries indicated undefined symbols.
 For Load-and-Go assembler
    Search SYMTAB for the symbol named in the END statement and jumps
    to this location to begin execution if there is no error
Object Code in Memory and SYMTAB
Figure 2.19(a), pp.95
Object Code in Memory and SYMTAB
Figure 2.19(b), pp.96
If One-Pass Assemblers Need to Produce
Object Codes
 If the operand contains an undefined symbol, use 0
 as the address and write the Text record to the object
 program.
 Forward references are entered into lists as in the
 load-and-go assembler.
 When the definition of a symbol is encountered, the
 assembler generates another Text record with the
 correct operand address of each entry in the
 reference list.
 When loaded, the incorrect address 0 will be updated
 by the latter Text record containing the symbol
 definition.
Object code generated by one-pass assembler
Figure 2.18, pp.97
Multi-Pass Assemblers

For a two pass assembler, forward references in
symbol definition are not allowed:
           ALPHA          EQU            BETA
           BETA           EQU            DELTA
           DELTA          RESW       1
  Symbol definition must be completed in pass 1.
Prohibiting forward references in symbol
definition is not a serious inconvenience.
  Forward references tend to create difficulty for a person
  reading the program.
Implementation
 For a forward reference in symbol definition, we store
 in the SYMTAB:
    The symbol name
    The defining expression
    The number of undefined symbols in the defining expression
 The undefined symbol (marked with a flag *)
 associated with a list of symbols depend on this
 undefined symbol.
 When a symbol is defined, we can recursively
 evaluate the symbol expressions depending on the
 newly defined symbol.
Multi-pass assembler example
      Figure 2.21, pp. 99-101
# of undefined symbols in the
defining expression
                The defining expression




                                          Depending list




   Undefined symbol
Multi-pass assembler example
       Figure 2.21, pp. 99-101




2 MAXLEN EQU BUFEND-BUFFER   3   PREVBT   EQU   BUFFER-1
Multi-pass assembler example
        Figure 2.21, pp. 99-101




4   BUFFER   RESB   4096     5   BUFEND   EQU   *
Two-pass assembler
 with overlay structure
   When memory is not enough
       Pass 1 and pass 2 are never required at the same time
       Three segments
       Overlay program


                                          %&
!" #
$                                       !" #
!" #
$                             $                  $
                              !" #               !" #
!" #

Weitere ähnliche Inhalte

Was ist angesagt? (20)

15ss
15ss15ss
15ss
 
Sp chap2
Sp chap2Sp chap2
Sp chap2
 
Single Pass Assembler
Single Pass AssemblerSingle Pass Assembler
Single Pass Assembler
 
Assembler
AssemblerAssembler
Assembler
 
Assembler
AssemblerAssembler
Assembler
 
Assemblers
AssemblersAssemblers
Assemblers
 
Spr ch-02
Spr ch-02Spr ch-02
Spr ch-02
 
Compilers
CompilersCompilers
Compilers
 
Ch 3 Assembler in System programming
Ch 3 Assembler in System programming Ch 3 Assembler in System programming
Ch 3 Assembler in System programming
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programming
 
Assembler
AssemblerAssembler
Assembler
 
system software 16 marks
system software 16 markssystem software 16 marks
system software 16 marks
 
Loader
LoaderLoader
Loader
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
C basics
C basicsC basics
C basics
 
MASM -UNIT-III
MASM -UNIT-IIIMASM -UNIT-III
MASM -UNIT-III
 
Phases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingPhases of the Compiler - Systems Programming
Phases of the Compiler - Systems Programming
 
Assembler
AssemblerAssembler
Assembler
 
Assembler
AssemblerAssembler
Assembler
 
Assembler
AssemblerAssembler
Assembler
 

Ähnlich wie Sp2 4

Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assemblerBansari Shah
 
Task Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdfTask Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdfacsmadurai
 
COBOL FOR FRESHER
COBOL FOR FRESHERCOBOL FOR FRESHER
COBOL FOR FRESHERNirmal Pati
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programmingTejaswiB4
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programmingTejaswiB4
 
Automate Payload Generation for a Given Binary and Perform Attack
Automate Payload Generation for a Given Binary and Perform AttackAutomate Payload Generation for a Given Binary and Perform Attack
Automate Payload Generation for a Given Binary and Perform AttackAbhishek BV
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docxvenkatapranaykumarGa
 
Mainframe refresher-part-1
Mainframe refresher-part-1Mainframe refresher-part-1
Mainframe refresher-part-1vishwas17
 
SAS Macros part 1
SAS Macros part 1SAS Macros part 1
SAS Macros part 1venkatam
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in detailskazi_aihtesham
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilersvijaya603274
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptxssuser3b4934
 

Ähnlich wie Sp2 4 (20)

Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
 
Task Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdfTask Perform addition subtraction division and multiplic.pdf
Task Perform addition subtraction division and multiplic.pdf
 
3.2
3.23.2
3.2
 
Unit1 cd
Unit1 cdUnit1 cd
Unit1 cd
 
COBOL FOR FRESHER
COBOL FOR FRESHERCOBOL FOR FRESHER
COBOL FOR FRESHER
 
Preprocessors
PreprocessorsPreprocessors
Preprocessors
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Automate Payload Generation for a Given Binary and Perform Attack
Automate Payload Generation for a Given Binary and Perform AttackAutomate Payload Generation for a Given Binary and Perform Attack
Automate Payload Generation for a Given Binary and Perform Attack
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
 
Handout#06
Handout#06Handout#06
Handout#06
 
Module-4 Program Design and Anyalysis.pdf
Module-4 Program Design and Anyalysis.pdfModule-4 Program Design and Anyalysis.pdf
Module-4 Program Design and Anyalysis.pdf
 
Mainframe refresher-part-1
Mainframe refresher-part-1Mainframe refresher-part-1
Mainframe refresher-part-1
 
SAS Macros part 1
SAS Macros part 1SAS Macros part 1
SAS Macros part 1
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
 
SPOS UNIT1 PPTS (1).pptx
SPOS UNIT1 PPTS (1).pptxSPOS UNIT1 PPTS (1).pptx
SPOS UNIT1 PPTS (1).pptx
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
 
C programming
C programmingC programming
C programming
 

Kürzlich hochgeladen

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 

Kürzlich hochgeladen (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 

Sp2 4

  • 1. Chapter 2 Assemblers -- 2.4 Assembler Design Options
  • 2. Outline One-pass assemblers Multi-pass assemblers Two-pass assembler with overlay structure
  • 3. Load-and-Go Assembler Load-and-go assembler generates their object code in memory for immediate execution. No object program is written out, no loader is needed. It is useful in a system oriented toward program development and testing such that the efficiency of the assembly process is an important consideration. Programs are re-assembled nearly every time they are run, efficiency of the assembly process is an important consideration.
  • 4. One-Pass Assemblers Scenario for one-pass assemblers Generate their object code in memory for immediate execution – load-and-go assembler External storage for the intermediate file between two passes is slow or is inconvenient to use Main problem - Forward references Data items Labels on instructions Solution Require that all areas be defined before they are referenced. It is possible, although inconvenient, to do so for data items. Forward jump to instruction items cannot be easily eliminated. Insert (label, address_to_be_modified) to SYMTAB Usually, address_to_be_modified is stored in a linked-list
  • 5. Sample program for a one-pass assembler Figure 2.18, pp. 94
  • 6. Forward Reference in One-pass Assembler Omits the operand address if the symbol has not yet been defined Enters this undefined symbol into SYMTAB and indicates that it is undefined Adds the address of this operand address to a list of forward references associated with the SYMTAB entry When the definition for the symbol is encountered, scans the reference list and inserts the address. At the end of the program, reports the error if there are still SYMTAB entries indicated undefined symbols. For Load-and-Go assembler Search SYMTAB for the symbol named in the END statement and jumps to this location to begin execution if there is no error
  • 7. Object Code in Memory and SYMTAB Figure 2.19(a), pp.95
  • 8. Object Code in Memory and SYMTAB Figure 2.19(b), pp.96
  • 9. If One-Pass Assemblers Need to Produce Object Codes If the operand contains an undefined symbol, use 0 as the address and write the Text record to the object program. Forward references are entered into lists as in the load-and-go assembler. When the definition of a symbol is encountered, the assembler generates another Text record with the correct operand address of each entry in the reference list. When loaded, the incorrect address 0 will be updated by the latter Text record containing the symbol definition.
  • 10. Object code generated by one-pass assembler Figure 2.18, pp.97
  • 11. Multi-Pass Assemblers For a two pass assembler, forward references in symbol definition are not allowed: ALPHA EQU BETA BETA EQU DELTA DELTA RESW 1 Symbol definition must be completed in pass 1. Prohibiting forward references in symbol definition is not a serious inconvenience. Forward references tend to create difficulty for a person reading the program.
  • 12. Implementation For a forward reference in symbol definition, we store in the SYMTAB: The symbol name The defining expression The number of undefined symbols in the defining expression The undefined symbol (marked with a flag *) associated with a list of symbols depend on this undefined symbol. When a symbol is defined, we can recursively evaluate the symbol expressions depending on the newly defined symbol.
  • 13. Multi-pass assembler example Figure 2.21, pp. 99-101 # of undefined symbols in the defining expression The defining expression Depending list Undefined symbol
  • 14. Multi-pass assembler example Figure 2.21, pp. 99-101 2 MAXLEN EQU BUFEND-BUFFER 3 PREVBT EQU BUFFER-1
  • 15. Multi-pass assembler example Figure 2.21, pp. 99-101 4 BUFFER RESB 4096 5 BUFEND EQU *
  • 16. Two-pass assembler with overlay structure When memory is not enough Pass 1 and pass 2 are never required at the same time Three segments Overlay program %& !" # $ !" # !" # $ $ $ !" # !" # !" #