Вы находитесь на странице: 1из 13

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

S stem Programming
Recommend 1.5k

Press Ctrl & '+' To enlarge te t and pics!

Chap e
Home Topics Chapter 1 : Basics of S stem Programming Chapter 2 : Editors Chapter 3 : Assemblers Chapter 4 : Compilers Chapter 5 : Debugger Chapter 6 : Linkers, Loaders, Micro-language, Microprocessor & Programming Language Chapter 6 : Part 2 Chapter 6 : Part 3 Chapter 6 : Part 4 Chapter 7 : Operating S stem

Home

Chap e 6 : Linke , Loade , Mac o Lang age, Mac op oce o and P og amming Lang age (Pa 1)

Q 1 In a two pass direct linking loader what is the function of passI? Ans The main task of loader is to load a source program into its memory and then prepare it for further execution In pass-I of direct link loaders allocates segment and define symbols for lexical analysis Each symbol in this phase assigned to next available location after the preceding segment in order to minimise amount of storage required for the total program Hence, pass-I deals with only for allocate segment end defining symbols Therefore, pass I of direct link loader the limited scope and is oblized and mainly deals for allocation of segment and defining of symbols Q 2 At what point of time do the direct linking loading scheme perform binding? Ans. Direct line loader basically deals with allocating of segments and defining symbols as a part of lexical analysis for pass-I It performs binding in pass-lI By binding we mean that linking the subroutines and addresses Aftei allocation of locations and external symbols by pass-I, it is easy to complete loading and linking Hence, direct link loader perfoims binding at load time Q 3 At what point of time do the absolute loader scheme perform binding

Ans The loader loads a source program into memory and then prepares it for further execution Absolute loader distinguishes from othcr types of loader, as it performs binding before run-time By binding we mean that linking the subroutines and addresses Both linking and loading are performed in absolute loader scheme and the execution of that particular program begins. Hence, binding in case of absolute loader scheme performs binding as well as execution of a program

ptucse.loremate.com/sp/node/6

1/13

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

Q. 4 What is loading of a program? Ans. Loading The loading is a process of preparing given object due for execution and moving it to the main memory for further execution Loading refers to following set of functions: (1) Loading : In loading, it places the machine instructions and data into main memory for further operation. (ii) Linking : The linking process resolves the symbolic references existing between the object decks. (iii) Allocating : The allocation process concerned with allocating memory for programmes. (iv) Relocation: it adjusts all address dependent locations to corresponding allocated addresses. (v) Execution This module prepares the input program for further execution.

Q. 5. List advantages of binding at load time over binding at assembl time. Ans. Binding basically deals with allocating segments and defining symbols as a part of lexical analysis. It perform binding during pass-Il. By binding we mean linking the subroutines and addresses. After allocating locations and external symbols by passI. Hence it is easy to complete loading and linking simultaneously. The advantages of binding at load band over binding at assembly for is as follows: (i) Dead lock avoidance : The pre-emptivness of processes leads to better multi programming. (ii) Less memory required : The execution of program larger than avaiLable memory is possible. (iii) It leads to more time complexity than others. (iv) Better utilization of memory : Since during binding at load time, there is no wastage of memory due to unused instructions and linkages. Hence memory is better utilized. (v) Increased throughout : The central processing unit is better utilized and thus increases throughout. Q. 6. At what point of time does direct linking loader (DLL) perform binding? Ans. Binding is basically deals with allocating segments and defining symbols as a part of lexical analysis. It performs binding during Pass-Il. By binding we mean linking the subroutines and addresses. After allocating location and external symbol by pass-I.
ptucse.loremate.com/sp/node/6 2/13

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

, .

Q. 7. I i defini ion? An . A

e ha call lead

an fe of con ol o mac o

. W , . A . H , .

. I

Q. 8. Wha a e ad an age of di ec linking loade ? An . T E . I . -I

. H -I D L L (DLL)

.. Q. 9. Li An . T . I . A () T . ( )A ( )I D () T ( ) T .
ptucse.loremate.com/sp/node/6 3/13

he f nc ion of loade

. ,

: ,

. . : .

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

