Addressing Modes of 8086
Addressing Modes of 8086
Example:
ADD R1, (R2)
Instruction has register R2 and R2 has memory address of operand.
Addressing Modes
The address field or fields in a typical instruction format are relatively small. We would like to be abl
systems, virtual memory. To achieve this objective, a variety of addressing techniques has been emplo
addressing flexibility, on the one hand, and the number of memory references and/or the complexity o
most common addressing techniques:
Immediate
Direct
Indirect
Register
Register indirect
Displacement
1) Immediate Addressing:
The simplest form of addressing is immediate addressing, in which the operand is actually present in
Istruction
op-code operand
The advantage of immediate addressing is that no memory reference other than the instruction fetch
cycle in the instruction cycle. The disadvantage is that the size of the number is restricted to the size o
with the word length.
2) Direct Addressing:
A very simple form of addressing is direct addressing, in which:
The technique was common in earlier generations of computers but is not common on contemporary
calculation. The obvious limitation is that it provides only a limited address space.
3) Indirect Addressing:
With direct addressing, the length of the address field is usually less than the word length, thus limitin
the address of a word in memory, which in turn contains a full-length address of the operand. This is
4) Register Addressing:
Register addressing is similar to direct addressing. The only difference is that the address field refers
The advantages of register addressing are that :
The disadvantage of register addressing is that the address space is very limited.
Just as register addressing is analogous to direct addressing, register indirect addressing is analogous
the address field refers to a memory location or a register. Thus, for register indirect address: Operan
The advantages and limitations of register indirect addressing are basically the same as for indirect a
of addresses) of the address field is overcome by having that field refer to a word-length location cont
less memory reference than indirect addressing.
6) Displacement Addressing:
A very powerful mode of addressing combines the capabilities of direct addressing and register indire
context of its use but the basic mechanism is the same. We will refer to this as displacement addressin
A = base value
R = register that holds displacement.
Types of Addressing Modes
In computer architecture, there are following types of addressing modes
1. Implied / Implicit Addressing Mode
2. Stack Addressing Mode
3. Immediate Addressing Mode
4. Direct Addressing Mode
5. Indirect Addressing Mode
6. Register Direct Addressing Mode
7. Register Indirect Addressing Mode
8. Relative Addressing Mode
9. Indexed Addressing Mode
10. Base Register Addressing Mode
11. Auto-Increment Addressing Mode
12. Auto-Decrement Addressing Mode
In this article, we will discuss these addressing modes in detail.
1. Implied Addressing Mode
Implied Addressing Mode is known as ‘Implicit’ or ‘Inherent’ addressing mode.
It is mainly used for Zero-address (STACK-organized) instructions. For such instruction, the o
operand.
Examples of zero address instruction are
ADD (it takes previous two values from the stack and ADD’s them).
CLC (used to reset Carry flag to 0)
2. Stack Addressing Mode
In stack addressing mode, The operand is found from the top of the stack.
Example
ADD Operation in Stack organization
Take the top two values from the top of the stack
Apply ADD instruction
Obtained result is again placed at the top of the stack
3. Immediate Addressing Mode
The operand is directly provided as a constant value. No extra computations are required to calcu
the constant in memory or register. We can directly use it from instruction.
The size of the constant must be equal or less than the size of the operand field in the instruction.
instruction
Identification: instruction contains constants.
Examples
ADD 10 (AC = AC+10)
MOV AL, 30H (move the data (30H) into AL register)
4. Direct Addressing Mode
The operand of instruction contains the address of the memory location. It also called an absolute
All computer hardware or instruction sets support direct and indirect addressing modes.
Example
ADD AL,[0302] //add the contents of address 0302 to AL
Disadvantage:
If we have a fixed instruction size for example 16 bits (4 for opcode) and (12 for operand). Then w
words, only 0-4095 memory locations can be fetched through it.
To resolve this issue we use indirect register addressing mode. We give the address of registe
address of memory location which is greater than 12 bits (4095).
5. Indirect Addressing Mode
The address field of the instruction contains the address of memory location. That memory location
Two references of memory are required to fetch the required
Pointers or variables use to contain the address of another variable.
Disadvantage: computations are increased.
Example
ADD X in indirect addressing mode will perform in the following way
AC ← AC + [[X]]
6. Register Direct Addressing Mode
The address field of the instruction specifies to a CPU register which contains the operand.
There is no need for memory access to fetch the operand.
Example
ADD R in register direct addressing mode will perform in the following way
AC ← AC + [R]
7. Register Indirect Addressing Mode
The address field of the instruction specifies to a CPU register which provides the effective addres
There is Only one memory reference is required to fetch the operand.
Example
ADD R in register indirect addressing mode will perform in the following way
AC ← AC + [[R]]
Advantage
Addressing modes reduced the instruction size. For example
If we have 4GB memory then to fetch any operand from this memory we required 32 bits address
reduce instruction size we use registers generally are 64, these registers store address of that
instruction to access actual operand from memory. It’s all register indirect addressing mode
Disadvantage:
Register indirect addressing mode requires three read operations to access an operand. So, more
8. Relative Addressing Mode
The effective address of the operand is obtained by adding the address of the program counter with
Effective Address = Value of PC + Address part of the instruction
Explanation:
If the program execution is at 500 locations in main memory and we have a branch instructio
instruction is use to jump from one location to another in the program.
We provide the value of offset rather to give the actual address of that position.
So, Offset value (displacement value) is 49 to jumps 50 instructions because when we fetch the i
add 49 to 501 then we will reach at 550 location. If we give offset 50 value then we will reach at 55
Advantage:
Use of offset, reduce the instruction size. Because we give offset value in instruction rather than a
9. Indexed Addressing Mode
Operand-field contains the starting base address of the array-memory block and the general regis
Adding a base address and index register will give the actual physical address of the operand.
So, EA= base address + index register
The address is fix for the base register. But index register value changed as required.
10. Base Register Addressing Mode
The effective address of the operand can be found by adding the value of the base register with the
Multiple programs reside in RAM. When memory is full then we swap a program out from memory
again load the same swap out the program in memory with the same or different location. Sometim
Immediate Mode
Register Mode
In this mode the operand is stored in the register and this register is present in
where the operand is stored.
Advantages
In this mode, the instruction specifies the register whose contents give us the a
register contains the address of operand rather than the operand itself.
For Example: ADD R1, 4000 - In this the 4000 is effective address of operand.
In this, the address field of instruction gives the address where the effective ad
execution, as this includes multiple memory lookups to find the operand.
In this the contents of the indexed register is added to the Address part of the
operand.
EA = A + (R), In this the address field holds two values, A(which is the base value
The operand is A cells away from the current cell(the one pointed to by PC)
Base Register Addressing Mode
In this mode, operand is at the top of the stack. For example: ADD, this instruct
and will then PUSH the result to the top of the stack.
Instruction Cycle
If the instruction has an indirect address, the effective address is read from the
case of immediate operand instruction.
4. Execute the Instruction
The Control Unit passes the information in the form of control signals to the fu
in main memory or sent to an output device.
The cycle is then repeated by fetching the next instruction. Thus in this way the