![]() |
VOOZH | about |
In computer programming, addressing modes help the CPU find data in memory. Two common types are direct addressing and indirect addressing.
In direct addressing mode, the instruction contains the exact memory address of the operand. The CPU directly accesses this address to retrieve or store data without any extra lookup.
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.
In indirect addressing mode, the instruction gives an address that points to another location containing the actual operandโs address. The CPU first accesses the pointer and then the real data, making it more flexible but slower than direct addressing.
Example: Load the content of the memory location stored at memory location 1500 to register R1.
LOAD R1, @1500
Here, effective address is stored at memory location 1500.
Following is a comparison between both addressing modes:
| Direct Addressing | Indirect Addressing |
|---|---|
| Contains the effective address directly. | Contains the address of a location holding the effective address. |
| One memory access. | Two memory accesses. |
| Faster. | Slower. |
| No subtypes. | Memory Indirect and Register Indirect. |
| No extra calculation. | Extra calculation required. |
| Smaller address space. | Larger address space. |
| No additional overhead. | More overhead. |
| Simple and fast. | Flexible and allows larger addressing. |
| Limited address space. | Slower due to extra steps. |
| Accessing static data and variables. | Pointers and passing arrays. |
| Less flexible (fixed addressing). | More flexible (dynamic addressing). |
| Less code, simple. | More code, more complex. |