SlideShare a Scribd company logo
2
Most read
3
Most read
9
Most read
WALCHAND INSTITUTE OF TECHNOLOGY, SOLAPUR
PRESENTING A SEMINAR ON
TWO PASS ASSEMBLERS
TWO PASS ASSEMBLER
• Processing the source program into two passes.
• The internal tables and subroutines that are used only during Pass 1.
• The SYMTAB, LITTAB, and OPTAB are used by both passes.
• The main problems to assemble a program in one pass involves
forward references.
Pass 1
Forward references
table String storage
buffer Partially
configured object file
Assembly
Language
Pass 2 Machine
Language
• PASS 1
• Assign addresses to all statements in the program.
• Addresses of symbolic labels are stored.
• Some assemble directives will be processed.
• PASS 2
• Translate opcode and symbolic operands.
• Generate data values defined by BYTE,WORD etc.
• Assemble directives will be processed.
• Write the object program and assembly listing.
DATA STRUCTURES
• Two major data structures:
• Operation Code Table (OPTAB): is used to look up mnemonic operation
codes and translate them to their machine language equivalents
• Symbol Table (SYMTAB): is used to store values (addresses) assigned to
labels
• Variable:
• Location Counter (LOCCTR) is used to help the assignment of addresses
• LOCCTR is initialized to the beginning address specified in the START
statement
• The length of the assembled instruction or data area to be generated is
added to LOCCTR
Algorithm for Pass 1 of Assembler(3/1)
read first input line
if OPCODE=‘START’ then
begin
save #[OPERAND] as starting address
initialize LOCCTR to starting address
write line to intermediate file
read next input line
end
else
initialize LOCCTR to 0
while OPCODE≠’END’ do
begin
if this is not a comment line then
begin
if there is a symbol in the LABEL field then
Algorithm for Pass 1 of Assembler(3/2)
begin
search SYMTAB for LABEL
if found then
set error flag (duplicate symbol)
else
insert (LABEL, LOCCTR) into SYMTAB
end {if symbol}
search OPTAB for OPCODE
if found then
add 3 {instruction length} to LOCCTR
else if OPCODE=‘WORD’ then
add 3 to LOCCTR
else if OPCODE=‘RESW’ then
add 3 * #[OPERAND] to LOCCTR
Algorithm for Pass 1 of Assembler(3/3)
else if OPCODE=‘RESB’ then
add #[OPERAND] to LOCCTR
else if OPCODE=‘BYTE’ then
begin
find length of constant in bytes
add length to LOCCTR
end {if BYTE}
else
set error flag (invalid operation code)
end {if not a comment}
write line to intermediate file
read next input line
end {while not END}
Write last line to intermediate file
Save (LOCCTR-starting address) as program length
Algorithm for Pass 2 of Assembler(3/1)
read first input line (from intermediate file)
If OPCODE=‘START’ then
begin
write listing line
read next input line
end {if START}
Write Header record to object program
Initialize first Text record
While OPCODE≠ ‘END’ do
begin
if this is not a comment line then
begin
search OPTAB for OPCODE
if found then
begin
Algorithm for Pass 2 of Assembler(3/2)
if there is a symbol in OPERAND field then
begin
search SYMTAB for OPERAND
if found then
store symbol value as operand address
else
begin
store 0 as operand address
set error flag (undefined symbol)
end
end {if symbol}
else
store 0 as operand address
assemble the object code instruction
end {if opcode found}
Algorithm for Pass 2 of Assembler(3/3)
else if OPCODE=‘BYTE’ or ‘WORD’ then
convert constant to object code
if object code will not fit into the current Text record then
begin
write Text record to object program
initialize new Text record
end
add object code to Text record
end {if not comment}
write listing line
read next input line
end {while not END}
write last Text record to object program
Write End record to object program
Write last listing line
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
char *code[9][4]={
{"PRG1","START","",""},
{"","USING","*","15"},
{"","L","",""},
{"","A","",""},
{"","ST","",""},
{"FOUR","DC","F",""},
{"FIVE","DC","F",""},
{"TEMP","DS","1F",""},
{"","END","",""}
};
char av[2],avail[15]={'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'};
int i,j,k,count[3],lc[9]={0,0,0,0,0,0,0,0,0},loc=0;
clrscr();
Program
printf("----------------------------------------------------n");
printf("LABELttOPCODEn");
printf("----------------------------------------------------nn");
for(i=0;i<=8;i++)
{
for(j=0;j<=3;j++)
{
printf("%stt",code[i][j]);
}
j=0;
printf("n");
}
getch();
printf("-----------------------------------------------------");
printf("nVALUES FOR LC : nn");
for(j=0;j<=8;j++)
{
if((strcmp(code[j][1],"START")!=0)&&(strcmp(code[j][1],"USING")!=0)&&(strcmp(code[j][1],"L")!=0))
lc[j]=lc[j-1]+4;
printf("%dt",lc[j]);
}
printf("nnSYMBOL TABLE:n----------------------------------------------------n");
printf("SYMBOLttVALUEttLENGTHttR/A");
printf("n----------------------------------------------------n");
for(i=0;i< 9;i++)
{
if(strcmp(code[i][1],"START")==0)
{
printf("%stt%dtt%dtt%cn",code[i][0],loc,4,'R');
}
else
if(strcmp(code[i][0],"")!=0)
{
printf("%stt%dtt%dtt%cn",code[i][0],loc,4,'R');
loc=4+loc;
}
else
if(strcmp(code[i][1],"USING")==0)
{
}
else
{
loc=4+loc;
printf("----------------------------------------------------");
printf("nnBASE TABLE:n-------------------------------------------------------n");
printf("REG NOttAVAILIBILITYtCONTENTS OF BASE TABLE");
printf("n-------------------------------------------------------n");
for(j=0;j<=8;j++)
{
if(strcmp(code[j][1],"USING")!=0)
{
}
else
{
strcpy(av,code[j][3]);
}
}
count[0]=(int)av[0]-48;
count[1]=(int)av[1]-48;
count[2]=count[0]*10+count[1];
avail[count[2]-1]='Y';
for(k=0;k< 16;k++)
{
printf(" %dtt %cn",k,avail[k-1]);
}
printf("-------------------------------------------------------n");
printf("Continue..??");
getchar();
printf("PASS2 TABLE:nn");
printf("LABELttOP1ttLCtt");
printf("n----------------------------------------------------n");
loc=0;
for(i=0;i<=8;i++)
{
for(j=0;j<=3;j++)
{
printf("%stt",code[i][j]);
}
j=0;
printf("n");
}
printf("-----------------------------------------------------");
getch();
----------------------------------------------------
LABEL OPCODE
----------------------------------------------------
PRG1 START
USING * 15
L
A
ST
FOUR DC F
FIVE DC F
TEMP DS 1F
END
-----------------------------------------------------
VALUES FOR LC :
0 0 0 4 8 12 16 20 24
OUTPUT
SYMBOL TABLE:
----------------------------------------------------
SYMBOL VALUE LENGTH R/A
----------------------------------------------------
PRG1 0 4 R
FOUR 12 4 R
FIVE 16 4 R
TEMP 20 4 R
----------------------------------------------------
BASE TABLE:
-------------------------------------------------------
REG NO AVAILIBILITY CONTENTS OF BASE TABLE
-------------------------------------------------------
0
1 N
2 N
3 N
4 N
5 N
6 N
7 N
8 N
9 N
10 N
11 N
12 N
13 N
Continue..??
PASS2 TABLE:
LABEL OP1 LC
----------------------------------------------------
PRG1 START
USING * 15
L
A
ST
FOUR DC F
FIVE DC F
TEMP DS 1F
END
-----------------------------------------------------
Two pass Assembler

More Related Content

What's hot (20)

PPTX
System Programming- Unit I
Saranya1702
 
PPTX
Single pass assembler
Bansari Shah
 
PDF
Symbol table in compiler Design
Kuppusamy P
 
PPTX
System Programming Unit II
Manoj Patil
 
PPTX
Unit 3 sp assembler
Deepmala Sharma
 
PPTX
Loaders ( system programming )
Adarsh Patel
 
PPTX
Introduction to loaders
Tech_MX
 
PPTX
Phases of Compiler
Tanzeela_Hussain
 
PPTX
Code generation
Aparna Nayak
 
PPTX
Macro Processor
Saranya1702
 
PPT
1.Role lexical Analyzer
Radhakrishnan Chinnusamy
 
PPTX
Unit 4 sp macro
Deepmala Sharma
 
PPTX
Finite automata-for-lexical-analysis
Dattatray Gandhmal
 
PPTX
Ch 4 linker loader
Malek Sumaiya
 
PPT
Intermediate code generation (Compiler Design)
Tasif Tanzim
 
PPT
Ll(1) Parser in Compilers
Mahbubur Rahman
 
PPTX
Direct linking loaders
Satyamevjayte Haxor
 
PPT
Introduction to Compiler design
Dr. C.V. Suresh Babu
 
PDF
Lexical Analysis - Compiler design
Aman Sharma
 
PDF
Syntax Directed Definition and its applications
ShivanandManjaragi2
 
System Programming- Unit I
Saranya1702
 
Single pass assembler
Bansari Shah
 
Symbol table in compiler Design
Kuppusamy P
 
System Programming Unit II
Manoj Patil
 
Unit 3 sp assembler
Deepmala Sharma
 
Loaders ( system programming )
Adarsh Patel
 
Introduction to loaders
Tech_MX
 
Phases of Compiler
Tanzeela_Hussain
 
Code generation
Aparna Nayak
 
Macro Processor
Saranya1702
 
1.Role lexical Analyzer
Radhakrishnan Chinnusamy
 
Unit 4 sp macro
Deepmala Sharma
 
Finite automata-for-lexical-analysis
Dattatray Gandhmal
 
Ch 4 linker loader
Malek Sumaiya
 
Intermediate code generation (Compiler Design)
Tasif Tanzim
 
Ll(1) Parser in Compilers
Mahbubur Rahman
 
Direct linking loaders
Satyamevjayte Haxor
 
Introduction to Compiler design
Dr. C.V. Suresh Babu
 
Lexical Analysis - Compiler design
Aman Sharma
 
Syntax Directed Definition and its applications
ShivanandManjaragi2
 

Viewers also liked (6)

PPT
Assemblers: Ch03
desta_gebre
 
PPTX
Input-Buffering
Dattatray Gandhmal
 
PPTX
Role-of-lexical-analysis
Dattatray Gandhmal
 
PPTX
Peephole optimization techniques in compiler design
Anul Chaudhary
 
PPT
Lexical analyzer
Ashwini Sonawane
 
PPT
Assembler
Maha Lakshmi
 
Assemblers: Ch03
desta_gebre
 
Input-Buffering
Dattatray Gandhmal
 
Role-of-lexical-analysis
Dattatray Gandhmal
 
Peephole optimization techniques in compiler design
Anul Chaudhary
 
Lexical analyzer
Ashwini Sonawane
 
Assembler
Maha Lakshmi
 
Ad

Similar to Two pass Assembler (20)

PDF
computer architecture Lecture 8 for computer science
kareem mohamed
 
PPT
Unit 3 assembler and processor
Abha Damani
 
PPT
8051assembly language
Hisham Mat Hussin
 
DOC
35787646 system-software-lab-manual
Naveen Kumar
 
PPTX
SPOS UNIT1 PPTS (1).pptx
RavishankarBhaganaga
 
PDF
Assembler
SheetalAwate2
 
PPTX
Ch 3 Assembler in System programming
Bhatt Balkrishna
 
PPTX
Assembly Language Compiler Implementation
RAVI TEJA KOMMA
 
PPTX
System software module 1 presentation file
jithujithin657
 
PPTX
Unit1 111206003944-phpapp02
riddhi viradiya
 
PPTX
Programming the basic computer
Kamal Acharya
 
PPTX
Computer Organization
Radhika Talaviya
 
PPTX
Assembler - System Programming
Radhika Talaviya
 
PPSX
Spr ch-02
Vasim Pathan
 
PPTX
First pass of assembler
Hemant Chetwani
 
PPTX
CH-3 CO-all-about-operating-system(Update).pptx
XyzXyz338506
 
PPT
Assembler
Temesgen Molla
 
PPTX
3.ASSEMBLERS.pptx
GaganaP13
 
PDF
Microprocessor 8086-lab-mannual
yeshwant gadave
 
PPTX
Sp chap2
sushma sanisetty
 
computer architecture Lecture 8 for computer science
kareem mohamed
 
Unit 3 assembler and processor
Abha Damani
 
8051assembly language
Hisham Mat Hussin
 
35787646 system-software-lab-manual
Naveen Kumar
 
SPOS UNIT1 PPTS (1).pptx
RavishankarBhaganaga
 
Assembler
SheetalAwate2
 
Ch 3 Assembler in System programming
Bhatt Balkrishna
 
Assembly Language Compiler Implementation
RAVI TEJA KOMMA
 
System software module 1 presentation file
jithujithin657
 
Unit1 111206003944-phpapp02
riddhi viradiya
 
Programming the basic computer
Kamal Acharya
 
Computer Organization
Radhika Talaviya
 
Assembler - System Programming
Radhika Talaviya
 
Spr ch-02
Vasim Pathan
 
First pass of assembler
Hemant Chetwani
 
CH-3 CO-all-about-operating-system(Update).pptx
XyzXyz338506
 
Assembler
Temesgen Molla
 
3.ASSEMBLERS.pptx
GaganaP13
 
Microprocessor 8086-lab-mannual
yeshwant gadave
 
Ad

More from Satyamevjayte Haxor (16)

DOCX
Processes and threads
Satyamevjayte Haxor
 
PPTX
Patterns
Satyamevjayte Haxor
 
PPT
Uml class Diagram
Satyamevjayte Haxor
 
DOCX
Uml Common Mechanism
Satyamevjayte Haxor
 
PPTX
Types and roles
Satyamevjayte Haxor
 
DOCX
States machine
Satyamevjayte Haxor
 
PPTX
What is symbol table?
Satyamevjayte Haxor
 
PPTX
Lexical
Satyamevjayte Haxor
 
PPTX
sCode optimization
Satyamevjayte Haxor
 
PPTX
Nested micro
Satyamevjayte Haxor
 
PPTX
Multiplier control unit
Satyamevjayte Haxor
 
PPTX
Control unit design
Satyamevjayte Haxor
 
PPTX
Compilers
Satyamevjayte Haxor
 
PPTX
Keyword Presentation
Satyamevjayte Haxor
 
PPTX
Linking in MS-Dos System
Satyamevjayte Haxor
 
Processes and threads
Satyamevjayte Haxor
 
Uml class Diagram
Satyamevjayte Haxor
 
Uml Common Mechanism
Satyamevjayte Haxor
 
Types and roles
Satyamevjayte Haxor
 
States machine
Satyamevjayte Haxor
 
What is symbol table?
Satyamevjayte Haxor
 
sCode optimization
Satyamevjayte Haxor
 
Nested micro
Satyamevjayte Haxor
 
Multiplier control unit
Satyamevjayte Haxor
 
Control unit design
Satyamevjayte Haxor
 
Keyword Presentation
Satyamevjayte Haxor
 
Linking in MS-Dos System
Satyamevjayte Haxor
 

Recently uploaded (20)

PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Tally software_Introduction_Presentation
AditiBansal54083
 

Two pass Assembler