Addressing modes in 8085 microprocessor
Prerequisite – Addressing modes
The 8085 microprocessor has several addressing modes that are used to access memory locations. Some of the most commonly used addressing modes in the 8085 microprocessor are:
The way of specifying data to be operated by an instruction is called addressing mode.
Why use addressing modes in 8085 microprocessor ?
Here are some reasons why addressing modes are used in the 8085 microprocessor:
- Flexibility: Addressing modes provide a flexible way to access data and instructions in memory. Different addressing modes allow programmers to choose the most appropriate addressing technique for a particular task, depending on the type of data being accessed, the size of the data, and other factors.
- Memory optimization: Addressing modes can help to optimize the use of memory resources by allowing data and instructions to be accessed in the most efficient way possible. For example, using indirect addressing modes can reduce the amount of memory needed to store addresses, while using indexed addressing modes can reduce the number of memory accesses needed to access a large array of data.
- Performance optimization: Addressing modes can also help to optimize the performance of the microprocessor by reducing the number of memory accesses needed to fetch data or instructions. This can help to speed up the execution of programs and improve the overall efficiency of the microprocessor.
- Reduced code size: Addressing modes can help to reduce the size of code needed to perform a particular task. By using addressing modes that allow data and instructions to be accessed using fewer instructions, programmers can write more compact and efficient code.
Types of addressing modes –
In 8085 microprocessor there are 5 types of addressing modes:
- Immediate Addressing Mode –
In immediate addressing mode the source operand is always data. If the data is 8-bit, then the instruction will be of 2 bytes, if the data is of 16-bit then the instruction will be of 3 bytes.
MVI B 45 (move the data 45H immediately to register B)
LXI H 3050 (load the H-L pair with the operand 3050H immediately)
JMP address (jump to the operand address immediately)
- Register Addressing Mode –
In register addressing mode, the data to be operated is available inside the register(s) and register(s) is(are) operands. Therefore the operation is performed within various registers of the microprocessor.
MOV A, B (move the contents of register B to register A)
ADD B (add contents of registers A and B and store the result in register A)
INR A (increment the contents of register A by one)
- Direct Addressing Mode –
In direct addressing mode, the data to be operated is available inside a memory location and that memory location is directly specified as an operand. The operand is directly available in the instruction itself.
LDA 2050 (load the contents of memory location into accumulator A)
LHLD address (load contents of 16-bit memory location into H-L register pair)
IN 35 (read the data from port whose address is 35)
- Register Indirect Addressing Mode –
In register indirect addressing mode, the data to be operated is available inside a memory location and that memory location is indirectly specified by a register pair.
MOV A, M (move the contents of the memory location pointed by the H-L pair to the accumulator)
LDAX B (move contents of B-C register to the accumulator)
STAX B (store accumulator contents in memory pointed by register pair B-C)
- Implied/Implicit Addressing Mode –
In implied/implicit addressing mode the operand is hidden and the data to be operated is available in the instruction itself.
CMA (finds and stores the 1’s complement of the contents of accumulator A in A)
RRC (rotate accumulator A right by one bit)
RLC (rotate accumulator A left by one bit)
6.Relative Addressing Mode:
In this mode, the operand is a memory location specified by the contents of the program counter plus a constant value.
In this example, the instruction JMP AGAIN uses the Relative Addressing Mode. The instruction jumps to the label AGAIN by adding the contents of the program counter with the specified constant value. The constant value is calculated based on the distance between the current instruction and the label AGAIN.
In this case, the instruction JMP AGAIN is executing a loop that loads the accumulator with the value 55H, adds the contents of the register R0 to the accumulator, and then jumps back to the label AGAIN to repeat the loop.
Features of the addressing modes in the 8085 microprocessor:
- Immediate addressing: In immediate addressing mode, the operand is a constant value that is part of the instruction. The immediate addressing mode is used for instructions that require a fixed value, such as loading a constant value into a register.
- Direct addressing: In direct addressing mode, the operand is a memory address specified directly in the instruction. The direct addressing mode is used for instructions that access data stored in memory.
- Indirect addressing: In indirect addressing mode, the operand is a memory address specified indirectly by a register or memory location. The indirect addressing mode is used for instructions that access data stored in memory, where the memory address is not known in advance.
- Register addressing: In register addressing mode, the operand is stored in one of the processor registers. The register addressing mode is used for instructions that manipulate the contents of the registers.
- Indexed addressing: In indexed addressing mode, the operand is obtained by adding an offset value to a base address stored in a register. The indexed addressing mode is used for instructions that access data stored in memory using a computed address.
- Relative addressing: In relative addressing mode, the operand is specified as an offset relative to the current program counter value. The relative addressing mode is used for instructions that perform conditional branching or looping.
- Memory-mapped I/O addressing: In memory-mapped I/O addressing mode, the processor accesses input/output devices using memory addresses instead of specialized I/O instructions. Memory-mapped I/O addressing mode is used for interfacing with peripherals such as displays, keyboards, and printers.
Advantages of Addressing Modes in 8085 Microprocessor:
- Versatility: The 8085 microprocessor supports several addressing modes, which allows for a wide range of memory access and manipulation options.
- Efficient memory usage: Different addressing modes allow for efficient use of memory, reducing the memory footprint of programs and making the best use of available memory.
- Easy to use: The addressing modes are easy to use, making it simple for programmers to write and execute complex programs.
- Improved performance: The use of different addressing modes can improve the performance of programs, as the correct addressing mode can be chosen to match the specific requirements of the program.
Disadvantages of Addressing Modes in 8085 Microprocessor:
- Complexity: The various addressing modes can be complex, making it difficult for programmers to choose the correct mode for a given task.
- Overhead: The use of different addressing modes can result in additional overhead, as the microprocessor must perform additional operations to access memory.
- Debugging difficulties: Debugging programs that use multiple addressing modes can be difficult, as the programmer must keep track of the different modes used in each memory access.
- Limitations: The addressing modes are limited by the size of the program counter and the memory address space, which can impact the performance of large programs.
Uses of Addressing Modes in 8085 Microprocessor:
Here are some of the most common uses of addressing modes in the 8085 microprocessor:
- Direct addressing: Direct addressing is used when the address of the operand is directly specified in the instruction. This addressing mode is used for simple operations where the operand is stored in a specific memory location, and the address does not need to be calculated or manipulated in any way.
- Indirect addressing: Indirect addressing is used when the address of the operand is not directly specified in the instruction, but is instead stored in a register or memory location. This addressing mode is useful for accessing data stored in memory that may be located at a different address each time the program is executed.
- Immediate addressing: Immediate addressing is used when the operand is specified directly in the instruction, rather than being stored in memory. This addressing mode is useful for performing simple arithmetic or logic operations on constants or literals.
- Register addressing: Register addressing is used when the operand is stored in a register, rather than in memory. This addressing mode is useful for performing fast arithmetic or logic operations on small amounts of data.
- Indexed addressing: Indexed addressing is used when the address of the operand is calculated by adding an offset value to the contents of a register. This addressing mode is useful for accessing elements of an array or data structure.
- Relative addressing: Relative addressing is used when the address of the operand is calculated relative to the current program counter. This addressing mode is useful for branching to different parts of a program or for accessing data stored in a specific location relative to the current program counter.
Challenges associated with addressing modes in the 8085 microprocessor, including:
Limited addressing range: The 8085 microprocessor has a 16-bit address bus, which limits the number of memory locations that can be accessed directly. This can be a challenge when working with large data sets or programs that require access to a lot of memory.
Complex instruction set: The 8085 microprocessor has a relatively complex instruction set, which can make it difficult to understand and use the various addressing modes correctly. This can lead to errors in programming and result in unexpected behavior.
Limited addressing modes: The 8085 microprocessor has a limited set of addressing modes, which can limit its flexibility and make certain types of programming tasks more difficult. For example, the lack of an indexed addressing mode can make it more difficult to work with arrays or other data structures.
Stack management: The use of the stack pointer register can be challenging, especially when dealing with nested subroutine calls or interrupts. Improper use of the stack can lead to memory corruption and program crashes.
Performance considerations: Some addressing modes, such as direct addressing, can be faster than others, such as register indirect addressing. This means that programmers need to carefully consider which addressing modes to use to optimize the performance of their programs.
Memory management: The 8085 microprocessor does not have built-in support for virtual memory or paging, which can be a challenge when working with large programs or data sets that exceed the available physical memory. Programmers need to manage memory usage carefully to avoid memory-related errors and crashes.
Please Login to comment...