An instruction contains an operation field, an address field, and a mode field. The operation field indicates what operation is to be performed, for example, addition, subtraction, multiplication, etc. The mode field indicates how the memory address of the operand, which is to be used in an operation, is determined. To understand the various types of addressing modes, it is important to understand how the computer deals with instruction. The instruction cycle of a computer goes through the following three phases:
Fetch the instruction from the memory
Decode the instruction
Execute the instruction
Types of Addressing Modes
The various types of addressing modes are discussed below:
Implied mode
In this mode, the instruction contains an indirect definition of the operand. An example of an implied mode instruction is CMA (complement accumulator). Here, the operand (complement) is implicitly specified in the instruction.
Immediate addressing mode
In this mode, the instruction contains both the opcode and the operand. It can be said that an instruction that uses the immediate addressing mode contains an operand field in place of an address field. The operation, as well as the operands, are mentioned in the instruction. An example of immediate addressing mode instruction is ADD 10. Here, ADD, which is the operation, and 10, which is the operand, are specified.
Register mode
In this mode, the instruction specifies a register. This register stores the operand. An example of register mode instruction is:
AC = AC + [R]
This will add the operand stored at register R to the operand stored in the accumulator.
Register indirect mode
In this mode, the instruction specifies a register. This register stores the effective address of the operand. An instruction that uses register indirect addressing mode is:
AC = AC + [[R]]
Here, the contents which reside in the memory location specified by the register R will be added to the contents of the accumulator.
Direct addressing mode
In this mode, the instruction specifies an address. This address is the address of the operand. An example of a direct addressing mode instruction is:
AC = AC + [X]
This will add the operand stored at address X with the operand stored in the accumulator. This mode is also referred to as absolute addressing mode.
Indirect addressing mode
In this mode, the instruction specifies an address. The memory location specified by the address contains the address of the operand. An example of an indirect addressing mode instruction is:
AC = AC + [[X]]
This will add the operand stored at the address specified by the memory location X with the contents of the accumulator.
Auto-increment/decrement mode
In this mode, the instruction specifies a register which points to a memory address that contains the operand. However, after the address stored in the register is accessed, the address is incremented or decremented, as specified. The next operand is found by the new value stored in the register.
Relative address mode
In this mode, the contents of the address field are added to the constant stored in the program counter. The result of the addition gives the address of the operand. For example, suppose the address field contains 850, and the program counter contains 20, then the operand will be at memory location 850 + 20 = 870.
Indexed addressing mode
In this mode, the address of the operand is determined by adding the contents of the address field and the contents of the index register.
Base register addressing mode
In this mode, the address of the operand is determined by adding the contents of the address field and the contents of the base register.
Applications of Various Addressing Modes
The applications of various addressing modes are as follows:
Immediate addressing mode: Used to set an initial value for a register. The value is usually a constant
Register addressing mode/direct addressing mode: Used to implement variables and access static data
Register indirect addressing mode/indirect addressing mode: Used to pass an array as a parameter and to implement pointers
Relative addressing mode: Used to relocate programs at run time and to change the execution order of instruction
Index addressing mode: Used to implement arrays
Base register addressing mode: Used to write codes that are relocatable and for handling recursion
Auto-increment/decrement addressing mode: Used to implement loops and stacks
Purpose of Addressing Mode
The addressing modes serve the following purposes:
To decrease the number of bits contained in an instruction’s address field
To provide users with programming versatility by providing facilities such as counters, pointers, indexing, and program relocation
Conclusion
The addressing mode is one of the fields in an instruction. This field determines how and where an operand is fetched from the memory. The various types of addressing modes are:
Implicit addressing mode
Immediate addressing mode
Direct addressing mode
Indirect addressing mode
Register addressing mode
Register indirect addressing mode
Auto-increment/decrement addressing mode
Relative addressing mode
Indexed addressing mode
Base register addressing mode
Also check: