SlideShare a Scribd company logo
2
Most read
8
Most read
13
Most read
Subject: Systems Programming
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Single Pass Assembler
 Forward reference: reference to a label that is defined
later in the program.
 Table of Incomplete Instruction
START 200
ADD AREG A
.. ..
A DS 2
.. ..
END
Instruction
Address
Symbol
200 A
.. ..
What is Forward
reference ??Eg..
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Single Pass Assembler
 Forward reference: reference to a label that is defined
later in the program.
 Table of Incomplete Instruction
START 200
ADD AREG A
.. ..
A DS 2
.. ..
END
Instruction
Address
Symbol
200 A
.. ..
Symbol Address
A
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Single Pass Assembler
 Forward reference: reference to a label that is defined later in the program.
 Table of Incomplete Instruction
START 200
ADD AREG A
.. ..
A DS 2
.. ..
END
Instruction
Address
Symbol
200 A
.. ..
Symbol Address
A 202
.. ..
Target Code
200 01 01 -
… .. .. ..
202
Target Code
200 01 01 202
.. .. .. ..
202
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Single pass Assembler Examples
SOURCE PROGRAM
START 101
READ N
MOVER BREG, ONE
MOVEM BREG, TERM
AGAIN MULT BREG, TERM
MOVER CREG, TERM
ADD CREG, ONE
MOVEM CREG, TERM
COMP CREG, TERM
BC LE, AGAIN
MOVEM BREG, RESULT
PRINT RESULT
STOP
N DS 1
RESULT DS 1
ONE DC ‘1’
TERM DS 1
END
TARGET CODE
101 09 -
102 04 02 -
103 05 02 -
104 03 02 -
105 04 03 -
106 01 03 -
107 05 03 -
108 06 03 -
109 07 02 104
110 05 02 -
111 10 -
112 00
113
114
115
116
TII
INSTRUCTI
ON Address
SYMBOL
101 N
102 ONE
103 TERM
104 TERM
105 TERM
106 ONE
107 TERM
108 TERM
110 RESULT
111 RESULT
Symbol Table
SYMBOL ADDRESS
N 113
ONE 115
TERM 116
RESULT 114
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Single pass Assembler Examples
SOURCE PROGRAM
START 101
READ N
MOVER BREG, ONE
MOVEM BREG, TERM
AGAIN MULT BREG, TERM
MOVER CREG, TERM
ADD CREG, ONE
MOVEM CREG, TERM
COMP CREG, TERM
BC LE, AGAIN
MOVEM BREG, RESULT
PRINT RESULT
STOP
N DS 1
RESULT DS 1
ONE DC ‘1’
TERM DS 1
END
TARGET CODE
101 09 113
102 04 02 115
103 05 02 116
104 03 02 116
105 04 03 116
106 01 03 115
107 05 03 116
108 06 03 116
109 07 02 104
110 05 02 114
111 10 114
112 00
113
114
115
116
TII
INSTRUCTI
ON Address
SYMBOL
101 N
102 ONE
103 TERM
104 TERM
105 TERM
106 ONE
107 TERM
108 TERM
110 RESULT
111 RESULT
Symbol Table
SYMBOL ADDRESS
N 113
ONE 115
TERM 116
AGAIN 104
RESULT 114
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Design of Two Pass Assembler
 PASS I
 Separate the symbol, mnemonic opcode,and operand
