Prerequisite – Addressing Modes
In an Instruction Fetch operation of the Instruction Cycle Process, addressing mode plays a crucial part. Addressing Mode is the way in which the operand is addressed in an instruction word before being actually executed.
1. Relative Address Mode :
In this mode, the Effective Address (EA) of the operand is calculated by adding the content of the CPU register and the address part of the instruction word. The effective address is calculated by adding displacement (immediate value given in the instruction) and the register value. The address part of the instruction is usually a signed number, either positive or negative. The effective address thus calculated is relative to the address of the next instruction.
EA = CPU Register + Displacement
Relative Addressing Mode can be further classified into three types –
- PC (Program Counter) Relative Addressing Mode.
- Index Register Relative Addressing Mode or Indexed Addressing Mode.
- Base Register Addressing Mode.
2. Direct Address Mode :
In Direct Address Mode, the effective address of the operand is equal to the address part of the instruction, i.e. the address part of the instruction indicates the memory location containing the operand.
ADD R1, 4000 where 4000 is the effective address of the location.
In this example, the memory location 4000 contains the operand 100 which gets added to the contents of R1 and gets stored in R1.
Difference between Relative Addressing Mode and Direct Addressing Mode :
|S.NO.||RELATIVE ADDRESSING MODE||DIRECT ADDRESSING MODE|
|1.||Effective address is calculated by adding the contents of the CPU Register with the address part of the instruction.||The address for fetching the operand is already provided in the address part of the instruction. It is not calculated.|
|2.||Relative mode has three types : PC Relative, Index Register Relative, Base Register Relative Addressing modes.||Direct addressing mode has no types.|
|3.||It results in shorter address field in the instruction format as the relative address can be specified with a small number of bits.||It results in longer address field in the instruction format as it requires more number of bits to designate the entire memory address.|
|4.||It is often used with branch type instructions since it directly updates the program counter.||It is not used in branch type of instructions.|
|5.||It is used for writing relocatable code, position independent code, i.e. for program relocation at run time.||It is used to access static data.|
|6.||It is used to implement array addressing, records.||It is used to implement variables.|
|7.||It is used to handle recursive procedures.||It cannot handle recursive procedures.|
Attention reader! Don’t stop learning now. Learn all GATE CS concepts with Free Live Classes on our youtube channel.