SlideShare a Scribd company logo
1 of 21
Download to read offline
Design Of Two Pass
Assembler
BY SWAPNALI R. PAWAR
SWAPNALI R. PAWAR~(RIT) 1
SWAPNALI R. PAWAR~(RIT) 2
SWAPNALI R. PAWAR~(RIT) 3
SWAPNALI R. PAWAR~(RIT) 4
SWAPNALI R. PAWAR~(RIT) 5
Assembly Process
Pass 1 :Completely scan .asm file. Finds all labels and calculates corresponding address, stores
different type data in different data structure such as symbol table ,Literal Table and pool Table.
Pass2: Convert all the instructions into machine language format.
Symbol Table : Stores information about assembly program such as data, variables ,instructions and
addresses
Literal table keeps track of constants (like numbers or strings) used in the program.
Pool table that keeps track of the locations where constants are used in the program. It's like a
"waiting area" for constants. When a constant is encountered in the code, the assembler adds its
address to the pool table. This helps in generating the correct addresses for these constants during
the second pass.
SWAPNALI R. PAWAR~(RIT) 6
SWAPNALI R. PAWAR~(RIT) 7
SWAPNALI R. PAWAR~(RIT) 8
SWAPNALI R. PAWAR~(RIT) 9
SWAPNALI R. PAWAR~(RIT) 10
SWAPNALI R. PAWAR~(RIT) 11
• Literal Table:
• Keeps track of constants used in the program.
• Assigns symbols to each constant and stores their values.
• Helps the assembler manage constants and replace them with values in the
second pass.
• Pool Table:
• Keeps track of locations where constants are used.
• Acts like a "waiting area" for constants.
• Stores addresses of constants encountered in the code.
• Aids in generating correct addresses for constants during the second pass.
SWAPNALI R. PAWAR~(RIT) 12
Pass1 of assembler
Convert .asm file into .obj fie
Complete scan .asm file to gather information and bulid a symbol table , literal table, pool table.
In a two-pass assembler, the first pass performs a scan of the entire assembly source code to
gather information and build a symbol table.
The primary goal of the first pass is to identify labels, assign memory addresses to instructions
This information is required for the second pass of the assembler to generate the final machine
code.
SWAPNALI R. PAWAR~(RIT) 13
operations performed in pass 1
Label Handling:
The assembler identifies and processes labels (symbolic names for memory addresses). It
records these memory addresses in the symbol table.
Address Calculation:
For instructions and data, the assembler calculates the memory addresses where they will be
placed in memory. This involves counting the number of bytes needed for each instruction or
data element.
SWAPNALI R. PAWAR~(RIT) 14
• Macro Expansion:
• If the assembly language supports macros (predefined sequences of instructions),
the first pass may expand these macros to their corresponding instructions.
• Directive Processing:
Directives that allocate memory space, define variables, or set up program sections
are processed. The assembler reserves memory for data and records information
about program sections.
• Error Checking:
• Basic syntax and semantic errors are checked, such as incorrect instruction formats
or invalid operations. However, detailed error checking is done by second pass.
SWAPNALI R. PAWAR~(RIT) 15
• Intermediate Code Generation:
• An intermediate representation of the assembly code is created. This
intermediate code is used in the second pass to generate the final machine code.
• Symbol Table Construction:
• As the assembler encounters labels and instructions, it builds a symbol table. The
symbol table stores the labels along with their corresponding memory addresses.
• Literal Processing, Literal table ,pool table:
• Literals (constant values used in the code) are identified and assigned memory
addresses.
• The first pass creates the groundwork for the assembler's understanding of the
program's structure and memory allocation. Once the first pass is complete, the
assembler has gathered enough information to perform the second pass, during
which it generates the actual machine code.
SWAPNALI R. PAWAR~(RIT) 16
Pass 2 of assembler
After the first pass has collected all the pieces (information about labels, addresses, instructions,
etc.), the second pass takes those pieces and arranges them correctly to create the final picture,
which is the machine code that the computer can understand and execute.
It's the step where the actual translation from assembly code to machine code happens.
SWAPNALI R. PAWAR~(RIT) 17
Break down the second pass of a
two-pass assembler in simple terms:
Information from First Pass: In the first pass, the assembler gathered information about labels,
addresses, instructions, and data. This information is stored in a symbol table and other data
structures.
Replacing Labels: Remember those labels we used to mark different parts of the code? The
assembler works on your code line by line. When it encounters a label, it looks up its address in
the symbol table and replaces the label with the actual memory address.
SWAPNALI R. PAWAR~(RIT) 18
• Process Instructions: The assembler reads each instruction, like "MOV" or "ADD."
It translates these human-readable instructions into the corresponding binary
patterns that represent machine instructions. This is where the translation from
assembly language to machine code happens.
• Calculating Offsets: For instructions involving memory, the assembler calculates
the appropriate memory addresses and offsets based on the information from the
first pass and the specific addressing modes used in the instruction.
• Putting It All Together: As the assembler processes each line of code, it builds up
the final machine code sequence, piece by piece. It also handles data definitions,
creating the binary representation for constants and variables.
SWAPNALI R. PAWAR~(RIT) 19
• Errors and Warnings: The assembler also performs a more thorough error check
during this pass. If it finds syntax errors or logical errors that weren't caught in the
first pass, it reports them now.
• Finished Product: At the end of the second pass, you have a complete binary
representation of your program that's ready to be executed on the computer's
hardware.
• Think of the second pass as the step where your assembly code truly becomes the
instructions that the computer's CPU can follow. The first pass organized everything,
and the second pass brings it all to life by turning it into the language the machine
understands.
SWAPNALI R. PAWAR~(RIT) 20
Thank You !
SWAPNALI R. PAWAR~(RIT) 21