fields.
 Build the symbol table
 Perform LC processing
 Construct intermediate code
 PASS II
 Synthesize the target code
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Required Data Structures for Two
Pass Assembler
PASS I PASS II
Intermediate Code
Symbol Table
Literal Table
Pool Table
Source
Code
Machine Code
Input
Output
Output Input
MOT
Register Value Table
Conditional Value Table
Prerequisite
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Assembler Pass I
SOURCE PROGRAM
START 200
MOVER AREG, =‘5’
MOVEM AREG, A
LOOP MOVER AREG, A
MOVER CREG, B
ADD CREG, =‘1’
LTORG
NEXT1 SUB AREG, ‘=1’
ORIGIN LOOP+1
MULT CREG, B
A DS 2
BACK EQU LOOP
B DC 1
END
INTERMEDIATE CODE
(AD,01) (C,200)
200 (IS,04) 1 (L,01)
201 (IS,05) 1 (S,01)
202 (IS,04) 1 (S,01)
203 (IS,04) 3 (S,03)
204 (IS,01) 3 (L,02)
(AD,05)
205 005
206 001
207 (IS,02) 1 (L,03)
(AD,03) (S,02)+(C,1)
203 (IS,03) 3 (S,03)
204 (DL,02) (C,02)
(AD,04) (S,02)
206 (DL,02) (C,02)
(AD,02)
207 001
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Assembler Pass I
SOURCE PROGRAM
START 200
MOVER AREG, =‘5’
MOVEM ADD, A
LOOP MOVER AREG, A
MOVER CREG, B
ADD CREG, =‘1’
LTORG
NEXT1 SUB AREG, ‘=1’
ORIGIN LOOP+1
MULT CREG, B
A DS 1
BACK EQU LOOP
B DS 1
END
INTERMEDIATE CODE
(AD,01) (C,200)
200 (IS,04) 1 (L,01)
201 (IS,05) 1 (S,01)
202 (IS,04) 1 (S,01)
203 (IS,04) 3 (S,03)
204 (IS,01) 3 (L,02)
(AD,05)
205 005
206 001
207 (IS,02) 1 (L,03)
(AD,03) (S,02)+(C,1)
203 (IS,03) 3 (S,03)
204 (DL,02) (C,01)
(AD,04) (S,02)
205 (DL,02) (C,01)
(AD,02)
206 001
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
SYMBOL TABLE
INDEX SYMBOL ADDRESS LENGTH
01 A 204 2
02 LOOP 202 1
03 B 205 1
04 NEXT1 207 1
05 BACK 202 1
Assembler Pass I
INTERMEDIATE CODE
(AD,01) (C,200)
200 (IS,04) 1 (L,01)
201 (IS,05) 1 (S,01)
202 (IS,04) 1 (S,01)
203 (IS,04) 3 (S,03)
204 (IS,01) 3 (L,02)
(AD,05)
205 005
206 001
207 (IS,02) 1 (L,03)
(AD,03) (S,02)+(C,1)
203 (IS,03) 3 (S,03)
204 (DL,02) (C,02)
(AD,04) (S,02)
206 (DL,02) (C,02)
(AD,02)
207 001
LITERAL TABLE
INDEX LITERAL ADDRESS
01 =‘5’ 205
02 =‘1’ 206
03 =‘1’ 207
POOL TABLE
LIT_INDEX
#01
#03
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Assembler Examples Convert Source
code into Pass I & Pass II
START 100
MOVER AREG, =‘5’
ADD CREG, =‘1’
A DS 3
L1 MOVER AREG, B
ADD AREG, C
MOPVEM AREG, D
LTORG
D EQU A+1
L2 PRINT D
ORIGIN A-1
SUB AREG, =‘1’
MULT CREG, B
C DS ‘5’
ORIGIN L2+1
STOP
B DC ’19’
END
EXAMPLE 2
SIMPLE START 100
BALR 15, 0
USING *, 15
LOOP L R1, TWO
A R1, FOUR
ST R1, FOUR
CLI FOUR+3, 4
BNE LOOP
BR 14
R1 EQU 1
TWO DC F’2’
FOUR DS F
END
ASSUME:-BALR & BR are of two bytes….
L,A,ST,CLI,BNE are of four byte instructions…
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Intermediate Code Forms
 Variant I
 Variant II
