![]() |
VOOZH | about |
Addressing modes are methods utilise by a CPU in computer architecture to access data stored in memory. It is in this respect that different addressing modes are employed depending on the manner in which the data or the instruction is required to be accessed and/or dealt with. There are two basic addressing modes; Relative Addressing Mode and Direct Addressing Mode. These two modes are different and they differ in the manner they are deployed in business depending on the flexibility required in a certain task or project.
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 + DisplacementFigure - PC Relative Addressing Mode
Relative Addressing Mode can be further classified into three types -
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. Example - ADD R1, 4000 where 4000 is the effective address of the location.
Figure - Direct Address Mode In this example, the memory location 4000 contains the operand 100 which gets added to the contents of R1 and gets stored in R1.
| RELATIVE ADDRESSING MODE | DIRECT ADDRESSING MODE |
|---|---|
| The 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. |
| The relative mode has three types: PC Relative, Index Register Relative, and Base Register Relative Addressing modes. | Direct addressing mode has no types. |
| It results in a shorter address field in the instruction format as the relative address can be specified with a small number of bits. | It results in a longer address field in the instruction format as it requires more bits to designate the entire memory address. |
| It is often used with branch-type instructions since it directly updates the program counter. | It is not used in branch type of instructions. |
| It is used for writing relocatable code, and position independent code, i.e. for program relocation at run time. | It is used to access static data. |
| It is used to implement array addressing, and records. | It is used to implement variables. |
| It is used to handle recursive procedures. | It cannot handle recursive procedures. |
The PC Relative or Base Relative Addressing mode is favored over the direct addressing mode because- iii) It will be simpler to relocate. | It is less preferable to use over PC Relative or Base Relative Addressing mode. |
| Advantage- Flexible | Advantage- Simple to use as no intermediary is involved for referencing memory. |
| Disadvantage- Complexity | Disadvantage- Address space limit |
| Application- It aids in run-time program relocation and instruction sequence modification. | Application- It assists in accessing static data and implementing variables. |
Overall, Relative addressing mode and Direct addressing mode are two different ways of accessing memory in computer architecture. Direct addressing mode is simpler and more efficient, but has the limitation of not allowing relocatable code, while Relative addressing mode allows for relocatable code but requires additional calculation to determine the memory address.