loaders
TRANSCRIPT
LoadersLoader is a program which
accepts object program,prepares these program for execution
Execution of a program includes following steps:-
Translation of a programLinking of a programRelocation of a programLoading of a program
LoaderLinkerTranslator
Binary program
Object module
Binary program
Data
Result
Loader must perform four functions:-
Allocation:- Allocate space in memory for programs.Linking:- Resolve symbolic references between object programs.Relocation:- Adjust all address dependent locations to correspond to the allocated space.Loading:- Physically places machine instruction in memory.
Various loader schemes are as follows:-
Compile and go loadersGeneral loader schemesAbsolute loaderSubroutine linkagesDirect linking loadersOther loader schemes
COMPILE AND GO LOADERS:-
One method of performing loader function is to have assembler run in one part of memory & place the assembled machine instructions & data as they are assembled directly in to their assigned memory location.
When assembly is completed assembler causes a transfer to the starting instruction of program.
USED BY:-
WATFOR FORTRAN COMPILER
ADVANTAGES:-
Easy to implement:- Assembler simply places the
code in to core & loader consist of one instruction that
transfers to the starting instruction of newly assembeled
program.
DISADVANTAGES:-
1. Portion of memory is wasted.2. Necessary to retranslate user’s
program every time it is run.3. Difficult to handle multiple
segments if source program are in different languages.
C&go translator Program loaded In memory
assembler
Source program
COMPILE AND GO LOADER SCHEME.
General loader scheme
Outputting the instructions and data as they are assembeled circumvents the problem of wasting core for assembler.such an output could be saved & loaded whenever code was to be executed.
In this loader accepts assembeled machine instructions present in object form & places machine instruction in core in an executable form.
ADVANTAGES:-Loader is assumed to be smaller than assembler :-more memory is available to user.Reassembly is no longer needed to run program at a later date.
loader
Source pro1 translator Object pro1
Source pro2 translator Object pro2
Object pro ready exec
loader
GENERAL LOADER SCHEME:-
ABSOLUTE LOADERS:-
In this scheme assembler outputs the machine language translation of s.p. in almost the same way as in compile and go scheme except that data is punched on cards,instead of being placed directly in to memory.
ADVANTAGESMore core available to user:- assembler is not in memory at load time.
DISADVANTAGES:-Programmer must specify to assembler the address in core where program is to be stored.Programmer must be careful not to assign two subroutine to the same location.
Absolute loader
Main
SQRT
Main
SQRT
100
248
400
478
EXAMPLE OF ABSOLUTE LOADER:-
OVERLAY:-
If the total amount of core required by all subroutines exceeds the amount available,as is common with large programs .
Usually the subroutines of a program are needed at different times.by explicitly recognizing which subroutine call other subroutines,it is possible to produce an overlay structure that identifies mutually exclusive subroutines.
100k
A(20k)
B(20k)
C(30k)
D(10k)
E(20k)
(A) Subroutine calls between procedures
(B) Overlay structure:-
B(20k) D(10k)
70k
A(20k)
C(30k) E(20k)
(B) Overlay structure:-
B(20k) D(10k)
C(30k) E(20k)
70k
A(20k)
(C) Possible storage assignment of each procedure
A
B D
EC
0
40k
60k
80k
20k