SOURCE PROGRAM
START 200
READ A
LOOP MOVER AREG, A
:
:
SUB AREG, =‘1’
VARIANT -II
(AD,01) (C,200)
(IS,09) A
(IS,04) AREG, A
:
:
(IS,02) AREG, (L,01)
VARIANT –I
(AD,01) (C,200)
(IS,09) (S,01)
(IS,04) 1 (S,01)
:
:
(IS,02) 1 (L,01)
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Assembler Pass II
INTERMEDIATE CODE
(AD,01) (C,200)
200 (IS,04) 1 (L,01)
201 (IS,05) 1 (S,01)
202 (IS,04) 1 (S,01)
203 (IS,04) 3 (S,03)
204 (IS,01) 3 (L,02)
(AD,05)
205 005
206 001
207 (IS,02) 1 (L,03)
(AD,03) (S,02)+(C,1)
203 (IS,03) 3 (S,03)
204 (DL,02) (C,02)
(AD,04) (S,02)
206 (DL,02) (C,02)
(AD,02)
207 001
TARGET CODE
200 04 1 205
201 05 1 204
202 04 1 204
203 04 3 205
204 01 3 206
205 005
206 001
207 02 1 207
203 03 3 205
204
206
207 001
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
Assembler Examples
SOURCE PROGRAM
START 1000
READ N
MOVER B, =‘1’
MOVEM B, TERM
AGAIN MULT B, TERM
MOVER C, TERM
ADD C, =‘1’
MOVEM C, TERM
COMP C, N
BC LE, AGAIN
MOVEM B, RESULT
LTORG
PRINT RESULT
STOP
N DS 1
RESUL
T
DS 20
TERM DS 1
END
INTERMEDIATE CODE
(AD,01) (C,1000)
1000 (IS,09) (S,01)
1001 (IS,04) 2 (L,01)
1002 (IS,05) 2 (S,02)
1003 (IS,03) 3 (S,02)
1004 (IS,05) 3 (S,02)
1005 (IS,01) 3 (L,01)
1006 (IS,05) 3 (S,02)
1007 (IS,06) 3 (S,01)
1008 (IS,07) 2 (S,03)
1009 (IS,05) 2 (S,04)
()AD,05)
1010 (L,01)
1011 (IS,10) (S,04)
1012 (IS,00)
1013 (DL,02) (C,01)
1014 (DL,02) (C,20)
1034 (DL,02) (C,01)
(AD,02)
Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in
THANK YOU
For Details feel free to contact
Prof. Sameer Mamadapure
sameerm@isquareit.edu.in
Department of Information Technology
Hope Foundation’s International Institute of Information Technology,
P-14 Rajiv Gandhi Infotech Park, MIDC Phase I
Hinjawadi, Pune – 411 057
Phone - +91 20 22933441
www.isquareit.edu.in | info@isquareit.edu.in

More Related Content

What's hot (20)

PDF
Compiler Design Lecture Notes
FellowBuddy.com
 
PPTX
Three address code In Compiler Design
Shine Raj
 
PPTX
System Programing Unit 1
Manoj Patil
 
PPT
Pass 1 flowchart
Namisha Sharma
 
PPTX
Relationship Among Token, Lexeme & Pattern
Bharat Rathore
 
PDF
Unit 2
pm_ghate
 
PPTX
Lexical analyzer generator lex
Anusuya123
 
PDF
Compiler Design Introduction
Kuppusamy P
 
PPTX
Ch 4 linker loader
Malek Sumaiya
 
PPTX
Peephole optimization techniques in compiler design
Anul Chaudhary
 
PPTX
System software - macro expansion,nested macro calls
SARASWATHI S
 
PPT
Parsing
khush_boo31
 
PPTX
Computer arithmetic
Balakrishna Chowdary
 
PPT
Compiler Design Unit 1
Jena Catherine Bel D
 
PPTX
Peephole Optimization
United International University
 
PPTX
Process synchronization in Operating Systems
Ritu Ranjan Shrivastwa
 
PPTX
Toy compiler
home
 
PPTX
Code Optimization
Akhil Kaushik
 
PPTX
And or graph
Ali A Jalil
 
PPTX
Parsing in Compiler Design
Akhil Kaushik
 
Compiler Design Lecture Notes
FellowBuddy.com
 
Three address code In Compiler Design
Shine Raj
 
System Programing Unit 1
Manoj Patil
 
Pass 1 flowchart
Namisha Sharma
 
Relationship Among Token, Lexeme & Pattern
Bharat Rathore
 
Unit 2
pm_ghate
 
Lexical analyzer generator lex
Anusuya123
 
Compiler Design Introduction
Kuppusamy P
 
Ch 4 linker loader
Malek Sumaiya
 
