Last Updated on July 4, 2023 by Abhishek Sharma
Addressing modes in computer architecture plays a vital role in enabling efficient and flexible memory access and operand manipulation. Addressing modes define the rules and mechanisms by which the processor calculates the effective memory address or operand location for data operations. By understanding the different addressing modes available, programmers and system designers can optimize memory utilization and enhance overall performance.
In this article, we embark on a comprehensive exploration of addressing modes in computer architecture. We delve into the intricacies of various addressing modes, unraveling their functionalities, benefits, and use cases.
What is Addressing Modes in Computer Architecture?
Addressing modes in computer architecture refer to the techniques and rules used by processors to calculate the effective memory address or operand location for data operations. They define how instructions specify the source or destination of data within the system’s memory or registers. Addressing modes play a crucial role in determining the efficiency and flexibility of memory access and operand manipulation.
Each addressing mode has its own set of rules and mechanisms, allowing programmers to optimize memory utilization and enhance overall system performance. Common addressing modes include immediate addressing, register addressing, direct addressing, indirect addressing, indexed addressing, base+offset addressing, and stack addressing, among others.
There are two types of addressing modes for 8086 instructions:
1) Addressing modes for data
2) Addressing modes for branch
You may quickly access variables, arrays, records, pointers, and other complicated data types thanks to the 8086 memory addressing modes, which offer flexible access to memory. The correct application of memory addressing modes is the secret to effective assembly language programming.
An assembly language program instruction consists of two parts
The memory address of an operand consists of two components:
Starting address of memory segment.
- Effective address or Offset: An offset is determined by adding any combination of three address elements: displacement, base and index.
- Displacement: It is an 8 bit or 16 bit immediate value given in the instruction.
- Base: Contents of base register, BX or BP.
- Index: Content of index register SI or DI.
The 8086 microprocessor uses a variety of addressing modes depending on how an operand is specified.
Addressing modes used by 8086 microprocessor are discussed below:
Implied mode: The operand is mentioned in the instruction itself in inferred addressing. Data is a component of instructions in this mode and might be 8 bits or 16 bits long.Insinuated addressing is used in the construction of zero address instructions.
Example: CLC (used to reset Carry flag to 0)
- Immediate addressing mode (symbol #): Data is present in the instruction’s address field in this manner. Like a single format for address instructions.
Note: Limitation in the immediate mode is that the range of constants are restricted by the size of the address field.
Example: MOV AL, 35H (move the data 35H into AL register)
- Register mode: The operand is put in either an 8 bit or 16 bit general purpose register when using register addressing. The instruction’s designated register for the data is present.
- Here one register reference is required to access the data.
Example: MOV AX,CX (move the contents of CX register to AX register)
- Register Indirect mode: According to the instruction, the operand’s offset is put in any one of the registers BX, BP, SI, or DI in this addressing. The base register or an index register that the instruction specifies is where the data’s actual address is located.
Here two register references are required to access the data.
Using the register indirect addressing modes, the 8086 CPUs enable indirect memory access via a register.
MOV AX, [BX](move the contents of memory location s
addressed by the register BX to the register AX)
Auto Indexed (increment mode): Effective address of the operand is the contents of a register specified in the instruction. After accessing the operand, the contents of this register are automatically incremented to point to the next consecutive memory location.(R1)+.
Here one register reference,one memory reference and one ALU operation is required to access the data.
Add R1, (R2)+ // OR
R1 = R1 +M[R2]
R2 = R2 + d
Useful for stepping through arrays in a loop. R2 – start of array d – size of an element.
Auto indexed ( decrement mode):The information in a register designated by the instruction serves as the operand’s effective address. The values of this register are automatically decremented to point to the preceding consecutive memory location before accessing the operand. –(R1)
Here one register reference,one memory reference and one ALU operation is required to access the data.
Add R1,-(R2) //OR
R2 = R2-d
R1 = R1 + M[R2]
The auto increment and auto decrement modes are identical. Both can be used to the push and pop implementation of a stack. For the implementation of "Last-In-First-Out" data structures, auto increment and auto decrement modes are helpful.
- Direct addressing/ Absolute addressing Mode (symbol [ ]): The operand’s offset is given in the instruction as an 8 bit or 16 bit displacement element. In this addressing mode the 16 bit effective address of the data is the part of the instruction.
Here only one memory reference operation is required to access the data.
Example:ADD AL, //add the contents of offset address 0301 to AL
- Indirect addressing Mode (symbol @ or () ): In this mode address field of instruction contains the address of effective address.Here two references are required.
1st reference to get effective address.
2nd reference to access the data.
Based on the availability of Effective address, Indirect mode is of two kind:
Register Indirect: In this method, the register holds the effective address, while the address field of an instruction maintains the name of the relevant register. In this case, one memory reference and one register reference are needed to access the data.
Memory Indirect: In this mode, the instruction’s address field will always preserve the associated memory address even while the effective address is in the memory. Here, accessing the data requires two memory references.
- Indexed addressing mode: The content of an index register SI or DI and an 8 bit or 16 bit displacement are added to determine the operand’s offset.
Example:MOV AX, [SI +05]
- Based Indexed Addressing: The content of a base register (BX or BP) and an index register (SI or DI) are added to determine the operand’s offset.
Example: ADD AX, [BX+SI]
Based on Transfer of control, addressing modes are:
- PC relative addressing mode: PC relative addressing mode is used to implement intra segment transfer of control, In this mode effective address is obtained by adding displacement to PC.
- EA= PC + Address field value
- PC= PC + Relative value.
- Base register addressing mode: Base register addressing mode is used to implement inter segment transfer of control.In this mode effective address is obtained by adding base register value to address field value.
- EA= Base register + Address field value.
- PC= Base register + Relative value.
- Program relocation at runtime is possible using both PC relative and based register addressing modes.
- Writing position independent codes is best done using the based register addressing technique.
Advantages of Addressing Modes
- The provision of programming tools like Pointers, counters for loop controllers, data indexing, and program relocation.
- To decrease the number of bits in the instruction’s addressing field.
In conclusion, addressing modes in computer architecture play a pivotal role in determining how data is accessed and manipulated within a system. By understanding and utilizing the various addressing modes available, programmers and system designers can optimize memory utilization, enhance performance, and achieve efficient operand manipulation.
Throughout this article, we have explored the intricacies of different addressing modes, including immediate addressing, register addressing, direct addressing, indirect addressing, indexed addressing, base+offset addressing, and stack addressing. Each addressing mode offers unique advantages and trade-offs, catering to specific programming requirements and memory access scenarios.
FAQs: Addressing Modes in Computer Architecture
Q1: Why are addressing modes important in computer architecture?
Addressing modes are essential in computer architecture as they determine how data is accessed and manipulated within a system. They enable efficient memory utilization, operand access, and code optimization, ultimately impacting the overall performance of the system.
Q2: How many types of addressing modes are there?
There are various types of addressing modes, including immediate addressing, register addressing, direct addressing, indirect addressing, indexed addressing, base+offset addressing, and stack addressing. The exact number and types may vary depending on the architecture and design of the processor.
Q3: How do addressing modes affect performance?
Different addressing modes have varying impacts on performance. Modes like immediate and register addressing offer quick access to data, minimizing memory access time and enhancing performance. However, indirect addressing may introduce additional memory access overhead, affecting performance to some extent.
Q4: How do I choose the right addressing mode for my program?
The choice of addressing mode depends on the specific requirements of your program. Consider factors such as the nature of the data, memory availability, the need for flexibility, and the desired level of performance optimization. Analyzing these factors will help you select the most appropriate addressing mode.
Q5: Can multiple addressing modes be used within a program?
Yes, it is common to use multiple addressing modes within a program. Different instructions may require different addressing modes based on the specific data access or manipulation needs. The choice of addressing mode can vary throughout the program based on the instruction being executed.
Q6: Do all processors support the same addressing modes?
Different processors and computer architectures may support different addressing modes. The availability and specific implementation of addressing modes can vary based on the processor’s design and architecture. It is essential to refer to the processor’s documentation to understand the supported addressing modes.