KEMBAR78
Addressing Modes in Computer Architecture | PDF | Computer Hardware | Integrated Circuit
0% found this document useful (0 votes)
96 views8 pages

Addressing Modes in Computer Architecture

Addressing modes are vital in computer architecture as they determine how operands are accessed in memory or registers, enhancing program efficiency. Common modes include Immediate, Register, Direct, Indirect, Indexed, Base-Register, Relative, Stack, Absolute, and Register Indirect, each with specific use cases, advantages, and limitations. Understanding these modes is crucial for optimizing code and designing effective algorithms.

Uploaded by

s4088225
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views8 pages

Addressing Modes in Computer Architecture

Addressing modes are vital in computer architecture as they determine how operands are accessed in memory or registers, enhancing program efficiency. Common modes include Immediate, Register, Direct, Indirect, Indexed, Base-Register, Relative, Stack, Absolute, and Register Indirect, each with specific use cases, advantages, and limitations. Understanding these modes is crucial for optimizing code and designing effective algorithms.

Uploaded by

s4088225
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Addressing Modes in Computer Architecture

Addressing modes are a crucial aspect of computer


architecture, as they define how the operands (data
values) for an instruction are accessed or located in
memory or registers. Each addressing mode provides a
mechanism for the processor to interpret the operand part
of an instruction. These modes enable greater flexibility
in how instructions interact with data, which is vital for
program efficiency and versatility.
Common Addressing Modes
Here are some of the common addressing modes used in
computer architecture:

1. Immediate Addressing Mode


 Definition: The operand is a constant value directly
specified in the instruction.
 Example: MOV R1, #5
o In this example, the value 5 is immediately

loaded into register R1.


 Usage: Immediate addressing is useful when you
need to use a constant value directly in the operation.
 Pros: Fast, as the operand is specified directly in the
instruction.
 Cons: Limited to small constant values that can fit
within the instruction encoding.

2. Register Addressing Mode


 Definition: The operand is located in a register, and
the instruction specifies the register.
 Example: ADD R1, R2, R3
o In this example, the values in R2 and R3 are

added together, and the result is stored in R1.


 Usage: Very fast because registers are the fastest
storage location in a processor.
 Pros: Fast access to operands; no memory access is
needed.
 Cons: Limited by the number of available registers.

3. Direct Addressing Mode


 Definition: The operand is located at a specific
memory address, which is specified directly in the
instruction.
 Example: MOV R1, [5000]
o The value stored at memory address 5000 is

loaded into register R1.


 Usage: Useful when the exact memory location is
known and does not change.
 Pros: Simple to implement.
 Cons: Lack of flexibility, as the operand’s address
must be fixed at compile-time.

4. Indirect Addressing Mode


 Definition: The operand's memory address is stored
in a register or memory location, and the instruction
specifies this address.
 Example: MOV R1, [R2]
o Here, R2 contains the memory address where the

operand is located. The value at that address is


moved into R1.
 Usage: Provides more flexibility than direct
addressing, as the address can change during runtime.
 Pros: Flexible and allows dynamic memory
management.
 Cons: Slightly slower than direct addressing due to
additional memory lookup.

5. Indexed Addressing Mode


 Definition: The effective address of the operand is
determined by adding an index value (often from a
register) to a base address (often specified in the
instruction).
 Example: MOV R1, [R2 + 10]
o In this case, the operand is located at the memory
address computed by adding 10 to the value in
register R2. The result is loaded into R1.
 Usage: Common in array accesses, where the index
specifies an offset from a base address.
 Pros: Flexible and efficient for accessing data
structures like arrays and tables.
 Cons: Requires additional computation to calculate
the effective address.

6. Base-Register Addressing Mode


 Definition: Similar to indexed addressing, but the
base address is stored in a register, and an offset
(either immediate or specified in the instruction) is
added to it.
 Example: MOV R1, [R2 + #5]
o The address is computed by adding the

immediate value 5 to the content of register R2.


 Usage: Often used in memory addressing for
accessing data in structures like arrays, where R2 may
hold the base address of an array.
 Pros: Efficient for dynamic data structures with fixed
offsets.
 Cons: Requires careful handling of offsets and base
addresses.
7. Relative Addressing Mode
 Definition: The operand’s address is determined by
adding an offset (relative to the current instruction
pointer or program counter) to the address of the
instruction.
 Example: JMP [PC + #8]
o Here, the instruction specifies that the jump

should occur to the memory location that is 8


bytes ahead of the current value of the program
counter (PC).
 Usage: Common in branching operations and control
flow (such as in jump, branch, and loop instructions).
 Pros: Useful for position-independent code (e.g., in
operating systems or interrupt handling).
 Cons: Limited by the size of the offset.

8. Stack Addressing Mode


 Definition: The operand is located at the top of the
stack. The stack is a last-in, first-out (LIFO) data
structure.
 Example: PUSH R1
o The value in register R1 is pushed onto the stack.

 Usage: Commonly used for function calls, saving


return addresses, and storing local variables.
 Pros: Facilitates function calls and recursion.
 Cons: Requires stack management to avoid overflow
or underflow.

9. Absolute Addressing Mode


 Definition: The instruction contains the actual
physical address of the operand.
 Example: MOV R1, [20000]
o This example directly accesses memory location

20000.
 Usage: Direct access to specific memory addresses
(typically used for hardware or memory-mapped
I/O).
 Pros: Simple and direct.
 Cons: Lack of flexibility, as addresses must be hard-
coded into the program.

10. Register Indirect Addressing Mode


 Definition: The address of the operand is stored in a
register, and the instruction specifies the register.
 Example: MOV R1, [R2]
o In this case, R2 contains the memory address of

the operand, and the operand is accessed


indirectly through the contents of R2.
 Usage: Common in scenarios where dynamic
memory allocation or pointer-based access is needed.
 Pros: Provides flexibility, as the register's value can
be updated during runtime.
 Cons: Slightly slower than direct addressing due to
the indirection.

Summary of Key Points:


 Immediate: Operand is constant.
 Register: Operand is in a register.
 Direct: Operand is at a specified memory address.
 Indirect: Operand's address is specified by a memory
location or register.
 Indexed/Base-Register: Operand’s address is
calculated from a base address and an offset.
 Relative: Operand’s address is relative to the current
instruction pointer (used for jumps and branches).
 Stack: Operand is on the top of the stack.

Conclusion
Addressing modes are essential to making computer
architectures flexible and efficient. By using different
addressing modes, processors can handle a wide range of
data access scenarios. A good understanding of
addressing modes helps in optimizing code, designing
efficient algorithms, and understanding how different
machine-level instructions interact with memory and
registers.

You might also like