0% found this document useful (0 votes)
23 views18 pages

Understanding Program Relocation Techniques

Uploaded by

suneetha prabhu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views18 pages

Understanding Program Relocation Techniques

Uploaded by

suneetha prabhu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Program Relocation

Absolute Program : Program is loaded at specific


memory which is specified at assembly time
Eg: Starting address 1000
In real time systems, where many simultaneous
programs are executed, assembler will not know
where the program is actually loaded.
Parts of the addresses in object program need to
be modified accordingly based on where program
is actually loaded
Program Relocation

Therefore, assembler generates Relocatable


Program. The object program contains
information regarding the parts of the program
that need modification. The object program
generated by assembler starts at an address
000000.
Example
Program Relocation

NOTE:
Object codes having following do not require any
modification
PC-relative and Base-relative addresses
not a memory address (immediate addressing)

The only parts of the program that require


modification at load time are those that specify
direct addresses (Format-4 instructions in SIC/XE)
Program Relocation

2 methods for specifying relocation as part of


object program:
1. Using Modification Records
2. Using Bit Mask
Relocation using Modification Records
Relocation using Modification Records

Most of the instructions in SIC/XE use PC


Relative or Base Relative addressing. Some use
immediate addressing and register addressing.
These instructions do not require any
modification.
Instructions that contain actual addresses are
extended format (format-4). These require
modification during relocation.
Relocation using Modification Records

Modification record Format


Col 1 M
Col 2-7 Starting location of the address field to be
modified, relative to the beginning of the program
Col 8-9 length of the address field to be modified, in half-
bytes
Relocation using Modification Records
Line Location Object Code
1 000000 START COPY O
2 000000 FIRST STL RETADR ……..
3 000003 LDA LENGTH ……..
4 000006 +JSUB WRREC 4B101036
…. …………. ……….. ……….
…. ………….. ……….. ……….
10 000026 +JSUB RDREC 4B10105D
11 BUFFER RESW 1 …………
…………. ……….. …………
Relocation using Modification Records

In the above sample SIC/XE program, the


instructions that are affected by relocation are at
lines 4 and 10. They are extended format
instructions

000006 +JSUB WRREC 4B101036

Modification is needed to last 05 half Bytes.


i.e., 4B101036
Address of the instruction = 000006
Modification is needed starting at address = 000007
Relocation using Modification Records
000026 +JSUB RDREC 4B10105D

Modification is needed to last 05 half Bytes.


i.e., 4B10105D
Address of the instruction = 000026
Modification is needed starting at address = 000027
Relocation using Modification Records

Object Program with Modification Records

Header Record…………
Text Record 1……………
Text Record 2……………
Mꞈ000007ꞈ05

Mꞈ000027ꞈ05
Eꞈ000000
Relocation using Modification Records

Advantage:
The Modification record scheme is a convenient
way of specifying relocation

Disadvantage:
As number of format-4 instructions increase, the
number of modification records also increase.
Thereby increasing the size of object program
It is not recommended for a machine that uses
direct addressing mode
Relocation using Bit Mask
Relocation using Bit Mask

The text records in object program have a


relocation bit associated with each word of object
code
It is suitable when large number of relocations are
needed.
It is suitable for machines where only direct
addressing mode is used (Standard SIC)
Relocation using Bit Mask

Text record Format when Bit Mask is ued


Col 1 T
Col 2-7 Starting address
Col 8-9 length in Bytes
Col 10-12: Relocation Bits
Col 13-72: Object Codes
Relocation using Bit Mask

Example:
Tꞈ000000ꞈ1Eꞈ140003ꞈ4C0034ꞈ481061ꞈ…… ꞈ00002D
If in the above text record, modification has to be
done for first 3 object codes. Then the bit mask is
111000000000. Its hexadecimal value is E00.
The corresponding Text record with Bit Mask is
Tꞈ000000ꞈ1EꞈE00ꞈ140003ꞈ4C0034ꞈ481061ꞈ……
ꞈ00002D
Relocation using Bit Mask

A bit value 0 in mask represents no modification is


necessary
If relocation bit corresponding to an object code is
set to 1, then it has to be modified. Starting address
of the program is added to it when the program is
relocated
The relocation bits are gathered together into a Bit
Mask which is represented as 3 Hexadecimal digits.
If a text record contains fewer than 12 words of
object codes , the bits corresponding to unused
words are set to 0

You might also like