0% found this document useful (0 votes)
19 views

The Intel 8086 Microprocessor

Uploaded by

Irfanul Huda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

The Intel 8086 Microprocessor

Uploaded by

Irfanul Huda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

THE INTEL 8086 MICROPROCESSOR

LECTURE - 5

Abdullah Al Noman
Lecturer
Computer Science and Engineering Department
Shahjalal University of Science and Technology
Addressing modes of 8086
Microprocessor
ADDRESSING MODES OF 8086 MICROPROCESSOR

o Addressing modes are techniques used in computer architecture and assembly language
programming to specify how the operands of an instruction are located or accessed in
memory. In other words, addressing modes define the way in which the CPU calculates
the effective address of an operand before performing an operation.

o The addressing modes of 8086 microprocessor can be classified into five groups:
1. Addressing modes for accessing immediate and register data (register and
immediate mode)
2. Addressing modes for accessing data in memory (memory modes)
3. Addressing modes for accessing data from I/O ports (I/O modes)
4. Relative addressing mode
5. Implied addressing mode
ADDRESSING MODES OF 8086 MICROPROCESSOR

1. Addressing Modes for Accessing Immediate and Register Data:


1.(a) Register Addressing Mode:
This mode specifies the source operand, destination operand, or both to be contained in an
8086 register.

Example: Destination Source

MOV DX, CX
Note that in the above both source and destination operands are in register mode.

MOV CL, DL

MOV BX, CH
ADDRESSING MODES OF 8086 MICROPROCESSOR

1. Addressing Modes for Accessing Immediate and Register Data:


1.(b) Immediate Addressing Mode :
In immediate mode, 8- or 16-bit data can be specified as part of the instruction.

Example:
MOV CL, 03H
MOV DX, 0502H
Note that in both of the above MOV instructions, the source operand is in immediate mode
and the destination operand is in register mode.

A constant such as "VALUE" can defined by the assembler EQUATE directive such as
VALUE EQU 35H.
MOV BH, VALUE
Note: These immediate data are considered as part of the instruction.
ADDRESSING MODES OF 8086 MICROPROCESSOR

2. Addressing Modes for Accessing Data in Memory:


The 8086 must use a segment register whenever it accesses the memory.
For example, INC BYTE PTR [START] will increment the 8-bit content of memory
location in DS with offset START by one. However, DS can be overridden by ES as
follows: INC ES: BYTE PTR [START]; segments cannot be overridden for some cases
such as stack reference instructions (such as PUSH and POP). There are six modes in this
category. These are,

a) Direct addressing mode


b) Register indirect addressing mode
c) Based addressing mode
d) Indexed addressing mode
e) Based indexed addressing mode
f) String addressing mode
ADDRESSING MODES OF 8086 MICROPROCESSOR

2. Addressing Modes for Accessing Data in Memory:


2.(a) Direct Addressing Mode:
In this mode, the 16-bit effective address (EA) is directly included with the instruction.

Example:
MOV CX; DS:START

Lets say,
START EQU 0040H
[DS] = 3050H
What will happen next considering the above instruction?
ADDRESSING MODES OF 8086 MICROPROCESSOR

2. Addressing Modes for Accessing Data in Memory:


2.(b) Register Indirect Addressing Mode:
In this mode, the EA is specified in either a pointer register or an index register.
Pointer register – BX & BP
Index register – SI & DI
The 20-bit physical address is computed using DS and EA (Effective Adds./Offset Adds.).
Register indirect mode Register mode
Example:
MOV [DI], BX

Now, if [DS] = 5004H, [DI] = 0020H, and [BX] = 2456H, then after executing MOV [DI], BX instruction,
what will happen?
ADDRESSING MODES OF 8086 MICROPROCESSOR

2. Addressing Modes for Accessing Data in Memory:


2.(c) Based Addressing Mode:
In this mode, EA is obtained by adding a displacement (signed 8-bit or unsigned 16-bit)
value to the contents of BX or BP. The segment registers used are DS and SS.

BX → DS and BP → SS

Note: SP is called the system stack pointer and BP is called the user stack pointer.
Based mode
Example:
MOV AL, START [BX]

The displacement START can be either unsigned 16-bit or signed 8-bit. The 8086 sign-extends the 8-bit
displacement and then adds it to [BX] in the above MOV instruction for determining EA. On the other hand,
the 8086 adds an unsigned 16-bit displacement directly with [BX] for determining EA.
ADDRESSING MODES OF 8086 MICROPROCESSOR

2. Addressing Modes for Accessing Data in Memory:


2.(c) Based Addressing Mode:
Based addressing provides a convenient way to address a structure which may be stored at different places in
memory:

MOV AL, ALPHA [BX]

Now, in order to access the salary of RECORD N,


the programmer simply changes the contents of the
base register to 3000H.
ADDRESSING MODES OF 8086 MICROPROCESSOR

2. Addressing Modes for Accessing Data in Memory:


2.(c) Based Addressing Mode:
If BP is specified as a base register in an instruction, the 8086 automatically obtains the operand from the
current SS (unless a segment override prefix is present). This makes based addressing with BP a very
convenient way to access stack data. BP can be used as a stack pointer in SS to access local variables.
Consider the following instruction sequence:
ADDRESSING MODES OF 8086 MICROPROCESSOR

2. Addressing Modes for Accessing Data in Memory:


2.(c) Based Addressing Mode:
Following figures shows the 8086 stack during various stages.
ADDRESSING MODES OF 8086 MICROPROCESSOR

