SlideShare a Scribd company logo
1 of 8
IMPLEMENTATION OF ABSOLUTE LOADER
Aim
To write a C program to implement an absolute loader.
Algorithm:
1. Start the program
2. Assign the required variable
3. Open the files fp1=fopen("input2.dat","r"); fp2=fopen("out2.dat","w");
4. Read the content. Using while loop perform the loop until character is not
equal to E.
5. Then compare whether the character is equal to H
6. If H then get the starting address, length and input
7. Else if the character is T then store the string as the three address in the
output file with input[0],inuput[1] for address input[2],inuput[3] for
address+1 input[4],inuput[5] for address+2
8. Else if it is not H or T then perform the following fprintf in fp2 for output file
for , input[0],inuput[1] for address input[2],inuput[3] for address+1
input[4],inuput[5] for address+2
9. Increment the address value by 3.
10. Read the next input string and repeat from step 4.
11. Finally terminate the program
Source Code:
# include <stdio.h>
# include <conio.h>
# include <string.h>
void main()
{
char input[10];
int start,length,address;
FILE *fp1,*fp2;
clrscr();
fp1=fopen("input2.dat","r");
fp2=fopen("out2.dat","w");
fscanf(fp1,"%s",input);
while(strcmp(input,"E")!=0)
{
if(strcmp(input,"H")==0)
{
fscanf(fp1,"%d",&start);
fscanf(fp1,"%d",&length);
fscanf(fp1,"%s",input);
}
else if(strcmp(input,"T")==0)
{
fscanf(fp1,"%d",&address);
fscanf(fp1,"%s",input);
fprintf(fp2,"%dt%c%cn",address,input[0],input[1]);
fprintf(fp2,"%dt%c%cn",(address+1),input[2],input[3])
;
fprintf(fp2,"%dt%c%cn",(address+2),input[4],input[5])
;
address+=3;
fscanf(fp1,"%s",input);
}
else
{
fprintf(fp2,"%dt%c%cn",address,input[0],input[1]);
fprintf(fp2,"%dt%c%cn",(address+1),input[2],input[3])
;
fprintf(fp2,"%dt%c%cn",(address+2),input[4],input[5])
;
address+=3;
fscanf(fp1,"%s",input);
}
}
fclose(fp1);
fclose(fp2);
printf("FINISHED");
getch();
}
Input & Output:
Input File:
INPUT2.DAT
H 1000 232
T 1000 142033 483039 102036
T 2000 298300 230000 282030 302015
E
Output File:
OUT2.DAT
1000 14
1001 20
1002 33
1003 48
1004 30
1005 39
1006 10
1007 20
1008 36
2000 29
2001 83
2002 00
2003 23
2004 00
2005 00
2006 28
2007 20
2008 30
2009 30
2010 20
2011 15
IMPLEMENTATION OF RELOCATING LOADER
Aim
To write a C program to implement a relocating loader.
Algorithm:
1. Start the program
2. Include the necessary header file and variable
3. Open the following two file fp1= relinput.dat fp2= reloutput.dat
4. Read the content. Using while loop perform the loop until character is not
equal to E.
5. If the character is H then get the variable add, length, and input
6. Else if the character is T then get the variable address and bitmask and
perform the for loop starting from zero and up to len.
7. Get the opcode ,addr and assign relocbit to bitmask
8. If relocabit is zero then actualadd=addr
9. Else add the addr and starting value
10. Finally terminate the program
Source Code:
# include <stdio.h>
# include <conio.h>
# include <string.h>
# include <stdlib.h>
void main()
{
char add[6],length[10],input[10],binary[12],bitmask[12],relocbit;
int start,inp,len,i,address,opcode,addr,actualadd;
FILE *fp1,*fp2;
clrscr();
printf("Enter the actual starting address : ");
scanf("%d",&start);
fp1=fopen("relinp.dat","r");
fp2=fopen("reloutput.dat","w");
fscanf(fp1,"%s",input);
while(strcmp(input,"E")!=0)
{
if(strcmp(input,"H")==0)
{
fscanf(fp1,"%s",add);
fscanf(fp1,"%s",length);
fscanf(fp1,"%s",input);
}
if(strcmp(input,"T")==0)
{
fscanf(fp1,"%d",&address);
fscanf(fp1,"%s",bitmask);
address+=start;
len=strlen(bitmask);
for(i=0;i<len;i++)
{
fscanf(fp1,"%d",&opcode);
fscanf(fp1,"%d",&addr);
relocbit=bitmask[i];
if(relocbit=='0')
actualadd=addr;
else
actualadd=addr+start;
fprintf(fp2,"%dt%d%dn",address,opcode,actualadd);
address+=3;
}
fscanf(fp1,"%s",input);
}
}
fclose(fp1);
fclose(fp2);
printf("FINISHED");
getch();
}
Input & Output:
Input File:
Enter the actual starting address: 5000
RELINPUT.DAT
H 1000 200
T 1000 11001 14 1033 48 1039 90 1776 92 1765 57 1765
T 2011 11110 23 1838 43 1979 89 1060 66 1849 99 1477
E 1000
Output File:
RELOUTPUT.DAT
6000 146033
6003 486039
6006 901776
6009 921765
6012 576765
7011 236838
7014 436979
7017 896060
7020 666849
7023 991477

