Page 122 - DCAP507_SYSTEM_SOFTWARE
P. 122
System Software
Notes 8.1.5 Relocating Loaders
Relocation is the procedure of modernizing the addresses used in the address sensitive instructions
of a program. It is essential that such an alteration should aid to carry out the program from
preferred area of the memory.
The assembler produces the object code. This object code gets executed after loading at storage
positions. The addresses of such object code will get specified only after the assembly process is
over. Thus, after loading,
Address of object code = Mere address of object code + relocation constant.
There are two kinds of addresses being produced: Absolute address and, Relative address. The
absolute address can be directly utilized to map the object code in the main memory. While the
relative address is only after the addition of relocation constant to the object code address. This sort
of adjustment needs to be completed in case of relative address before definite execution of the code.
Example: The classic example of relative reference is : addresses of the symbols defined
in the Label field, addresses of the data which is defined by the assembler directive, literals,
redefinable symbols. Likewise, the classic example of absolute address is the constants which
are produced by assembler are absolute.
The assembler computes which addresses are absolute and which addresses are relative
throughout the assembly process. Throughout the assembly process the assembler computes
the address with the aid of simple expressions.
Example: LOADA(X)+5
The expression A(X) means the address of variable X. The meaning of the above instruction is
that loading of the contents of memory location which is 5 more than the address of variable X.
Let us consider if the address of X is 50 then by above command we attempt to get the memory
location 50+5=55. Thus as the address of variable X is relative A(X) + 5 is also relative.
To compute the relative addresses the simple expressions are permitted. It is expected that the
expression should possess at the most addition and multiplication operations. A straightforward
exercise can be carried out to find out whether the specified address is absolute or relative. In the
expression if the address is absolute then put 0 over there and if address is relative then put lover
there. The expression then obtains transformed to sum of O's and l's. If the resultant value of the
expression is 0 then expression is absolute. And if the consequential value of the expression is 1
then the expression is relative. If the resultant is other than 0 or 1 then the expression is illegal.
Example:
Expression Computation Relocation Attribute
A - B 1 - 1 = 0 Absolute
A + B - C 1 + 1-1= 1 Relative
A - B + 5 1 -1 + 0 = 0 Absolute
A + B 1 + 1 = 2 Illegal
In the above expression the A, B and C are the variable names. The assembler is to consider the
relocation attributes and regulates the object code by relocation constant. Assembler is then
accountable to convey the information loading of object code to the loader.
116 LOVELY PROFESSIONAL UNIVERSITY