Professional Documents
Culture Documents
• Function of Loader
1. Allocation Allocates space in Memory for Program
2. Linking Resolves symbolic references between objects
codes
3. Relocation Adjust all the address dependent locations
4. Loading Physically place M/C instructions and data into
memory
Linkers and Loaders
• Advantages
– Simple to design
– Only one transfer instruction as a part of loader
• Disadvantages
– Memory wasted for holding assembler
– Necessary to re-translate code every time
– Source program need to be in one language only.
Assemble and Go Loader
General Loader Scheme
• Advantages
– No need of re-assembling of program at every execution
– Assembler need not be in memory
– Subroutines can be written in several languages
Absolute Loader
• Advantage
– Simple to implement
• Dis-advantage
– Programmer has to specify the physical address to
assembler where object code is to be loaded.
– Programmer should remember address of each subroutine
– Programmer should use those addresses explicitly to call
those functions.
– Programmer should take care of non-conflicting subroutine
address.
Absolute Loader
Absolute Loader
Absolute Loader
• Example:
MAIN START
EXTRN SUBROUT
----------
----------
L 15, =A(SUBROUT)
BALR 14, 15
-----------
END
Subroutine Linkages
SUBROUT START
USING *,15
----------
BR 14
END
Subroutine Linkages
• Example ENTRY
A START
ENTRY B1, B2, B3,….Bn
(entry points in subroutine)
-----------
B1 -------
B2 -------
END
Relocating Loaders
• Purpose:
– To reduce efforts of programmer to allocate and link the
object codes.
– To avoid re-assembling of all subroutines even if one is
modified.
• Assembler assembles every routine independently.
• Assembler has to provide object code and other
information to the loader to support the loader
functionalities.
• Binary Symbolic Subroutine is simple example of
relocating loader.
• It is used with system having fixed-length direct
address instruction
• BSS allows many procedure segments and one data
segment.
Relocating Loaders
Relocating Loaders
Relocating Loaders
• Advantages:
– All four functions are performed by Loader.
• Disadvantages:
– Transfer Vector can be used only for linking not for storage
of external data.
– Transfer vector increases the size of object code.
– Common data segment so every subroutine has to access it
in synchronization.
Direct Linking Loader