Lecture 20 and 21 Addressing Modes and Its Types
Lecture 20 and 21 Addressing Modes and Its Types
Different operands will use different addressing modes. One or more bits in the instruction
format can be used as mode field. The value of the mode field determines which addressingmode
is to be used. The effective address will be either main memory address of a register.
The most common addressing modes are:
1. Immediate addressing mode
Immediate Addressing:
This is the simplest form of addressing. Here, the operand is given in the instruction.
This mode is used to define constant or set initial values of variables.
The advantage of this mode is that no memory reference other than instruction fetch is
required to obtain operand.
The disadvantage is that the size of the number is limited to the size of the address field
because most instruction sets is small compared to word length.
Example: ADD 3
Length of the address field is usually less than the word length.
Example : Move P, Ro
Add Q, Ro
Where P and Q are the address of operand, Ro is any register. SometimesAccumulator (AC)
is the default register. Then the instruction will look like:
Add A
Register Addressing:
Register addressing mode is similar to direct addressing. The only difference is that the
address field of the instruction refers to a register rather than a memory location.
3 or 4 bits are used as address field in the instruction to refer 8 to 16 generate purpose
registers (GPR).
The operands are in registers that reside within the CPU.
The instruction specifies a register in CPU, which contain the operand.
There is no need to compute the actual address as the operand is in a register and to getoperand
there is no memory access involved.
The advantages of register addressing are small address field is needed in the instructionand
faster instruction fetch.
The disadvantages includes very limited address space and usage of multiple registershelps
in performance but it complicates the instructions.
Example: MOV AX,BX
Displacement Addressing:
It is a combination of direct addressing or register indirect addressing mode.
Displacement Addressing Modes requires that the instruction have two address fields,at
least one of which is explicit means, one is address field indicate direct address andother
indicate indirect address.
Value contained in one addressing field is A, which is used directly and the value in
other address field is R, which refers to a register whose contents are to be added to
produce effective address.
Example: EA=A+(R)
Fig a): Displacement Addressing Modes
Indexed addressing:
The content of Index Register is added to direct address part of instruction toobtain the
effective address. The register indirect addressing field of instruction point to Index Register,
which is a special CPU register that contain an Indexed value, and directaddressing field contain
base address.
The data array is in memory and each operand in the array is stored in memoryrelative
to base address. The distance between the beginning address and the address of operand is the
indexed value stored in indexed register.
Any operand in the array can be accessed with the same instruction, which provided
that the index register contains the correct index value i.e., the index registercan be incremented
to facilitate access to consecutive operands.
Auto-increment mode:
Auto-increment Addressing Mode are similar to Register Indirect Addressing Mode
except that the register is incremented after its value is loaded (or accessed) at another
location like accumulator (AC).
The Effective Address of the operand is the contents of a register in the instruction.
After accessing the operand, the contents of this register is automatically incremented to
point to the next item in the list.
Example: (R) +.
The contents in register R will be accessed and them it will be incremented to point thenext
item in the list.
Example: - ( R)
The contents in register R will be decremented and then it is accessed.