SlideShare a Scribd company logo
2
Most read
3
Most read
6
Most read
Linking In MS-DOS
Shubham Shah
Yashashwi Mahindrakar
Sagar Nadgauda
Linking In MS Dos System
 First of All lets see what is linking

 Linking is the Process of collecting and combining various pieces of code
and data into single fie.
 Thus this file can be Loaded (Copied) into Main MEMORY and executed.
 Linking can be performed at compile time, when the source code is
translated into machine code, at load time, when the program is loaded
into memory and executed by the loader, and even at run time, by
application programs.
Linkers Intro.
 On early computer systems, linking was performed manually.
 On modern systems, linking is performed automatically by programs called
linkers.
 Linkers play a crucial role in software development because they enable
separate compilation.
 Instead of organizing a large application as one monolithic source file, we
can decompose it into smaller, more manageable modules that can be
modified and compiled separately.
 When we change one of these modules, we simply recompile it and relink
the application, without having to recompile the other files
Understanding Linkers will do???
 Understanding linkers will help you build large programs. Programmers
who build large programs often encounter linker errors caused by
missing modules, missing libraries, or incompatible library versions. Unless
you understand how a linker resolves references, what a library is, and
how a linker uses a library to resolve references, these kinds of errors will
be baffling and frustrating.
 Understanding linkers will help you avoid dangerous programming
errors. The decisions that Unix linkers make when they resolve symbol
references can silently affect the correctness of your programs.
Programs that incorrectly define multiple global variables pass through
the linker without any warnings in the default case. The resulting
programs can exhibit baffling run-time behavior and are extremely
difficult to debug.
 Understanding linking will help you understand other important systems
concepts. The executable object files produced by linkers play key
roles in important systems functions such as loading and running
programs, virtual memory., paging, and memory mapping.
 Understanding linking will enable you to exploit shared libraries. For
many years, linking was considered to be fairly straightforward and
uninteresting. However, with the increased importance of shared
libraries and dynamic linking in modern operating systems, linking is
a sophisticated process that provides the knowledgeable
programmer with significant power. For example, many software
products use shared libraries to upgrade shrink-wrapped binaries at
run time. Also, most Web servers rely on dynamic linking of shared
libraries to serve dynamic content.
===== LinKing =====
 The Linker Diagram:-
More about Linking
 Static Linking
 all code modules are copied into a single executable file
the same shared module may exist in many files
 a location in this file implies the location in the memory image
 target address for cross-module reference can be determined before
run time
 Dynamic Linking
 needs help from OS ( that means the scheme varies depending on OS)
 library modules are usually linked dynamically
 inserts symbolic references in the executable file
 these symbols are resolved at run time
Object Model Format
 The Object Module of MS DOS differs from the intel specification in
some respects .We also make some simplification for the purpose of this
discussion. Details of the object module are as follows:
 “An Object module is a sequence of object records.”
 There are 14 types of object records, in which they contain 5 kinds of
information :-
 Binary Image , i.e the code and data generated by translator.
 External references.
 Public Definitions
 Debugging information such as line number in the source program.
 Miscellaneous information such as comments in the source program.
Object Records Of Intel 8088
Record Type Id(Hex) Description
THREADR 80 Translator header record
LNAMES 96 List of names record
SEGDEF 99 Segment definition record
EXTDEF 8C External names definition
PUBDEF 91 Public names definition record
LEDATA A1 Enumerated data(Binary Image)
LIDATA A3 Repeated data(binary Image)
FIXUPP 9D Fix up (i.e. relocation) record
MODEND 8B Module end record
Sample MS DOS assembly language
program
Sr.no Statement Offset
0001 NAME FIRST
0002 COMPUTE SEGMENT
0003 EXTERN
PHI:BYTE,PSI:WORD
0004 PUBLI APLHA, BETA
0007 ALPHA . . . . . . . 0015
. . .
. . .
. . .
0012 MOV AX, SEG PHI 0028
. . .
. . .
. . .
0029 BETA .. . . . . . . . . 0084
0036 COMPUTE ENDS
Design of Linker
 For linking in MS Dos system we will design a program named LINKER which
performs both linking and relocation of absolute segments and of re
locatable segments that cannot be combined with other re
locatable segments.
 Its output is a binary program which resembles a program with .COM