2. Addressing Modes for Accessing Data in Memory:


2.(d) Indexed Addressing Mode:
In this mode, the effective address is calculated by adding the unsigned 16-bit or sign-extended 8-bit
displacement and the contents of SI or Dl.

Example:
MOV BH, ARRAY[SI]
Here the 20-bit physical address is calculated from the displacement ARRAY, SI, and DS. The displacement
is provided by the programmer using an assembler directive such as EQU (ARRAY EQU XXXXH).

For 16-bit displacement, the EU adds this to SI to determine EA. On the other hand, for 8-bit displacement
the EU sign-extends it to 16 bits and then adds to SI for determining EA.
ADDRESSING MODES OF 8086 MICROPROCESSOR

2. Addressing Modes for Accessing Data in Memory:


2.(e) Based Indexed Addressing Mode:
In this mode, the EA is computed by adding a base register (BX or BP), an index register (SI or DI), and a
displacement (unsigned 16-bit or sign-extended 8-bit).

Example:
MOV ALPHA [SI] [BX], CL

If [BX] = 0200H, value of ALPHA = 08H, [SI] = 1000H, and [DS] = 3000H, then 8-bit content of CL is
moved to 20-bit physical address 31208H.

Based indexed addressing mode provides a convenient way for a subroutine to address an array allocated on
a stack. Since in the based indexed mode, the contents of two registers such as BX and SI can be varied,
two-dimensional arrays such as matrices can also be accessed.
ADDRESSING MODES OF 8086 MICROPROCESSOR

2. Addressing Modes for Accessing Data in Memory:


2.(e) Based Indexed Addressing Mode:
displacement = difference between the top
of the stack and start of the array = 04H

[SI or DI) = N = 16-bit number (0, 2,4,6 in


the example)

2005H

Instruction: MOV DX, 4 [SI] [BP]


Top of the stack (TOS)
ADDRESSING MODES OF 8086 MICROPROCESSOR

2. Addressing Modes for Accessing Data in Memory:


2.(f) String Addressing Mode:
• This mode uses index registers.
• The string instructions automatically assume SI points to the first byte or word of the source operand and
DI points to the first byte or word of the destination operand.
• The contents of SI and DI are automatically incremented (by clearing DF to 0 by CLD instruction) or
decremented (by setting DF to 1 by STD instruction) to point to the next byte or word.
• The segment register for the source is DS and may be overridden.
• The segment register for the destination must be ES and cannot be overridden.

Example: MOVS BYTE


If [DF] = 0, [DS] = 2000H, [SI] = 0500H, [ES] = 4000H, [DI] = 0300H, [20500H] = 38H, and [40300H] =
45, then after execution of the MOVS BYTE, [40300H] = 38H, [SI] = 0501H, and [DI] = 0301H.
The contents of other registers and memory locations will be unchanged.
ADDRESSING MODES OF 8086 MICROPROCESSOR

2. Addressing Modes for Accessing Data in Memory:


2.(f) String Addressing Mode:

Example: MOVS BYTE

[DF] → 0
[DS] → 2000H and [SI] → 0500H. So, [DS] + [SI] → [20500H] = 38H
[ES] → 4000H and [DI] → 0300H. So, [ES] + [DI] → [40300H] = 45H

after execution of the MOVS BYTE,


[40300H] = 38H and [SI] → 0501H, and [DI] → 0301H.
The contents of other registers and memory locations will be unchanged.
ADDRESSING MODES OF 8086 MICROPROCESSOR

3. Addressing Modes for Accessing I/O Ports:


Standard I/O uses port addressing modes. For memory-mapped I/O, memory addressing
modes are used.

There arc two types of port addressing modes:


a) Direct port mode
b) Indirect port mode
ADDRESSING MODES OF 8086 MICROPROCESSOR

3. Addressing Modes for Accessing I/O Ports:


3.(a) Direct port mode:
In direct port mode, the port number is an 8-bit immediate operand. This allows fixed
access to ports numbered 0 to 255.

Example:
OUT 05H, AL
ADDRESSING MODES OF 8086 MICROPROCESSOR

3. Addressing Modes for Accessing I/O Ports:


3.(a) Indirect port mode:
In indirect port mode, the port number is taken from DX allowing 64K 8-bit ports or 32K
16-bit ports.

Example:
IN AL, DX
If [DX] = 5040H, then what will happen after executing this instruction?
IN AX, DX
What will happen after executing this instruction?

Note that 8-bit and 16-bit I/O transfers must take place via AL and AX, respectively.
ADDRESSING MODES OF 8086 MICROPROCESSOR

4. Relative Addressing Mode:


Instructions using this mode specify the operand as a signed 8-bit displacement relative to
PC.
Example:
JNC START
JMP HERE
JC HERE
JZ HERE
JNZ HERE
• Relative mode with signed 8-bit displacement provides a range of -128 to +127 (0 being
positive).
• If branching beyond this range is necessary, one must use the unconditional 8086 JUMP
instruction which uses direct mode.
ADDRESSING MODES OF 8086 MICROPROCESSOR

5. Implied Addressing Mode:


Instructions using this mode have no operands.

Example:
STD → Set direction flag
CLC → Clear carry flag
CLD → Clear direction flag
8086 BUS Cycle
HOW THE 8086 DEMULTIPLEXES THE ADDRESS AND DATA BUSES?

Separate address and data buses


8086 BUS CYCLE

Read Cycle
8086 BUS CYCLE

Write Cycle
THANK YOU

You might also like