Q. 10. What is the role of a linker in program execution? Ans. As the loader performs the following functions 1. Allocation of space in memory for programs. - and 2. Resolving symbolic references between object decks. with 3. Adjust all address dependent locations such as address constants. 4. Place the machine instructions and data into memory. So. the linker plays a very important role in it. For example, consider the concept of is subroutine linkage. Here, a main program A wishes to transfer to subprogram B. The user in program A transfer instruction to program B as; BAL14, B However assembler does not knows value of this symbol reference and declare an used error. Using the concept of linkage pseudo-op we can remove this error. Q. 11. Define loader, go . Ans. Definition : The loader is a program which accepts the object program decks, the prepares these programs for execution by the computer, and initiates the execution of program. e.g. user s source program decks are usually converted to object program decks (machine language) by assemblers and compilers. Q. 12. What are the various functions performed by the loaders? Explain. Ans. Functions: functions:
. . .

In particular, the loader must perform these

Allocate spare in memory for the programs (allocation). Resolve symbolic references between objects decks (linking). Adjust all address, dependent locations, such as address constants, to correspond to the allocated space (relocation). Physically place the machine instructions and data into memory (loading). Performing all operations operator and operands. and machine instruction on

ptucse.loremate.com/sp/node/6

4/13

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

Most of the examples used in this section are based upon IBM System! 370 assembler and loader Several of the alternative loader schemes discussed are based upon computers with a fixed-word, direct-address instruction format, such as the IBM 7094, IBM 1130, UNIVAC 1108 and GE 635. Q. 13. What are the Compile-and-Co loaders ? E plain. Ans. Compile-and-Go Loaders Ohe method of performing the loader functions is to have the assembler run in one part of memory and place the assembled machine instructions and data, as they are ssembled, directly into their assigned memory locations. When the assembly is completed, the assembler causes a transfer to the starting instruction of the program. This is a simple solution, involving no extra procedures. It is used by the WATFOR FORTRAN compiler and several other language processers Such a loading scheme is commonly called compile-and-go or assemble-andgo. It is relatively easy to implement. The assembler simply places the code into core, and the loader consists of one instruction that transfers to the starting instruction of the newly assembled program

ptucse.loremate.com/sp/node/6

5/13

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

Q 14. What are the various advantages and disadvantages of dynamic linking Ans An advantage here is that noverhead is incu i red unless the procedure to be called or referenced as actually used A further advantage is that system can be dynamically reconfigured The major drawback to using this type of loading scheme is the considerable overhead and complexity incurred, due to the fact that we have postponed most of the binding process until execution time. Q. 15. What is the general loader scheme? Explain. Ans. General loader Scheme : The use, of an object deck as intermediate data to avoid one disadvantage of the preceding compile-and-go scheme requires the addition. of a new program to the system, a loader. The loader accepts the assembled machine instructions, data, and other information present in the object format, and places machine instructions and data in core in an executable computer form. The loader is assumed to be, smaller than the assembler, so that more memory is available to the user. A further advantage is that reassembly is no longer necessary to run the program at a later date.

Q 16 What are the functions performed by absolute loading scheme Explain Ans The four loader functions are accomplished as follows in an absolute loading scheme: 1 Allocation-by programmer 2 Linking-by programmer 3 Relocation-by assembler
ptucse.loremate.com/sp/node/6 6/13

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

4 Loading-by loader

Q 17 What are the uses of multiple entry points Ans The uses of multiple entry points are I Common coding Example SIN and COS involve basically the same computations and could employ different entry points of the same routine. 2. Collecting together related routines for convenience. 3. Better or convenient access to common data base. Q 18 What are subroutine reference or extern pseudo-ops Ans. SUBROUTINE REFERENCE (EXTRN PSEUDO-OP) Assembler symbols are either internal or external External means that their value is not known to the assembler but will be provided by the loaderthe action of the loader wilibe discussed in the following section. EXTRN El, E2, etc. defines El, E2, etc. as external symbols to be used in address constants.

Q. 19. What do you meant by macro instructions? Ans Macro Instructions The macro is an abbreviation for a sequence of operations. Consider the following program:

ptucse.loremate.com/sp/node/6

7/13

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

A i