extension in MS DOS.
 This program is not relocated by the loader prior the execution .
 (Note:- the difference between the LINKER and the LINK program of MS DOS
:LINK produces a program with .EXE extension, which is relocated by the
loader prior to execution)
Specification
 The LINKER invocation command has the following format:
 LINKER <object module names> ,<executable file>,
<load origin>, <list of library files>
 The linker performs relocation and linking of all named object modules to
produce a binary program with the specified load origin.
 The program is stored in the file with the name <executable file>.If the
LINKER comes across an external symbol that is not defined in any of the
object modules named in th LINKER command, it locates ian object
module in one of the library files included in <list of library files>that contains
a public definitions.
 This method of resolving an external reference by automatically including
an object module form a library file is called “AUTOLINKING”.
Datastructures.
 Here the linker program has two pass organization .
 In first pass object modules are processed to collect information concering
segments and public definations into name table(NTAB)
 The second pass performs relocation and linking to produce a binary
program.
General Shortcut to remember of ms
dos linking
 pass 1:
allocates segments defined in SEGDEF
resolve external symbols
 pass 2:
prepare memory image
if needed, disk space is also used
expand LIDATA
relocations within segment
write .EXE file
General Difference between linux and
ms dos linker
 Linux linker GOT(Global Offset table ) & lazy modeling.
 Where as the ms dos linker does pass 1 & pass2 linking wise
Thank you
 Any questions

More Related Content

PPTX
Fundamentals of Language Processing
PPTX
Ch 4 linker loader
PDF
Macro-processor
PPTX
System Programing Unit 1
PDF
loaders and linkers
PPTX
Unit 3 sp assembler
PPTX
Linker and Loader
PPTX
Macro Processor
Fundamentals of Language Processing
Ch 4 linker loader
Macro-processor
System Programing Unit 1
loaders and linkers
Unit 3 sp assembler
Linker and Loader
Macro Processor

What's hot (20)

PPTX
Unit 4 sp macro
PPTX
Life cycle of a computer program
PPTX
Language processing activity
PPT
Software tools
PPTX
Single pass assembler
PPTX
System Programming- Unit I
PPTX
System Programming Overview
PPTX
Loaders ( system programming )
PPTX
System software - macro expansion,nested macro calls
PPTX
COMPILER DESIGN OPTIONS
PPT
Pass 1 flowchart
PPTX
Design of a two pass assembler
PPTX
Assemblers
PPT
PPSX
Spr ch-02
PPTX
Compilers
PPTX
Introduction to loaders
PPTX
Introduction to system programming
PPTX
MACRO PROCESSOR
Unit 4 sp macro
Life cycle of a computer program
Language processing activity
Software tools
Single pass assembler
System Programming- Unit I
System Programming Overview
Loaders ( system programming )
System software - macro expansion,nested macro calls
COMPILER DESIGN OPTIONS
Pass 1 flowchart
Design of a two pass assembler
Assemblers
Spr ch-02
Compilers
Introduction to loaders
Introduction to system programming
MACRO PROCESSOR
Ad

Viewers also liked (20)

PPTX
Linkers
DOCX
MASM -UNIT-III
PPT
UNIX introduction
PDF
Lecture11 syntax analysis_7
PPTX
C LANGUAGE - BESTECH SOLUTIONS
PPTX
Unix Introduction
PPTX
Introduction to C programming
PPTX
Structure of c_program_to_input_output
PPT
Structure of a C program
PPTX
Inline functions & macros
PDF
Solaris basics
PPT
C material
PPTX
Direct linking loaders
PPT
Linkers And Loaders
PPT
System software
PPT
SYSTEM SOFTWARE
PPTX
Direct linking loader
PPTX
Overview of c language
PPTX
PDF
Unix system programming
Linkers
MASM -UNIT-III
UNIX introduction
Lecture11 syntax analysis_7
C LANGUAGE - BESTECH SOLUTIONS
Unix Introduction
Introduction to C programming
Structure of c_program_to_input_output
Structure of a C program
Inline functions & macros
Solaris basics
C material
Direct linking loaders
Linkers And Loaders
System software
SYSTEM SOFTWARE
Direct linking loader
Overview of c language
Unix system programming
Ad

Similar to Linking in MS-Dos System (20)