More Related Content

What's hot

Flynns classification
Flynns classificationFlynns classification
Flynns classification
Yasir Khan
 
Web essentials clients, servers and communication – the internet – basic inte...
Web essentials clients, servers and communication – the internet – basic inte...Web essentials clients, servers and communication – the internet – basic inte...
Web essentials clients, servers and communication – the internet – basic inte...
smitha273566
 

What's hot (20)

1.1.2 HEXADECIMAL
1.1.2 HEXADECIMAL1.1.2 HEXADECIMAL
1.1.2 HEXADECIMAL
 
Array Processor
Array ProcessorArray Processor
Array Processor
 
Bus interconnection
Bus interconnectionBus interconnection
Bus interconnection
 
Arm organization and implementation
Arm organization and implementationArm organization and implementation
Arm organization and implementation
 
Compiler unit 5
Compiler  unit 5Compiler  unit 5
Compiler unit 5
 
bus and memory tranfer (computer organaization)
bus and memory tranfer (computer organaization)bus and memory tranfer (computer organaization)
bus and memory tranfer (computer organaization)
 
Register Organization of 80386
Register Organization of 80386Register Organization of 80386
Register Organization of 80386
 
Flynns classification
Flynns classificationFlynns classification
Flynns classification
 
Rtos concepts
Rtos conceptsRtos concepts
Rtos concepts
 
Pentium processor
Pentium processorPentium processor
Pentium processor
 
Multi dimensional turing machine
Multi dimensional turing machineMulti dimensional turing machine
Multi dimensional turing machine
 
DMA operation
DMA operationDMA operation
DMA operation
 
05 multiply divide
05 multiply divide05 multiply divide
05 multiply divide
 
Assembly level language
Assembly level languageAssembly level language
Assembly level language
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
Interconnection Network
Interconnection NetworkInterconnection Network
Interconnection Network
 
Web essentials clients, servers and communication – the internet – basic inte...
Web essentials clients, servers and communication – the internet – basic inte...Web essentials clients, servers and communication – the internet – basic inte...
Web essentials clients, servers and communication – the internet – basic inte...
 
Training report on web developing
Training report on web developingTraining report on web developing
Training report on web developing
 
Bottom up parser
Bottom up parserBottom up parser
Bottom up parser
 
Intel 8051 Programming in C
Intel 8051 Programming in CIntel 8051 Programming in C
Intel 8051 Programming in C
 

Viewers also liked (11)

Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming )
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loaders
 
Absolute Loader
Absolute LoaderAbsolute Loader
Absolute Loader
 
Direct linking loaders
Direct linking loadersDirect linking loaders
Direct linking loaders
 
Loaders
LoadersLoaders
Loaders
 
System software-loaders
System software-loadersSystem software-loaders
System software-loaders
 
Loader and Its types
Loader and Its typesLoader and Its types
Loader and Its types
 
