loaders

21
Loaders Loader is a program which accepts object program,prepares these program for execution

Upload: neetu-kalra

Post on 22-Nov-2014

119 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Loaders

LoadersLoader is a program which

accepts object program,prepares these program for execution

Page 2: Loaders

Execution of a program includes following steps:-

Translation of a programLinking of a programRelocation of a programLoading of a program

Page 3: Loaders

LoaderLinkerTranslator

Binary program

Object module

Binary program

Data

Result

Page 4: Loaders

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.

Page 5: Loaders

Various loader schemes are as follows:-

Compile and go loadersGeneral loader schemesAbsolute loaderSubroutine linkagesDirect linking loadersOther loader schemes

Page 6: Loaders

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.

Page 7: Loaders

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.

Page 8: Loaders

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.

Page 9: Loaders

C&go translator Program loaded In memory

assembler

Source program

COMPILE AND GO LOADER SCHEME.

Page 10: Loaders

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.

Page 11: Loaders

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.

Page 12: Loaders

loader

Source pro1 translator Object pro1

Source pro2 translator Object pro2

Object pro ready exec

loader

GENERAL LOADER SCHEME:-

Page 13: Loaders

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.

Page 14: Loaders

ADVANTAGESMore core available to user:- assembler is not in memory at load time.

Page 15: Loaders

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.

Page 16: Loaders

Absolute loader

Main

SQRT

Main

SQRT

100

248

400

478

EXAMPLE OF ABSOLUTE LOADER:-

Page 17: Loaders

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.

Page 18: Loaders

100k

A(20k)

B(20k)

C(30k)

D(10k)

E(20k)

(A) Subroutine calls between procedures

Page 19: Loaders

(B) Overlay structure:-

B(20k) D(10k)

70k

A(20k)

C(30k) E(20k)

Page 20: Loaders

(B) Overlay structure:-

B(20k) D(10k)

C(30k) E(20k)

70k

A(20k)

Page 21: Loaders

(C) Possible storage assignment of each procedure

A

B D

EC

0

40k

60k

80k

20k