SlideShare une entreprise Scribd logo
1  sur  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


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

Contenu connexe

Tendances

Tendances (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
 

Similaire à Sp2 4

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
acsmadurai
 
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
venkatapranaykumarGa
 
Mainframe refresher-part-1
Mainframe refresher-part-1Mainframe refresher-part-1
Mainframe refresher-part-1
vishwas17
 
SAS Macros part 1
SAS Macros part 1SAS Macros part 1
SAS Macros part 1
venkatam
 

Similaire à 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
 

Dernier

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Dernier (20)

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
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...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 

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 %& !" # $ !" # !" # $ $ $ !" # !" # !" #