Microprocessors perform operations on data stored in the register or memory. This data is specified in the operand field of the instruction. The data can be specified in various ways as direct data value or stored in some register or memory location, and so forth. These are referred to as the addressing modes of the microprocessor. That is to say, the addressing mode as expressed in the instruction tells us how and from where the microprocessor can get the data to act upon. In most CPUs, addressing modes may be specified directly or indirectly.  Addressing modes are of direct bearing to compiler writers and to programmers writing the code in assembly language.

Different microprocessor architectures provide a multiplicity of addressing modes. RISC microprocessors have fewer addressing modes than CISC microprocessors. The most commonly used addressing modes are absolute or memory direct addressing, register direct addressing, register indirect addressing, program counter relative addressing, immediate addressing, and so on.

Related article: RISC vs. CISC Processors

Absolute or Memory Direct Addressing Mode

In this mode, the data is accessed by specifying its address in the memory. This mode is useful for accessing fixed memory locations, such as memory mapped I/O devices. The operand address is embedded within the assembled instruction code. For example, the instruction MOV A, 30H in the 8085 microprocessor moves the contents of memory location 30H into the accumulator. In this case accumulator has the value 07H.

Immediate Addressing Mode

In immediate addressing mode, the value of the operand is held within the instruction itself. This mode is useful for accessing constant values in a program. It is faster than the absolute addressing mode and requires less memory space. For instance in 8085 microprocessor, the instruction MOV A, #40H moves the data value 40H into the accumulator. The sign # in the instruction tells the assembler that the addressing mode used is immediate.

Figure 1.1 Immediate addressing mode

Register Direct Addressing Mode

In register direct addressing mode, data is accessed by specifying the register name in which it is stored. Operations on registers are very fast and hence the instructions in this mode require less time than absolute mode instructions. For example, the instruction MOV A, R1 in the 8085 microprocessor moves the contents of register R1 into the accumulator. The contents of the accumulator after the instruction are 06H.

Register Indirect Addressing Mode

So far, all the modes we have discussed have either the value of data or their location directly specified. The indirect addressing mode uses a register to hold the actual address where the data is stored i.e. the memory location of the data is stored in a register as illustrated in Figure 1.3 below. That is to say, in indirect addressing mode, the address is specified indirectly and has to be looked up. This addressing mode is useful when implementing the pointer data type of high-level language.

In the 8085 microprocessor, the R0 and R1 registers are used as an eight-bit index and the DPTR as 16-bit index. The mnemonic symbol used for indirect addressing is @. For example, the instruction MOV A, @R0 moves the contents of the memory location whose address is stored in R0 into the accumulator. The value of the accumulator in this example is 07H as shown in the Figure 1.3 above. This addressing mode can also be enhanced with an offset for accessing data structures in data space memory. This is called register indirect with displacement. For example, the instruction MOV A, @A+DPTR copies the code byte at the memory address formed by adding the contents of A and DPTR to A.

Indexed Addressing Mode

In the indexed addressing mode, the address is obtained by adding the contents of a register to a constant. The instruction “move the contents of accumulator A to the memory location whose address is given by the contents of register 1 plus 7” is an example of indexed addressing.

The following instructions show examples of indexed addressing mode:

Pentium:

MOV AX,5[BX]    ; address = (BX) + 5

ARM:      

LDRB R0,[R1,#5]   ;address = (R1) + 5

HCS12:

LDAA 5,X   ; address = (X) + 5

The indexed addressing mode is useful whenever the absolute location of the data is not known until the program is running. This addressing mode is used to access a continuous table or array of data items stored in memory. The content of the constant gives the starting address, while the contents of the register determine the element of the array or table to be accessed. If the program counter is used in the indexed addressing mode, it is known as the program counter relative addressing mode.

Related: Assembly Language Step-by-Step: Programming with Linux

Implicit Addressing Mode & Relative Addressing Mode

In implicit addressing mode, no operand is used in the instruction and the location of the operand is obvious from the instruction itself. Examples include: ‘clear carry flag’, ‘return from subroutine’ and so forth.

The relative addressing mode is used for ‘jump’ and ‘branch’ instructions only. In this, a displacement is added to the address in the program counter and the next instruction is fetched from the new address in the program counter. This mode is specifically useful in connection with conditional jumps.

John Mulindi

John Mulindi has a background in a technical field and he writes on topics ranging from automation, computer systems, embedded systems, mechatronics to measurement and control.

View Comments

Recent Posts

Rigid-Flex PCBs: Enhancing Durability and Flexibility in Electronic Devices

The world of electronics is constantly evolving, allowing designers and manufacturers to push the boundaries…

4 months ago

Key Features of PIC16X84 Family of Microcontrollers

PIC microcontrollers are fabricated by Microchip Technology. PIC16C84 and PIC16F84 are the two microcontrollers in…

10 months ago

ADD Instruction in Intel 8051 (MCS-51) Microcontroller

The ADD instruction tells the microcontroller’s CPU to add the source byte to register A…

10 months ago

Main Features of Intel 8086 Microprocessor

8-bit microprocessors are limited in their speed (the number of instructions that can be executed…

10 months ago

Basic Features of 68HC11 Family of Microcontrollers

The 68HC11 (also abbreviated as 6811 or HC11) is an 8-bit microcontroller that was introduced…

10 months ago

Process Synchronization using Semaphores

Mutual exclusion typically imposes some conditions on access to a given resource by two or…

11 months ago