SlideShare a Scribd company logo
4
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

PPTX
Assemblers
PPTX
Design of a two pass assembler
PPTX
Single pass assembler
PPTX
Type checking compiler construction Chapter #6
PPTX
Introduction to loaders
PDF
loaders and linkers
PPTX
Macro Processor
PPTX
Linker and Loader
Assemblers
Design of a two pass assembler
Single pass assembler
Type checking compiler construction Chapter #6
Introduction to loaders
loaders and linkers
Macro Processor
Linker and Loader

What's hot (20)

PPT
Introduction to Compiler design
PPTX
Loaders ( system programming )
PPT
CHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddel
PPTX
Unit 3 sp assembler
PPT
Pass 1 flowchart
PPT
Lexical Analysis
PPTX
MACRO PROCESSOR
PPTX
Syntax Analysis in Compiler Design
PPTX
SOFTWARE PARADIGM
PPTX
Direct linking loaders
PPTX
Recognition-of-tokens
DOC
Time and space complexity
PPTX
Unit 4 sp macro
PPTX
Ch 4 linker loader
PPT
1.Role lexical Analyzer
PPTX
Software Configuration Management (SCM)
PPTX
Interactive debugging system
PPTX
Two pass Assembler
PPTX
Process synchronization in Operating Systems
Introduction to Compiler design
Loaders ( system programming )
CHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddel
Unit 3 sp assembler
Pass 1 flowchart
Lexical Analysis
MACRO PROCESSOR
Syntax Analysis in Compiler Design
SOFTWARE PARADIGM
Direct linking loaders
Recognition-of-tokens
Time and space complexity
Unit 4 sp macro
Ch 4 linker loader
1.Role lexical Analyzer
Software Configuration Management (SCM)
Interactive debugging system
Two pass Assembler
Process synchronization in Operating Systems
Ad

Similar to Pass Structure of Assembler (20)

PPTX
Introduction To Assembly Language Programming
PPT
Importance of Theory of Computations
PPTX
PIC Microcontroller | ADC Interfacing
PPTX
Conformal Mapping - Introduction & Examples
PPTX
Systems Programming & Operating Systems - Overview of LEX-and-YACC
PPTX
PPTX
Company Profile JTIN Update 25 September 2024
PPTX
Euler’s Theorem Homogeneous Function Of Two Variables
PPTX
Session-1-IPCRF-e-Toollllllllllllll.pptx
PDF
Handout#07
PDF
projrct oop.pdf
PPTX
DAA Introduction to Algorithms & Application
PDF
Indian Patents 2014
Introduction To Assembly Language Programming
Importance of Theory of Computations
PIC Microcontroller | ADC Interfacing
Conformal Mapping - Introduction & Examples
Systems Programming & Operating Systems - Overview of LEX-and-YACC
Company Profile JTIN Update 25 September 2024
Euler’s Theorem Homogeneous Function Of Two Variables
Session-1-IPCRF-e-Toollllllllllllll.pptx
Handout#07
projrct oop.pdf
DAA Introduction to Algorithms & Application
Indian Patents 2014
Ad

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

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

Recently uploaded (20)

PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
OOP with Java - Java Introduction (Basics)
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Sustainable Sites - Green Building Construction
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
PPT on Performance Review to get promotions
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Lecture Notes Electrical Wiring System Components
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
OOP with Java - Java Introduction (Basics)
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
UNIT 4 Total Quality Management .pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Embodied AI: Ushering in the Next Era of Intelligent Systems
Sustainable Sites - Green Building Construction
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Arduino robotics embedded978-1-4302-3184-4.pdf
bas. eng. economics group 4 presentation 1.pptx
PPT on Performance Review to get promotions
CH1 Production IntroductoryConcepts.pptx
Lecture Notes Electrical Wiring System Components

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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 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 - info@isquareit.edu.in
  • 16. 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