PPTX
Linkers in compiler
PPT
Loaders and Linkers
PPT
loaderfffffffffffffffffffffffffffflinker.ppt
PPTX
Linkers
PPT
PDF
Hm system programming class 1
PPTX
linker & loader presentation in Compiler Design
PDF
Linker and Loader Explained
PDF
Address Binding Scheme
PPTX
System software module 3 presentation file
PPT
assem.ppt
PDF
Handout#11
PPT
Loaders complete
PDF
Unit 3
PPTX
Loader and Its types
PPT
Mod 5.3 - Linkers & Loaderss Summary.ppt
PPTX
Linker and loader upload
PPTX
Assembly-and-Linking-From-Instructions-to-Execution.pptx
PPTX
C++ shared libraries and loading
PPTX
Linkers in compiler
Loaders and Linkers
loaderfffffffffffffffffffffffffffflinker.ppt
Linkers
Hm system programming class 1
linker & loader presentation in Compiler Design
Linker and Loader Explained
Address Binding Scheme
System software module 3 presentation file
assem.ppt
Handout#11
Loaders complete
Unit 3
Loader and Its types
Mod 5.3 - Linkers & Loaderss Summary.ppt
Linker and loader upload
Assembly-and-Linking-From-Instructions-to-Execution.pptx
C++ shared libraries and loading

More from Satyamevjayte Haxor (17)

DOCX
Processes and threads
PPTX
PPT
Uml class Diagram
DOCX
Uml Common Mechanism
PPTX
Types and roles
DOCX
States machine
PPTX
What is symbol table?
PPTX
PPTX
PPTX
sCode optimization
PPTX
Single Pass Assembler
PPTX
Nested micro
PPTX
Multiplier control unit
PPTX
Control unit design
PPTX
Two pass Assembler
PPTX
Compilers
PPTX
Keyword Presentation
Processes and threads
Uml class Diagram
Uml Common Mechanism
Types and roles
States machine
What is symbol table?
sCode optimization
Single Pass Assembler
Nested micro
Multiplier control unit
Control unit design
Two pass Assembler
Compilers
Keyword Presentation

Recently uploaded (20)