More Related Content

Similar to 10.Design Of Two Pass Assembler in system software.pdf

CS520 Computer Architecture Project 2 � Spring 2023 Due date 0326.pdf
CS520 Computer Architecture Project 2 � Spring 2023 Due date 0326.pdfCS520 Computer Architecture Project 2 � Spring 2023 Due date 0326.pdf
CS520 Computer Architecture Project 2 � Spring 2023 Due date 0326.pdf
ameerandsons
 
Workshop Assembler
Workshop AssemblerWorkshop Assembler
Workshop Assembler
Tuhin_Das
 
Effisiensi prog atmel
Effisiensi prog atmelEffisiensi prog atmel
Effisiensi prog atmel
rm_dhozooo
 
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
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)
Ashim Saha
 

Similar to 10.Design Of Two Pass Assembler in system software.pdf (20)

Introduction to microprocessor
Introduction to microprocessorIntroduction to microprocessor
Introduction to microprocessor
 
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
 
Compiler design
Compiler designCompiler design
Compiler design
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
 
CS520 Computer Architecture Project 2 � Spring 2023 Due date 0326.pdf
CS520 Computer Architecture Project 2 � Spring 2023 Due date 0326.pdfCS520 Computer Architecture Project 2 � Spring 2023 Due date 0326.pdf
CS520 Computer Architecture Project 2 � Spring 2023 Due date 0326.pdf
 
Assembly language.pptx
Assembly language.pptxAssembly language.pptx
Assembly language.pptx
 
Workshop Assembler
Workshop AssemblerWorkshop Assembler
Workshop Assembler
 
System Programming- Unit I
System Programming- Unit ISystem Programming- Unit I
System Programming- Unit I
 
Mp lab manual
Mp lab manualMp lab manual
Mp lab manual
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
Unit1 cd
Unit1 cdUnit1 cd
Unit1 cd
 
Effisiensi prog atmel
Effisiensi prog atmelEffisiensi prog atmel
Effisiensi prog atmel
 
Code generation errors and recovery
Code generation errors and recoveryCode generation errors and recovery
Code generation errors and recovery
 
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
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)
 
Assembly Language Paper.docx
Assembly Language Paper.docxAssembly Language Paper.docx
Assembly Language Paper.docx
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
 
SS-assemblers 1.pptx
SS-assemblers 1.pptxSS-assemblers 1.pptx
SS-assemblers 1.pptx
 
