Addressing Modes in Computer Architecture
The operation field of an instruction specifies the operation to be performed. This operation will be executed on some data which is stored in computer registers or the main memory. The way any operand is selected during the program execution is dependent on the addressing mode of the instruction. The purpose of using addressing modes is as follows:
- To give the programming versatility to the user.
- To reduce the number of bits in addressing the field of instruction.
Types of Addressing modes:
Immediate Mode: In this mode, the operand is specified in the instruction itself. An immediate mode instruction has an operand field rather than the address field.
Register Mode: In this mode, the operand is stored in the register and this register is present in the CPU. The instruction has the address of the Register where the operand is stored.
Register Indirect Mode:n this mode, the instruction specifies the register whose contents give us the address of operand which is in memory. Thus, the register contains the address of the operand rather than the operand itself.
Autoincrement/ decrement Mode: In this, the register is incremented or decremented after or before its value is used.
Relative Addressing Mode: It is a version of the Displacement addressing mode. In this, the contents of PC(Program Counter) are added to address part of the instruction to obtain the effective address.
Direct Addressing Mode: In this mode, the effective address of the operand is present in the instruction itself.
- Single memory reference to access data.
- No additional calculations to find the effective address of the operand.
Indirect Addressing Mode: In this, the address field of instruction gives the address where the effective address is stored in memory. This slows down the execution, as this includes multiple memory lookups to find the operand.
Base Register Addressing Mode: It is again a version of the Displacement addressing mode. This can be defined as EA = A + (R), where A is displacement and R holds a pointer to the base address.
Stack Addressing Mode: In this mode, the operand is at the top of the stack. For example ADD, this instruction will POP top two items from the stack, add them, and will then PUSH the result to the top of the stack.
Displacement Addressing Mode: In this the contents of the indexed register are added to the Address part of the instruction, to obtain the effective address of the operand.
For more reference, you can check the link https://www.tutorialandexample.com/addressing-modes/.