Advantages of relative addressing mode over direct address
Answers
Addressing modes are conventions which are used in assembly language programming. They specify the way in which certain values are read in a given segment of assembly instructions.
The PC relative addressing mode is more advantageous than the direct address. It can be utilized to load a register with a value stored in the program memory at a short distance from the current instruction. It can be viewed as a special case of the 'base plus offset' addressing mode. It selects the program counter (PC) as the 'base register'.
Addressing mode is an important aspect of the instruction set architecture in most of the central processing unit (CPU) designs. The various addressing modes that are defined in a given instruction set architecture define how machine language instructions in that architecture identify the operand(s) of each instruction.
In Absolute or Direct addressing mode, the effective address for an absolute instruction address is the address parameter itself with no modifications.
In Relative addressing mode, the effective address for a PC-relative instruction address is the offset parameter added to the address of the next instruction. This offset is usually signed to allow reference to code both before and after the instruction.
The advantage of using relative mode over direct mode is that relative addressing is a code which is position-independent, i.e. it can be loaded anywhere in memory without the need to adjust any addresses.
Also, relative addressing is particularly useful in connection with jumps, because typical jumps are to nearby instructions.
The direct "addressing mode" does not have an effective address and is not considered to be an addressing mode on some computers. In such cases, all the operands are in registers, and the result is placed in a register.