Spr ch-02
Spr ch-02Spr ch-02
Spr ch-02
 
Assembly Language for x86 Processors 7th Edition Chapter 2 : x86 Processor Ar...
Assembly Language for x86 Processors 7th Edition Chapter 2 : x86 Processor Ar...Assembly Language for x86 Processors 7th Edition Chapter 2 : x86 Processor Ar...
Assembly Language for x86 Processors 7th Edition Chapter 2 : x86 Processor Ar...
 

More from SwapnaliPawar27

More from SwapnaliPawar27 (13)

9.SimpleAssemblyScheme in system software.pdf
9.SimpleAssemblyScheme in system software.pdf9.SimpleAssemblyScheme in system software.pdf
9.SimpleAssemblyScheme in system software.pdf
 
8.PassStructureofAssembler in System Software.pdf
8.PassStructureofAssembler in System Software.pdf8.PassStructureofAssembler in System Software.pdf
8.PassStructureofAssembler in System Software.pdf
 
7.IntermediateCode in System Software.pdf
7.IntermediateCode in System Software.pdf7.IntermediateCode in System Software.pdf
7.IntermediateCode in System Software.pdf
 
6.Assembly Language Statments in system Software.pdf
6.Assembly Language Statments in system Software.pdf6.Assembly Language Statments in system Software.pdf
6.Assembly Language Statments in system Software.pdf
 
5.Elements of Assembly Language in System Software.pdf
5.Elements of Assembly Language in System Software.pdf5.Elements of Assembly Language in System Software.pdf
5.Elements of Assembly Language in System Software.pdf
 
4.LanguageProcessors and language Processing Activities.pdf
4.LanguageProcessors and language Processing Activities.pdf4.LanguageProcessors and language Processing Activities.pdf
4.LanguageProcessors and language Processing Activities.pdf
 
3.SystemPrograms and System Programming.pdf
3.SystemPrograms and System Programming.pdf3.SystemPrograms and System Programming.pdf
3.SystemPrograms and System Programming.pdf
 
2.Exploring-the-Goals-and-Programs-of-System-Software.pdf
2.Exploring-the-Goals-and-Programs-of-System-Software.pdf2.Exploring-the-Goals-and-Programs-of-System-Software.pdf
2.Exploring-the-Goals-and-Programs-of-System-Software.pdf
 
Inroduction System Software -features Types
Inroduction System Software -features TypesInroduction System Software -features Types
Inroduction System Software -features Types
 
2.dfa.pdf
2.dfa.pdf2.dfa.pdf
2.dfa.pdf
 
1.AutomataU1.pdf
1.AutomataU1.pdf1.AutomataU1.pdf
1.AutomataU1.pdf
 
Pointer.pptx
Pointer.pptxPointer.pptx
Pointer.pptx
 
Array.pptx
Array.pptxArray.pptx
Array.pptx
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
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
QucHHunhnh
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
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
 
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...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
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
 
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
 
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.
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
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
 
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
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

