Difference between Direct and Indirect Addressing Modes
Prerequisite: Addressing Modes
1. Direct Addressing Mode: In direct addressing mode, the address field in the instruction contains the effective address of the operand and no intermediate memory access is required. Nowadays it is rarely used.
Example: Add the content of R1 and 1001 and store back to R1:
Add R1, (1001)
Here 1001 is the address where the operand is stored.
2. Indirect Addressing Mode: In Indirect addressing mode, the address field in the instruction contains the memory location or register where the effective address of the operand is present. It requires two memory access. It is further classified into two categories: Register Indirect, and Memory Indirect.
Example:
LOAD R1, @500
The above instruction is used to load the content of the memory location stored at memory location 500 to register R1. In other words, we can say, effective address is stored at memory location 500.
Difference between Direct and Indirect Addressing Modes:
Parameters | Direct Addressing Mode | Indirect Addressing Mode |
---|---|---|
Address Field | Address field contains the effective address of operand. | Address field contains reference of effective address. |
Memory References | Requires only one memory reference | Requires two memory references |
Processing Speed | This addressing mode has fast addressing compared to indirect addressing mode | It is slower than direct addressing mode. |
Classification | No further classification | Further classified into two categories- Memory Indirect and Register Indirect Addressing Mode. |
Calculation | No further calculation is required to perform the operation. | Requires further calculation to find the effective address. |
Address Space | It occupies a smaller amount of space than the indirect mode. | It occupies a large amount of space than the direct mode. |
Overhead | No additional overhead is involved while searching for operand. | Additional overhead is involved while searching for operand. |
Advantage | Easy as no intermediary is involved. | Availability of large address space. |
Disadvantage | Address space is restricted. | Requires more number of memory references. |
Application | It aids in accessing static data and using variables. | It assists in passing arrays as parameters and implementing pointers. |
Feature | Direct Addressing | Indirect Addressing |
Addressing method | Explicit: address of the operand is directly specified in the instruction | Explicit: address of the operand is stored in a memory location specified by the instruction |
Flexibility | Less flexible: only allows for fixed memory addressing | More flexible: allows for more dynamic memory addressing |
Code size | Requires less code: operand address is directly specified in the instruction | Requires more code: additional instructions are needed to load the operand address from memory |
Execution speed | Faster: operand address is immediately available | Slower: additional memory accesses are required to obtain the operand address |
Complexity | Less complex: requires fewer instructions and is generally easier to debug | More complex: requires additional instructions and memory accesses, and can be more difficult to debug |
Contact Us