Interfacing of a LED display with laptop using Arduino
Interfacing of a LED display with laptop using ArduinoInterfacing of a LED display with laptop using Arduino
Interfacing of a LED display with laptop using Arduino
 
Loaders
LoadersLoaders
Loaders
 
Direct linking loader
Direct linking loaderDirect linking loader
Direct linking loader
 
Segmentation, Targeting, and Positioning
Segmentation, Targeting, and PositioningSegmentation, Targeting, and Positioning
Segmentation, Targeting, and Positioning
 

Similar to Implementation of absolute loader

Start from the sample code on the pdf Change struct to clas.pdf
Start from the sample code on the pdf  Change struct to clas.pdfStart from the sample code on the pdf  Change struct to clas.pdf
Start from the sample code on the pdf Change struct to clas.pdf
babitasingh698417
 
Code In PythonFile 1 main.pyYou will implement two algorithms t.pdf
Code In PythonFile 1 main.pyYou will implement two algorithms t.pdfCode In PythonFile 1 main.pyYou will implement two algorithms t.pdf
Code In PythonFile 1 main.pyYou will implement two algorithms t.pdf
aishwaryaequipment
 
Lecture#5 c lang new
Lecture#5 c lang newLecture#5 c lang new
Lecture#5 c lang new
Zeeshan Ahmad
 

Similar to Implementation of absolute loader (20)

Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branchComputer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
 
Start from the sample code on the pdf Change struct to clas.pdf
Start from the sample code on the pdf  Change struct to clas.pdfStart from the sample code on the pdf  Change struct to clas.pdf
Start from the sample code on the pdf Change struct to clas.pdf
 
00 C hello world.pptx
00 C hello world.pptx00 C hello world.pptx
00 C hello world.pptx
 
Code In PythonFile 1 main.pyYou will implement two algorithms t.pdf
Code In PythonFile 1 main.pyYou will implement two algorithms t.pdfCode In PythonFile 1 main.pyYou will implement two algorithms t.pdf
Code In PythonFile 1 main.pyYou will implement two algorithms t.pdf
 
Cp week _2.
Cp week _2.Cp week _2.
Cp week _2.
 
C++ Help FilestreamWrite a program that reads the values from a f.pdf
C++ Help FilestreamWrite a program that reads the values from a f.pdfC++ Help FilestreamWrite a program that reads the values from a f.pdf
C++ Help FilestreamWrite a program that reads the values from a f.pdf
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Infix to postfix.pdf
Infix to postfix.pdfInfix to postfix.pdf
Infix to postfix.pdf
 
Lecture#5 c lang new
Lecture#5 c lang newLecture#5 c lang new
Lecture#5 c lang new
 
It’s sometimes useful to make a little language for a simple problem.pdf
It’s sometimes useful to make a little language for a simple problem.pdfIt’s sometimes useful to make a little language for a simple problem.pdf
It’s sometimes useful to make a little language for a simple problem.pdf
 
Revision Lecture
Revision LectureRevision Lecture
Revision Lecture
 
270_1_CIntro_Up_To_Functions.ppt
270_1_CIntro_Up_To_Functions.ppt270_1_CIntro_Up_To_Functions.ppt
270_1_CIntro_Up_To_Functions.ppt
 
Survey of programming language getting started in C
Survey of programming language getting started in CSurvey of programming language getting started in C
Survey of programming language getting started in C
 
270 1 c_intro_up_to_functions
270 1 c_intro_up_to_functions270 1 c_intro_up_to_functions
270 1 c_intro_up_to_functions
 
270_1_CIntro_Up_To_Functions.ppt
270_1_CIntro_Up_To_Functions.ppt270_1_CIntro_Up_To_Functions.ppt
270_1_CIntro_Up_To_Functions.ppt
 
Programming in C
Programming in CProgramming in C
Programming in C
 
C programming Lab 1
C programming Lab 1C programming Lab 1
C programming Lab 1
 
Basic programming1..pptx
Basic programming1..pptxBasic programming1..pptx
Basic programming1..pptx
 
Common Programming Errors
Common Programming ErrorsCommon Programming Errors
Common Programming Errors
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
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.
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
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
 

Implementation of absolute loader