10.Design Of Two Pass Assembler in system software.pdf

  • 1. Design Of Two Pass Assembler BY SWAPNALI R. PAWAR SWAPNALI R. PAWAR~(RIT) 1
  • 6. Assembly Process Pass 1 :Completely scan .asm file. Finds all labels and calculates corresponding address, stores different type data in different data structure such as symbol table ,Literal Table and pool Table. Pass2: Convert all the instructions into machine language format. Symbol Table : Stores information about assembly program such as data, variables ,instructions and addresses Literal table keeps track of constants (like numbers or strings) used in the program. Pool table that keeps track of the locations where constants are used in the program. It's like a "waiting area" for constants. When a constant is encountered in the code, the assembler adds its address to the pool table. This helps in generating the correct addresses for these constants during the second pass. SWAPNALI R. PAWAR~(RIT) 6
  • 12. • Literal Table: • Keeps track of constants used in the program. • Assigns symbols to each constant and stores their values. • Helps the assembler manage constants and replace them with values in the second pass. • Pool Table: • Keeps track of locations where constants are used. • Acts like a "waiting area" for constants. • Stores addresses of constants encountered in the code. • Aids in generating correct addresses for constants during the second pass. SWAPNALI R. PAWAR~(RIT) 12
  • 13. Pass1 of assembler Convert .asm file into .obj fie Complete scan .asm file to gather information and bulid a symbol table , literal table, pool table. In a two-pass assembler, the first pass performs a scan of the entire assembly source code to gather information and build a symbol table. The primary goal of the first pass is to identify labels, assign memory addresses to instructions This information is required for the second pass of the assembler to generate the final machine code. SWAPNALI R. PAWAR~(RIT) 13
  • 14. operations performed in pass 1 Label Handling: The assembler identifies and processes labels (symbolic names for memory addresses). It records these memory addresses in the symbol table. Address Calculation: For instructions and data, the assembler calculates the memory addresses where they will be placed in memory. This involves counting the number of bytes needed for each instruction or data element. SWAPNALI R. PAWAR~(RIT) 14
  • 15. • Macro Expansion: • If the assembly language supports macros (predefined sequences of instructions), the first pass may expand these macros to their corresponding instructions. • Directive Processing: Directives that allocate memory space, define variables, or set up program sections are processed. The assembler reserves memory for data and records information about program sections. • Error Checking: • Basic syntax and semantic errors are checked, such as incorrect instruction formats or invalid operations. However, detailed error checking is done by second pass. SWAPNALI R. PAWAR~(RIT) 15
  • 16. • Intermediate Code Generation: • An intermediate representation of the assembly code is created. This intermediate code is used in the second pass to generate the final machine code. • Symbol Table Construction: • As the assembler encounters labels and instructions, it builds a symbol table. The symbol table stores the labels along with their corresponding memory addresses. • Literal Processing, Literal table ,pool table: • Literals (constant values used in the code) are identified and assigned memory addresses. • The first pass creates the groundwork for the assembler's understanding of the program's structure and memory allocation. Once the first pass is complete, the assembler has gathered enough information to perform the second pass, during which it generates the actual machine code. SWAPNALI R. PAWAR~(RIT) 16
  • 17. Pass 2 of assembler After the first pass has collected all the pieces (information about labels, addresses, instructions, etc.), the second pass takes those pieces and arranges them correctly to create the final picture, which is the machine code that the computer can understand and execute. It's the step where the actual translation from assembly code to machine code happens. SWAPNALI R. PAWAR~(RIT) 17
  • 18. Break down the second pass of a two-pass assembler in simple terms: Information from First Pass: In the first pass, the assembler gathered information about labels, addresses, instructions, and data. This information is stored in a symbol table and other data structures. Replacing Labels: Remember those labels we used to mark different parts of the code? The assembler works on your code line by line. When it encounters a label, it looks up its address in the symbol table and replaces the label with the actual memory address. SWAPNALI R. PAWAR~(RIT) 18
  • 19. • Process Instructions: The assembler reads each instruction, like "MOV" or "ADD." It translates these human-readable instructions into the corresponding binary patterns that represent machine instructions. This is where the translation from assembly language to machine code happens. • Calculating Offsets: For instructions involving memory, the assembler calculates the appropriate memory addresses and offsets based on the information from the first pass and the specific addressing modes used in the instruction. • Putting It All Together: As the assembler processes each line of code, it builds up the final machine code sequence, piece by piece. It also handles data definitions, creating the binary representation for constants and variables. SWAPNALI R. PAWAR~(RIT) 19
  • 20. • Errors and Warnings: The assembler also performs a more thorough error check during this pass. If it finds syntax errors or logical errors that weren't caught in the first pass, it reports them now. • Finished Product: At the end of the second pass, you have a complete binary representation of your program that's ready to be executed on the computer's hardware. • Think of the second pass as the step where your assembly code truly becomes the instructions that the computer's CPU can follow. The first pass organized everything, and the second pass brings it all to life by turning it into the language the machine understands. SWAPNALI R. PAWAR~(RIT) 20
  • 21. Thank You ! SWAPNALI R. PAWAR~(RIT) 21