Peephole optimization techniques in compiler design
Anul Chaudhary
 
System software - macro expansion,nested macro calls
SARASWATHI S
 
Parsing
khush_boo31
 
Computer arithmetic
Balakrishna Chowdary
 
Compiler Design Unit 1
Jena Catherine Bel D
 
Peephole Optimization
United International University
 
Process synchronization in Operating Systems
Ritu Ranjan Shrivastwa
 
Toy compiler
home
 
Code Optimization
Akhil Kaushik
 
And or graph
Ali A Jalil
 
Parsing in Compiler Design
Akhil Kaushik
 

Similar to Pass Structure of Assembler (20)

PPTX
Introduction To Assembly Language Programming
International Institute of Information Technology (I²IT)
 
PPT
Importance of Theory of Computations
International Institute of Information Technology (I²IT)
 
PPTX
PIC Microcontroller | ADC Interfacing
International Institute of Information Technology (I²IT)
 
PPTX
Conformal Mapping - Introduction & Examples
International Institute of Information Technology (I²IT)
 
PPTX
Systems Programming & Operating Systems - Overview of LEX-and-YACC
International Institute of Information Technology (I²IT)
 
PPTX
Block Diagram Reduction Techniques
International Institute of Information Technology (I²IT)
 
PPTX
Euler’s Theorem Homogeneous Function Of Two Variables
International Institute of Information Technology (I²IT)
 
PPTX
Session-1-IPCRF-e-Toollllllllllllll.pptx
RHONALYNCABULLO1
 
PDF
Handout#07
Sunita Milind Dol
 
PDF
projrct oop.pdf
MohitSamota1
 
PPTX
DAA Introduction to Algorithms & Application
International Institute of Information Technology (I²IT)
 
PDF
Indian Patents 2014
Relecura Inc.
 
PPTX
Smartphone, Tablets and Mobile Device Repair Technique - IT Support Associate...
IT Support Program at Milwaukee Area Technical College
 
Introduction To Assembly Language Programming
International Institute of Information Technology (I²IT)
 
Importance of Theory of Computations
International Institute of Information Technology (I²IT)
 
PIC Microcontroller | ADC Interfacing
International Institute of Information Technology (I²IT)
 
Conformal Mapping - Introduction & Examples
International Institute of Information Technology (I²IT)
 
Systems Programming & Operating Systems - Overview of LEX-and-YACC
International Institute of Information Technology (I²IT)
 
Euler’s Theorem Homogeneous Function Of Two Variables
International Institute of Information Technology (I²IT)
 
Session-1-IPCRF-e-Toollllllllllllll.pptx
RHONALYNCABULLO1
 
Handout#07
Sunita Milind Dol
 
projrct oop.pdf
MohitSamota1
 
DAA Introduction to Algorithms & Application
International Institute of Information Technology (I²IT)
 
Indian Patents 2014
Relecura Inc.
 
Smartphone, Tablets and Mobile Device Repair Technique - IT Support Associate...
IT Support Program at Milwaukee Area Technical College
 
Ad

More from International Institute of Information Technology (I²IT) (20)

PPTX
Understanding Natural Language Processing
International Institute of Information Technology (I²IT)
 
PPTX
Professional Ethics & Etiquette: What Are They & How Do I Get Them?
International Institute of Information Technology (I²IT)
 
PPTX
Writing Skills: Importance of Writing Skills
International Institute of Information Technology (I²IT)
 
PPTX
Professional Communication | Introducing Oneself
International Institute of Information Technology (I²IT)
 
PPTX
Servlet: A Server-side Technology
International Institute of Information Technology (I²IT)
 
PPTX
What Is Jenkins? Features and How It Works
International Institute of Information Technology (I²IT)
 
PPTX
Data Science, Big Data, Data Analytics
International Institute of Information Technology (I²IT)
 
PPTX
Types of Artificial Intelligence
International Institute of Information Technology (I²IT)
 
