Addressing Modes Computer organisation
Addressing modes specify the way in which the address of the operand is given in the instruction. Addressing mode gives the flexibility of writing programs.
eg MVI B, 05 : Here MVI (Move Immediate) is the opcode part and the rest is the operand part.
MOV A , B : Here MOV is the opcode part and the rest is the operand part.
ADD B : Here ADD is the opcode part and the rest is the operand part.
The following are the various addressing modes used very commonly.
- Immediate Addressing Mode
- Direct Addressing Mode
- Indirect Addressing Mode
- Displacement Addressing Mode
- Auto increment / Auto Decrement Addressing Mode
- Scaled Addressing Mode
Immediate Addressing Mode
In Immediate Addressing mode the operand itself is present in the instruction. It is generally used for accessing constants. eg MVI B , 05
The advantage of Immediate Addressing mode is that no extra memory reference needed since the value of the operand is given itself in the instruction. So Immediate Addressing mode is the fastest addressing mode.
Direct Addressing Mode
In Direct Addressing mode the effective address of the operand is given directly in the instruction. So it require one extra memory reference to access the operand. The direct addressing mode is slow compared to immediate addressing mode. It is generally used to access static variables.
The format of Direct Addressing Mode is : Opcode Effective_Address_of_Operand
Indirect Addressing Mode
In Indirect addressing mode the reference for effective address of the operand is given in the instruction .In indirect addressing mode the operand part tells where the effective address of the operand is stored in memory.It is the slowest addressing mode. It is generally used for accessing local variables(eg: Arrays,Pointers)
The indirection in Indirect Addressing mode can be of varied level, For example Single Indirection,Double indirection etc.
The format of Indirect Addressing Mode is : Opcode Reference_to_Effective_Address_of_Operand
Single Indirection : The format is Opcode Reference_to_Effective_Address_of_Operand
Double Indirection: The format is Opcode Reference_to_Reference_to_Effective_Address_of_Operand
Displacement Addressing Mode
In Displacement addressing mode the Effective address of the operand is given by
Effective Address = Implicit Processor Register + Displacement
The following addressing modes comes in the category of Displacement Addressing mode.
- Base Addressing mode
- Index Addressing mode
- Relative Addressing mode
- Relative Base Addressing mode
Base Addressing mode : Base addressing mode is used in relocatable programs. Effective Address =Base Register + Displacement
Index Addressing mode : Index Addressing mode is used to stepping through array. Effective Address =Index Register + Displacement
Relative Addressing mode: Relative Addressing mode is used in intrasegment branching (Example GOTO).Effective Address =Program Counter + Displacement
Rlative Base Addressing mode : Effective Address = PC + BR + displacement . Where PC stands for program counter and BR stands for base register.
Auto Increment / Auto Decrement Addressing Mode
It is generally used to increment or decrement the array pointer. For example while executing a loop the processor may require to increment or decrement the pointer to the adjacent address at each iteration. So it can be used to increment or decrement file pointers, or it can be used to implemet stack in which the top can be incremented (TOP++) or decremented(TOP--).
Also in Auto increment or Auto decrement addressing mode the contents of the register is automatically incremented or decremented before or after the execution of the instruction . For Example MOV (R2)+, R1
Scaled Addressing Mode
It allows the portion of the operand to be extracted for manipulation depended on the scaling factor . It may access 1st byte , 2ndbyte , or the entire operand. For example in 8086 , in the instruction MOV BL , AH . Here the content of A move to B.