ac e hi

faci i a a ei

a ach a a

hi

e ce a d

ace. We ca i e he ab e a a ac a e . We ha e ch e

a ac a g age ha a ecif defi i i a d a he defi i i e a 360e ac a g age. o i e a e a ae

Q 20 Wha a e mac o p oce An . A a g age ac ce ce ihi ed a a :

effec i e c a g age.

I ha bee f

Q. 21. Wha a e ha i pe fo m? An . The e a e f ce e f

he

a io

mac o in

c ion p oce

ba ic .

ha

ac

ci

I Rec g i e ac defi i i A ac i ci ce ec g i e ac defi i i ide fified b he MACRO a d MEND e d . Thi a ca be c ica ed he ac defi i i a ea i hi ac Whe MACRO a d MEND a e e ed, a i he e a e f he e i ec i , he ac ce ec g i e he e i g a d c ec a ch he a e MEND i h he fi MACRO. A f he i e e i g e , i c di g e ed MACRO a d MEND , defi e a i g e ac i ci .
ptucse.loremate.com/sp/node/6 8/13

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

2. in

Sa e he defini ion : The p oce o m o e mac o c ion defini ion , hich i ill need fo e panding mac o call . ecogni e mac o call ha gge ha mac o name

3 Recogni e call The p oce o m appea a ope a ion mnemonic Thi be handled a a pe of op-code.

4 E pand call and b i e a g men The p oce o m b i e fo d mm o mac o defini ion a g men he coi e ponding a g men f om a mac o call he e l ing mbolic (in hi ca e, a cmbl lang age) e i hen b i ed fo he mac o call I hi e of co L, ma con ain addi ional mac o defini ion o call . Q 22 Wha a e he da aba e ed in mac o p oce o ed

An Specifica ion of Da a Ba e The follo ing da a ba e a e b he o pa e of he mac o p oce o Pa I da a ba e mac o o p mac o o ce deck ce deck cop fo e b pa ed o ed o 2 I The inp 2 The o

3. The Mac o Defini ion Table (MDT), mac o defini ion 4 The Mac o Name Table (MNT), defined mac o

o e he bod of he o e he name of

5 The Mac o Defini ion Table Co n e (MDTC), ne a iable en in he MDT (MNTC), ed o b i 6. The Mac o Name Table Co n e ne a ailable en in he MNT. 7 The A g men Li fo d mm a g men Pa befo e 2 da a ba e mac o o o ce deck o be e panded ce deck A a (ALA),

ed o indica e he

ed o indica e he e inde ma ke

o ing a mac o defini ion

1 The cop of he inp 2 The o p a emble

ed a i

inp

o he

3 The Mac o Defini ion Table (MDT), c ea ed b pa 4 The Mac o Name Table (MNT), c ea ed b pa 5 The Mac o Defini ion Table Poin e (MDTP), ne line of e o be ed d ing mac o e pan ion A a (ALA), ed o b i 6 The A g men Li a g men fo
ptucse.loremate.com/sp/node/6

i ed o indica e he

e mac o call
9/13

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

the index markers in the stored macro definition 7 Stop Q 23 What are storage classes E plain Ans Storage classes PL/I offers the programmcr three classes of storage (1) static, (2) automatic, and (3) controlled Static storage is permanent and is assigned at compile time Static is the only storage available m many programming languages such as FORTRAN Automatic storage is allocated only when the procedure or block referencing it is being executed For example if there is a procedure SUBR with an automatic variable A on the first call SUBR will be assigned a location for A When the procedure is exited, A s space will be released for possible use by other procedui es It is possible that a different location will be assigned to A for each call to SUBR A is automatic storage and is assigned automatically at execution time Q 24 What is the block structure facilit programming languages provided b

Ans When a declaration of a variable is made in a program, there is a certain welldefined region of the program to which this declaration is applicable The block structure facility, in programming languages such as PL/I and ALGOL, controls the scope of declaration of variables Figure illustrates the use of these features (The reference numbers are not part of the program They are only used to refer to specific imes in the explanation)