PPTX
Difference Between AI(Artificial Intelligence), ML(Machine Learning), DL (Dee...
International Institute of Information Technology (I²IT)
 
PPTX
Sentiment Analysis in Machine Learning
International Institute of Information Technology (I²IT)
 
PPT
Java as Object Oriented Programming Language
International Institute of Information Technology (I²IT)
 
PPTX
What Is High Performance-Computing?
International Institute of Information Technology (I²IT)
 
PPTX
Data Visualization - How to connect Microsoft Forms to Power BI
International Institute of Information Technology (I²IT)
 
Understanding Natural Language Processing
International Institute of Information Technology (I²IT)
 
Professional Ethics & Etiquette: What Are They & How Do I Get Them?
International Institute of Information Technology (I²IT)
 
Writing Skills: Importance of Writing Skills
International Institute of Information Technology (I²IT)
 
Professional Communication | Introducing Oneself
International Institute of Information Technology (I²IT)
 
What Is Jenkins? Features and How It Works
International Institute of Information Technology (I²IT)
 
Data Science, Big Data, Data Analytics
International Institute of Information Technology (I²IT)
 
Difference Between AI(Artificial Intelligence), ML(Machine Learning), DL (Dee...
International Institute of Information Technology (I²IT)
 
Sentiment Analysis in Machine Learning
International Institute of Information Technology (I²IT)
 
Java as Object Oriented Programming Language
International Institute of Information Technology (I²IT)
 
Data Visualization - How to connect Microsoft Forms to Power BI
International Institute of Information Technology (I²IT)
 
Ad

Recently uploaded (20)

PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
PPTX
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PPTX
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PPTX
Day2 B2 Best.pptx
helenjenefa1
 
PPTX
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PPTX
MPMC_Module-2 xxxxxxxxxxxxxxxxxxxxx.pptx
ShivanshVaidya5
 
PPTX
EC3551-Transmission lines Demo class .pptx
Mahalakshmiprasannag
 
PPTX
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
PPTX
UNIT DAA PPT cover all topics 2021 regulation
archu26
 
PDF
monopile foundation seminar topic for civil engineering students
Ahina5
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
Hashing Introduction , hash functions and techniques
sailajam21
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
Day2 B2 Best.pptx
helenjenefa1
 
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
MPMC_Module-2 xxxxxxxxxxxxxxxxxxxxx.pptx
ShivanshVaidya5
 
EC3551-Transmission lines Demo class .pptx
Mahalakshmiprasannag
 
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
UNIT DAA PPT cover all topics 2021 regulation
archu26
 
monopile foundation seminar topic for civil engineering students
Ahina5
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 

Pass Structure of Assembler

  • 1. Subject: Systems Programming Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 2. Single Pass Assembler  Forward reference: reference to a label that is defined later in the program.  Table of Incomplete Instruction START 200 ADD AREG A .. .. A DS 2 .. .. END Instruction Address Symbol 200 A .. .. What is Forward reference ??Eg.. Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 3. Single Pass Assembler  Forward reference: reference to a label that is defined later in the program.  Table of Incomplete Instruction START 200 ADD AREG A .. .. A DS 2 .. .. END Instruction Address Symbol 200 A .. .. Symbol Address A Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 4. Single Pass Assembler  Forward reference: reference to a label that is defined later in the program.  Table of Incomplete Instruction START 200 ADD AREG A .. .. A DS 2 .. .. END Instruction Address Symbol 200 A .. .. Symbol Address A 202 .. .. Target Code 200 01 01 - … .. .. .. 202 Target Code 200 01 01 202 .. .. .. .. 202 Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 5. Single pass Assembler Examples SOURCE PROGRAM START 101 READ N MOVER BREG, ONE MOVEM BREG, TERM AGAIN MULT BREG, TERM MOVER CREG, TERM ADD CREG, ONE MOVEM CREG, TERM COMP CREG, TERM BC LE, AGAIN MOVEM BREG, RESULT PRINT RESULT STOP N DS 1 RESULT DS 1 ONE DC ‘1’ TERM DS 1 END TARGET CODE 101 09 - 102 04 02 - 103 05 02 - 104 03 02 - 105 04 03 - 106 01 03 - 107 05 03 - 108 06 03 - 109 07 02 104 110 05 02 - 111 10 - 112 00 113 114 115 116 TII INSTRUCTI ON Address SYMBOL 101 N 102 ONE 103 TERM 104 TERM 105 TERM 106 ONE 107 TERM 108 TERM 110 RESULT 111 RESULT Symbol Table SYMBOL ADDRESS N 113 ONE 115 TERM 116 RESULT 114 Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 6. Single pass Assembler Examples SOURCE PROGRAM START 101 READ N MOVER BREG, ONE MOVEM BREG, TERM AGAIN MULT BREG, TERM MOVER CREG, TERM ADD CREG, ONE MOVEM CREG, TERM COMP CREG, TERM BC LE, AGAIN MOVEM BREG, RESULT PRINT RESULT STOP N DS 1 RESULT DS 1 ONE DC ‘1’ TERM DS 1 END TARGET CODE 101 09 113 102 04 02 115 103 05 02 116 104 03 02 116 105 04 03 116 106 01 03 115 107 05 03 116 108 06 03 116 109 07 02 104 110 05 02 114 111 10 114 112 00 113 114 115 116 TII INSTRUCTI ON Address SYMBOL 101 N 102 ONE 103 TERM 104 TERM 105 TERM 106 ONE 107 TERM 108 TERM 110 RESULT 111 RESULT Symbol Table SYMBOL ADDRESS N 113 ONE 115 TERM 116 AGAIN 104 RESULT 114 Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 7. Design of Two Pass Assembler  PASS I  Separate the symbol, mnemonic opcode,and operand fields.  Build the symbol table  Perform LC processing  Construct intermediate code  PASS II  Synthesize the target code Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 8. Required Data Structures for Two Pass Assembler PASS I PASS II Intermediate Code Symbol Table Literal Table Pool Table Source Code Machine Code Input Output Output Input MOT Register Value Table Conditional Value Table Prerequisite Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 9. Assembler Pass I SOURCE PROGRAM START 200 MOVER AREG, =‘5’ MOVEM AREG, A LOOP MOVER AREG, A MOVER CREG, B ADD CREG, =‘1’ LTORG NEXT1 SUB AREG, ‘=1’ ORIGIN LOOP+1 MULT CREG, B A DS 2 BACK EQU LOOP B DC 1 END INTERMEDIATE CODE (AD,01) (C,200) 200 (IS,04) 1 (L,01) 201 (IS,05) 1 (S,01) 202 (IS,04) 1 (S,01) 203 (IS,04) 3 (S,03) 204 (IS,01) 3 (L,02) (AD,05) 205 005 206 001 207 (IS,02) 1 (L,03) (AD,03) (S,02)+(C,1) 203 (IS,03) 3 (S,03) 204 (DL,02) (C,02) (AD,04) (S,02) 206 (DL,02) (C,02) (AD,02) 207 001 Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 10. Assembler Pass I SOURCE PROGRAM START 200 MOVER AREG, =‘5’ MOVEM ADD, A LOOP MOVER AREG, A MOVER CREG, B ADD CREG, =‘1’ LTORG NEXT1 SUB AREG, ‘=1’ ORIGIN LOOP+1 MULT CREG, B A DS 1 BACK EQU LOOP B DS 1 END INTERMEDIATE CODE (AD,01) (C,200) 200 (IS,04) 1 (L,01) 201 (IS,05) 1 (S,01) 202 (IS,04) 1 (S,01) 203 (IS,04) 3 (S,03) 204 (IS,01) 3 (L,02) (AD,05) 205 005 206 001 207 (IS,02) 1 (L,03) (AD,03) (S,02)+(C,1) 203 (IS,03) 3 (S,03) 204 (DL,02) (C,01) (AD,04) (S,02) 205 (DL,02) (C,01) (AD,02) 206 001 Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 11. SYMBOL TABLE INDEX SYMBOL ADDRESS LENGTH 01 A 204 2 02 LOOP 202 1 03 B 205 1 04 NEXT1 207 1 05 BACK 202 1 Assembler Pass I INTERMEDIATE CODE (AD,01) (C,200) 200 (IS,04) 1 (L,01) 201 (IS,05) 1 (S,01) 202 (IS,04) 1 (S,01) 203 (IS,04) 3 (S,03) 204 (IS,01) 3 (L,02) (AD,05) 205 005 206 001 207 (IS,02) 1 (L,03) (AD,03) (S,02)+(C,1) 203 (IS,03) 3 (S,03) 204 (DL,02) (C,02) (AD,04) (S,02) 206 (DL,02) (C,02) (AD,02) 207 001 LITERAL TABLE INDEX LITERAL ADDRESS 01 =‘5’ 205 02 =‘1’ 206 03 =‘1’ 207 POOL TABLE LIT_INDEX #01 #03 Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 12. Assembler Examples Convert Source code into Pass I & Pass II START 100 MOVER AREG, =‘5’ ADD CREG, =‘1’ A DS 3 L1 MOVER AREG, B ADD AREG, C MOPVEM AREG, D LTORG D EQU A+1 L2 PRINT D ORIGIN A-1 SUB AREG, =‘1’ MULT CREG, B C DS ‘5’ ORIGIN L2+1 STOP B DC ’19’ END EXAMPLE 2 SIMPLE START 100 BALR 15, 0 USING *, 15 LOOP L R1, TWO A R1, FOUR ST R1, FOUR CLI FOUR+3, 4 BNE LOOP BR 14 R1 EQU 1 TWO DC F’2’ FOUR DS F END ASSUME:-BALR & BR are of two bytes…. L,A,ST,CLI,BNE are of four byte instructions… Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 13. Intermediate Code Forms  Variant I  Variant II SOURCE PROGRAM START 200 READ A LOOP MOVER AREG, A : : SUB AREG, =‘1’ VARIANT -II (AD,01) (C,200) (IS,09) A (IS,04) AREG, A : : (IS,02) AREG, (L,01) VARIANT –I (AD,01) (C,200) (IS,09) (S,01) (IS,04) 1 (S,01) : : (IS,02) 1 (L,01) Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 14. Assembler Pass II INTERMEDIATE CODE (AD,01) (C,200) 200 (IS,04) 1 (L,01) 201 (IS,05) 1 (S,01) 202 (IS,04) 1 (S,01) 203 (IS,04) 3 (S,03) 204 (IS,01) 3 (L,02) (AD,05) 205 005 206 001 207 (IS,02) 1 (L,03) (AD,03) (S,02)+(C,1) 203 (IS,03) 3 (S,03) 204 (DL,02) (C,02) (AD,04) (S,02) 206 (DL,02) (C,02) (AD,02) 207 001 TARGET CODE 200 04 1 205 201 05 1 204 202 04 1 204 203 04 3 205 204 01 3 206 205 005 206 001 207 02 1 207 203 03 3 205 204 206 207 001 Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 15. Assembler Examples SOURCE PROGRAM START 1000 READ N MOVER B, =‘1’ MOVEM B, TERM AGAIN MULT B, TERM MOVER C, TERM ADD C, =‘1’ MOVEM C, TERM COMP C, N BC LE, AGAIN MOVEM B, RESULT LTORG PRINT RESULT STOP N DS 1 RESUL T DS 20 TERM DS 1 END INTERMEDIATE CODE (AD,01) (C,1000) 1000 (IS,09) (S,01) 1001 (IS,04) 2 (L,01) 1002 (IS,05) 2 (S,02) 1003 (IS,03) 3 (S,02) 1004 (IS,05) 3 (S,02) 1005 (IS,01) 3 (L,01) 1006 (IS,05) 3 (S,02) 1007 (IS,06) 3 (S,01) 1008 (IS,07) 2 (S,03) 1009 (IS,05) 2 (S,04) ()AD,05) 1010 (L,01) 1011 (IS,10) (S,04) 1012 (IS,00) 1013 (DL,02) (C,01) 1014 (DL,02) (C,20) 1034 (DL,02) (C,01) (AD,02) Hope Foundation’s ,International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - [email protected]
  • 16. THANK YOU For Details feel free to contact Prof. Sameer Mamadapure [email protected] Department of Information Technology Hope Foundation’s International Institute of Information Technology, P-14 Rajiv Gandhi Infotech Park, MIDC Phase I Hinjawadi, Pune – 411 057 Phone - +91 20 22933441 www.isquareit.edu.in | [email protected]