PDF
System and Network Administraation Chapter 3
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
medical staffing services at VALiNTRY
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
L1 - Introduction to python Backend.pptx
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Online Work Permit System for Fast Permit Processing
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Design an Analysis of Algorithms I-SECS-1021-03
System and Network Administraation Chapter 3
Wondershare Filmora 15 Crack With Activation Key [2025
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
ISO 45001 Occupational Health and Safety Management System
Which alternative to Crystal Reports is best for small or large businesses.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
medical staffing services at VALiNTRY
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Odoo POS Development Services by CandidRoot Solutions
L1 - Introduction to python Backend.pptx
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
How to Migrate SBCGlobal Email to Yahoo Easily
Odoo Companies in India – Driving Business Transformation.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Online Work Permit System for Fast Permit Processing
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Design an Analysis of Algorithms I-SECS-1021-03

Linking in MS-Dos System

  • 1. Linking In MS-DOS Shubham Shah Yashashwi Mahindrakar Sagar Nadgauda
  • 2. Linking In MS Dos System  First of All lets see what is linking
  Linking is the Process of collecting and combining various pieces of code and data into single fie.  Thus this file can be Loaded (Copied) into Main MEMORY and executed.  Linking can be performed at compile time, when the source code is translated into machine code, at load time, when the program is loaded into memory and executed by the loader, and even at run time, by application programs.
  • 3. Linkers Intro.  On early computer systems, linking was performed manually.  On modern systems, linking is performed automatically by programs called linkers.  Linkers play a crucial role in software development because they enable separate compilation.  Instead of organizing a large application as one monolithic source file, we can decompose it into smaller, more manageable modules that can be modified and compiled separately.  When we change one of these modules, we simply recompile it and relink the application, without having to recompile the other files
  • 4. Understanding Linkers will do???  Understanding linkers will help you build large programs. Programmers who build large programs often encounter linker errors caused by missing modules, missing libraries, or incompatible library versions. Unless you understand how a linker resolves references, what a library is, and how a linker uses a library to resolve references, these kinds of errors will be baffling and frustrating.  Understanding linkers will help you avoid dangerous programming errors. The decisions that Unix linkers make when they resolve symbol references can silently affect the correctness of your programs. Programs that incorrectly define multiple global variables pass through the linker without any warnings in the default case. The resulting programs can exhibit baffling run-time behavior and are extremely difficult to debug.
  • 5.  Understanding linking will help you understand other important systems concepts. The executable object files produced by linkers play key roles in important systems functions such as loading and running programs, virtual memory., paging, and memory mapping.  Understanding linking will enable you to exploit shared libraries. For many years, linking was considered to be fairly straightforward and uninteresting. However, with the increased importance of shared libraries and dynamic linking in modern operating systems, linking is a sophisticated process that provides the knowledgeable programmer with significant power. For example, many software products use shared libraries to upgrade shrink-wrapped binaries at run time. Also, most Web servers rely on dynamic linking of shared libraries to serve dynamic content.
  • 6. ===== LinKing =====  The Linker Diagram:-
  • 7. More about Linking  Static Linking  all code modules are copied into a single executable file the same shared module may exist in many files  a location in this file implies the location in the memory image  target address for cross-module reference can be determined before run time  Dynamic Linking  needs help from OS ( that means the scheme varies depending on OS)  library modules are usually linked dynamically  inserts symbolic references in the executable file  these symbols are resolved at run time
  • 8. Object Model Format  The Object Module of MS DOS differs from the intel specification in some respects .We also make some simplification for the purpose of this discussion. Details of the object module are as follows:  “An Object module is a sequence of object records.”  There are 14 types of object records, in which they contain 5 kinds of information :-  Binary Image , i.e the code and data generated by translator.  External references.  Public Definitions  Debugging information such as line number in the source program.  Miscellaneous information such as comments in the source program.
  • 9. Object Records Of Intel 8088 Record Type Id(Hex) Description THREADR 80 Translator header record LNAMES 96 List of names record SEGDEF 99 Segment definition record EXTDEF 8C External names definition PUBDEF 91 Public names definition record LEDATA A1 Enumerated data(Binary Image) LIDATA A3 Repeated data(binary Image) FIXUPP 9D Fix up (i.e. relocation) record MODEND 8B Module end record
  • 10. Sample MS DOS assembly language program Sr.no Statement Offset 0001 NAME FIRST 0002 COMPUTE SEGMENT 0003 EXTERN PHI:BYTE,PSI:WORD 0004 PUBLI APLHA, BETA 0007 ALPHA . . . . . . . 0015 . . . . . . . . . 0012 MOV AX, SEG PHI 0028 . . . . . . . . . 0029 BETA .. . . . . . . . . 0084 0036 COMPUTE ENDS
  • 11. Design of Linker  For linking in MS Dos system we will design a program named LINKER which performs both linking and relocation of absolute segments and of re locatable segments that cannot be combined with other re locatable segments.  Its output is a binary program which resembles a program with .COM extension in MS DOS.  This program is not relocated by the loader prior the execution .  (Note:- the difference between the LINKER and the LINK program of MS DOS :LINK produces a program with .EXE extension, which is relocated by the loader prior to execution)
  • 12. Specification  The LINKER invocation command has the following format:  LINKER <object module names> ,<executable file>, <load origin>, <list of library files>  The linker performs relocation and linking of all named object modules to produce a binary program with the specified load origin.  The program is stored in the file with the name <executable file>.If the LINKER comes across an external symbol that is not defined in any of the object modules named in th LINKER command, it locates ian object module in one of the library files included in <list of library files>that contains a public definitions.  This method of resolving an external reference by automatically including an object module form a library file is called “AUTOLINKING”.
  • 13. Datastructures.  Here the linker program has two pass organization .  In first pass object modules are processed to collect information concering segments and public definations into name table(NTAB)  The second pass performs relocation and linking to produce a binary program.
  • 14. General Shortcut to remember of ms dos linking  pass 1: allocates segments defined in SEGDEF resolve external symbols  pass 2: prepare memory image if needed, disk space is also used expand LIDATA relocations within segment write .EXE file
  • 15. General Difference between linux and ms dos linker  Linux linker GOT(Global Offset table ) & lazy modeling.  Where as the ms dos linker does pass 1 & pass2 linking wise
  • 16. Thank you  Any questions

Editor's Notes

  • #12: Differnce between ms dos linker and linux linker