In the outer block of the PL/I program in Figure 6.3, the variables S,X and N are defined as integers (fixed-point binary numbers); by default all variables in PL,/I are assumed to be automatic unless explicitly declared otherwise. This program has an inner block that extends from reference numbers 3 to 6. In the inner block the array A and variable X are declared to be real floating-point numbers; since these variables are automatic storage, they are only allocatedspace when the inner block is entered. This example
ptucse.loremate.com/sp/node/6 10/13

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

ae

e e a

: a iab e he b c a ed X b c e. he e N i a e

1. Thi g a i i ea a 2. The a a i ege ha

ha diffe e i e, a defi ed b

A i dec a ed be N ca i g a a ead defi ed i he e b c .

3 The a e e X S e he a iab e X, defi ed i a e a he c e a e f he a iab e S, defi ed i 2. Si ce he e a iab e a e f diffe e da a e , a a ica c e he a e f S a f ai e e e ai . Q. 25. Wha a e he a io in on 8086? E plain i h e ample . An A i (i) O e a i ( )O e a d ci f a i c c de) a d c ion fo ma

e e 4, ae e PL/I i gi

a ailable

ed f

c de (

c de ecifie he a be e f ed b he c e a d e a d i he da a be e a ed The i ci f a ecifie h he c de a d e a d a e bei g e e i a i ci f e a eca+b e a d ci ca be ci f 8 bi 16 bi . Acc ified i di g h ee e a he e c a a d b a e he e +, a e The f he I f a fa i d i e, he

e 8085, 8086 a d 8088 i a : ci ci ci ci ci : : b e

a e ca

(a) O e b e i (b) T (c) Th ee b e i (a) O e b e i (a) O e b e i

(1) ADD B : Thi i ci add he c e f egi e B i he acc a . F e a e 100,00,000 i bi a f i h 80H a a c de. Fi fi e bi 10000 ecif egi e B. The ADD e ai ed a d a be i acc h ee bi a . 000 a e c de f

e a di a

(ii) MOV A, B Thi i e a e 7814 i a i 01111000. The fi


ptucse.loremate.com/sp/node/6

ci c de f ea f

e he c e f egi e A. F MOV A, B. The bi a f f 78H MOV e ai , he e h ee 111


11/13

bi

01 a e

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

bits are binary code for register B. (iii) RAL: This instruction rotates the contents of accumulator to left by one bit, For example 17 is an opcode for RAL. (iv) HLT : This instruction stops the program, opcode for HLT is 76 for Intel 8085. (b) Two Byte instruction: (i) MVI A, 05 : This instruction moves register 05 to register A. In code form it is written as 3E, 05. The first byte instruction is 3E. This code is for MVI A. The second byte for instruction is 05 is data to be placed in A. (ii) MOV B, A: This instruction moves content of register A to B. In code form it is written as 47. (c) Three Byte Instruction: (i) LDA : This instruction loads the cntents of particular memory address to accumulator. For example 3A, 50, FC. This instruction (LDA, IC5OH) loads accumulator with contents of memory ldcation FC5OH. (ii) LXI: The instruction LXI loads the contents FC5OH to .-.L pair. For example: 21, 50 FC is opcode for LXI. 5C50H. This instruct (LXI H, FC5O) will place FC5OH in HT pair. Q. 26. De c ibe he f nc ion of each of he RLD, ESD, TXT and END ca d in a loade . An . In case of a loader, the object deck must contain all information needed for relocation and linking. There are four sections to the objects deck and thus four corresponding card formats as under: (i) External Symbol Dictionary card (ESD. (ii) instructions and data card, called text of program (TXT). (ii)
ptucse.loremate.com/sp/node/6 12/13

4/25/12

Chapter 6 : Linkers, Loaders, Macro Language, Macroprocessor and Progra

( )R ( )E T ( ) ESD . E ; ( )S )L ( )E RLD , :E D R SD RLD D

L (END).

D I

(RLD)

: ES!) . T (SD) (LD) (ER). , ID R D ) ID :

.T ( )T ( ) T ( )T ( TXT P , ( )E END END

(8

. : L :I S END . . T , A . F (PLA) . T , , TXT

RLD,ESD, TXT

ptucse.loremate.com/sp/node/6

13/13

Вам также может понравиться