0% found this document useful (0 votes)
82 views23 pages

3- CH 3 Addressing Modes - ١٢٢٠٣٧

The document discusses various addressing modes of the 8086 microprocessor. It divides the addressing modes into 5 groups: 1. Register and immediate addressing modes which specify registers or immediate data. 2. Memory addressing modes which specify the effective address (EA) of memory locations using registers, offsets, segments, etc. 3. I/O port addressing modes which specify I/O ports. 4. Relative addressing mode which uses relative displacement. 5. Implied addressing mode where the operand is implied by the instruction. Examples of memory addressing modes are direct, register indirect, based, indexed, and based indexed addressing.

Uploaded by

Boy az
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)
82 views23 pages

3- CH 3 Addressing Modes - ١٢٢٠٣٧

The document discusses various addressing modes of the 8086 microprocessor. It divides the addressing modes into 5 groups: 1. Register and immediate addressing modes which specify registers or immediate data. 2. Memory addressing modes which specify the effective address (EA) of memory locations using registers, offsets, segments, etc. 3. I/O port addressing modes which specify I/O ports. 4. Relative addressing mode which uses relative displacement. 5. Implied addressing mode where the operand is implied by the instruction. Examples of memory addressing modes are direct, register indirect, based, indexed, and based indexed addressing.

Uploaded by

Boy az
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/ 23

ELMERGIB UNIVERSITY

Faculty of Engineering
Department of Electrical and Computer Engineering

ECE484– Microprocessors II

Instructor: Dr Abdullah Al Masrub


Addressing Modes
8086 Microprocessor
Addressing Modes
Every instruction of a program has to operate on a data.
The different ways in which a source operand is denoted
in an instruction are known as addressing modes.
1. Register Addressing
Group I : Addressing modes for
2. Immediate Addressing register and immediate data

3. Direct Addressing

4. Register Indirect Addressing

5. Based Addressing
Group II : Addressing modes for
6. Indexed Addressing memory data
7. Based Index Addressing

8. String Addressing

9. Direct I/O port Addressing


Group III : Addressing modes for
10. Indirect I/O port Addressing I/O ports

11. Relative Addressing Group IV : Relative Addressing mode

12. Implied Addressing Group V : Implied Addressing mode


Dr Abdullah Al Masrub ECE484 3
8086 Microprocessor Group I : Addressing modes for
Addressing Modes register and immediate data

1. Register Addressing The instruction will specify the name of the


register which holds the data to be operated by
2. Immediate Addressing the instruction.
3. Direct Addressing Example:
4. Register Indirect Addressing
MOV CL, DH
5. Based Addressing
The content of 8-bit register DH is moved to
6. Indexed Addressing another 8-bit register CL

7. Based Index Addressing (CL)  (DH)

8. String Addressing

9. Direct I/O port Addressing

10. Indirect I/O port Addressing

11. Relative Addressing

12. Implied Addressing

Dr Abdullah Al Masrub ECE484 4


8086 Microprocessor Group I : Addressing modes for
Addressing Modes register and immediate data

1. Register Addressing
In immediate addressing mode, an 8-bit or 16-bit
2. Immediate Addressing data is specified as part of the instruction
3. Direct Addressing
Example:
4. Register Indirect Addressing
MOV DL, 08H
5. Based Addressing
The 8-bit data (08H) given in the instruction is
6. Indexed Addressing moved to DL

7. Based Index Addressing (DL)  08H

8. String Addressing Example:


9. Direct I/O port Addressing MOV AX, 0A9FH
10. Indirect I/O port Addressing
The 16-bit data (0A9FH) given in the instruction is
11. Relative Addressing moved to AX register

12. Implied Addressing (AX)  0A9FH

Dr Abdullah Al Masrub ECE484 5


8086 Microprocessor
Addressing Modes : Memory Access

Offset Value (16 bits)

Segment Register (16 bits) 0000

Adder

Physical Address (20 Bits)

Dr Abdullah Al Masrub ECE484 6


8086 Microprocessor
Addressing Modes : Memory Access

20 Address lines  8086 can address up to


220 = 1M bytes of memory

However, the largest register is only 16 bits

Physical Address will have to be calculated


Physical Address : Actual address of a byte in
memory. i.e. the value which goes out onto the
address bus.

Memory Address represented in the form –


Seg : Offset (Eg - 89AB:F012)

Each time the processor wants to access


memory, it takes the contents of a segment
register, shifts it one hexadecimal place to the
16 bytes of
left (same as multiplying by 1610), then add the contiguous memory
required offset to form the 20- bit address

89AB : F012  89AB  89AB0 (Paragraph to byte  89AB x 10 = 89AB0)


F012  0F012 (Offset is already in byte unit)
+ -------
98AC2 (The absolute address)

Dr Abdullah Al Masrub ECE484 7


8086 Microprocessor
Addressing Modes : Memory Access

To access memory we use these four registers: BX,


BP, SI, DI

Combining these registers inside [ ] symbols, we


can get different memory locations (Effective
Address, EA)

Supported combinations:

[BX + SI] [SI] [BX + SI + d8]


[BX + DI] [DI] [BX + DI + d8]
[BP + SI] d16 (variable offset only) [BP + SI + d8]
[BP + DI] [BX] [BP + DI + d8]

[SI + d8] [BX + SI + d16] [SI + d16]


[DI + d8] [BX + DI + d16] [DI + d16]
[BP + d8] [BP + SI + d16] [BP + d16]
[BX + d8] [BP + DI + d16] [BX + d16]

BX SI
+ disp
BP DI

Dr Abdullah Al Masrub ECE484 8


8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

Here, the effective address EA of the memory


1. Register Addressing location is just a 16-bit number written directly in
the instruction.
2. Immediate Addressing

3. Direct Addressing This addressing mode is called direct because the


displacement of the operand from the segment
4. Register Indirect Addressing base is specified directly in the instruction.

5. Based Addressing Example:

6. Indexed Addressing MOV BX, [1354H]

7. Based Index Addressing The square brackets around the 1354H denotes
the contents of the memory location.
8. String Addressing
Operations:
9. Direct I/O port Addressing
EA = 1354H
10. Indirect I/O port Addressing BA = (DS) x 1610
MA = BA + EA
11. Relative Addressing
(BX)  (MA) or,
12. Implied Addressing (BL)  (MA)
(BH)  (MA +1)

When executed, this instruction will copy the


contents of the memory location into BX register.

Dr Abdullah Al Masrub ECE484 9


8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

1. Register Addressing In Register indirect addressing, name of the


register which holds the effective address (EA)
2. Immediate Addressing will be specified in the instruction.

3. Direct Addressing Registers used to hold EA are any of the following


registers: BX, BP, DI and SI.
4. Register Indirect Addressing
Content of the DS register is used for base
5. Based Addressing address calculation.
6. Indexed Addressing
Example: Note : Register/ memory
7. Based Index Addressing enclosed in brackets refer
MOV CX, [BX] to content of register/
memory
8. String Addressing
Operations:
9. Direct I/O port Addressing
EA = (BX)
10. Indirect I/O port Addressing BA = (DS) x 1610
MA = BA + EA
11. Relative Addressing
(CX)  (MA) or,
12. Implied Addressing
(CL)  (MA)
(CH)  (MA +1)

Dr Abdullah Al Masrub ECE484 10


8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

1. Register Addressing In Based Addressing, BX or BP is used to hold the


base value for effective address and a signed 8-bit
2. Immediate Addressing or unsigned 16-bit displacement will be specified
in the instruction.
3. Direct Addressing
In case of 8-bit displacement, it is sign extended
4. Register Indirect Addressing to 16-bit before adding to the base value.

5. Based Addressing When BX holds the base value of EA, 20-bit


physical address is calculated from BX and DS.
6. Indexed Addressing
When BP holds the base value of EA, BP and SS is
7. Based Index Addressing
used.
8. String Addressing
Example:
9. Direct I/O port Addressing
MOV AX, [BX + 08H]
10. Indirect I/O port Addressing
Operations:
11. Relative Addressing
0008H  08H (Sign extended)
12. Implied Addressing EA = (BX) + 0008H
BA = (DS) x 1610
MA = BA + EA

(AX)  (MA) or,


(AL)  (MA)
Dr Abdullah Al Masrub (AH) ECE484
 (MA + 1) 11
8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

1. Register Addressing SI or DI register is used to hold an index value for


memory data and a signed 8-bit or unsigned 16-
2. Immediate Addressing bit displacement will be specified in the
instruction.
3. Direct Addressing
Displacement is added to the index value in SI or
4. Register Indirect Addressing DI register to obtain the EA.

5. Based Addressing In case of 8-bit displacement, it is sign extended


to 16-bit before adding to the base value.
6. Indexed Addressing
Example:
7. Based Index Addressing

8. String Addressing MOV CX, [SI + A2H]

9. Direct I/O port Addressing Operations:

10. Indirect I/O port Addressing FFA2H  A2H (Sign extended)

11. Relative Addressing EA = (SI) + FFA2H


BA = (DS) x 1610
12. Implied Addressing
MA = BA + EA

(CX)  (MA) or,


(CL)  (MA)
(CH)  (MA + 1)

Dr Abdullah Al Masrub ECE484 12


8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

1. Register Addressing In Based Index Addressing, the effective address


is computed from the sum of a base register (BX
2. Immediate Addressing or BP), an index register (SI or DI) and a
displacement.
3. Direct Addressing
Example:
4. Register Indirect Addressing
MOV DX, [BX + SI + 0AH]
5. Based Addressing
Operations:
6. Indexed Addressing
000AH  0AH (Sign extended)
7. Based Indexed Addressing

8. String Addressing EA = (BX) + (SI) + 000AH


BA = (DS) x 1610
9. Direct I/O port Addressing MA = BA + EA

10. Indirect I/O port Addressing (DX)  (MA) or,

11. Relative Addressing (DL)  (MA)


(DH)  (MA + 1)
12. Implied Addressing

Dr Abdullah Al Masrub ECE484 13


8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

1. Register Addressing Employed in string operations to operate on string


data.
2. Immediate Addressing
The effective address (EA) of source data is stored
3. Direct Addressing in SI register and the EA of destination is stored in
DI register.
4. Register Indirect Addressing
Segment register for calculating base address of
5. Based Addressing source data is DS and that of the destination data
is ES
6. Indexed Addressing

7. Based Index Addressing


Example: MOV S BYTE (move byte string)
8. String Addressing
Operations:
9. Direct I/O port Addressing
Calculation of source memory location:
10. Indirect I/O port Addressing EA = (SI) BA = (DS) x 1610 MA = BA + EA

11. Relative Addressing Calculation of destination memory location:


EAE = (DI) BAE = (ES) x 1610 MAE = BAE + EAE
12. Implied Addressing
(MAE)  (MA)
Note : Effective address of
the Extra segment register If DF = 1, then (SI)  (SI) – 1 and (DI) = (DI) - 1
If DF = 0, then (SI)  (SI) +1 and (DI) = (DI) + 1

Dr Abdullah Al Masrub ECE484 14


8086 Microprocessor Group III : Addressing
Addressing Modes modes for I/O ports

1. Register Addressing These addressing modes are used to access data


from standard I/O mapped devices or ports.
2. Immediate Addressing
In direct port addressing mode, an 8-bit port
3. Direct Addressing address is directly specified in the instruction.

4. Register Indirect Addressing Example: IN AL, [09H]

5. Based Addressing Operations: PORTaddr = 09H


(AL)  (PORT)
6. Indexed Addressing
Content of port with address 09H is
7. Based Index Addressing
moved to AL register
8. String Addressing
In indirect port addressing mode, the instruction
9. Direct I/O port Addressing will specify the name of the register which holds
the port address. In 8086, the 16-bit port address
10. Indirect I/O port Addressing is stored in the DX register.

11. Relative Addressing Example: OUT [DX], AX

12. Implied Addressing Operations: PORTaddr = (DX)


(PORT)  (AX)

Content of AX is moved to port


whose address is specified by DX
register.
Dr Abdullah Al Masrub ECE484 15
8086 Microprocessor Group IV : Relative
Addressing Modes Addressing mode

1. Register Addressing

2. Immediate Addressing

3. Direct Addressing In this addressing mode, the effective address of


a program instruction is specified relative to
4. Register Indirect Addressing Instruction Pointer (IP) by an 8-bit signed
displacement.
5. Based Addressing
Example: JZ 0AH
6. Indexed Addressing
Operations:
7. Based Index Addressing

8. String Addressing 000AH  0AH (sign extend)

9. Direct I/O port Addressing If ZF = 1, then

10. Indirect I/O port Addressing EA = (IP) + 000AH


BA = (CS) x 1610
11. Relative Addressing MA = BA + EA

12. Implied Addressing If ZF = 1, then the program control jumps to


new address calculated above.

If ZF = 0, then next instruction of the


program is executed.

Dr Abdullah Al Masrub ECE484 16


8086 Microprocessor Group IV : Implied
Addressing Modes Addressing mode

1. Register Addressing

2. Immediate Addressing

3. Direct Addressing

4. Register Indirect Addressing

5. Based Addressing

6. Indexed Addressing
Instructions using this mode have no operands.
The instruction itself will specify the data to be
7. Based Index Addressing
operated by the instruction.
8. String Addressing
Example: CLC
9. Direct I/O port Addressing
This clears the carry flag to zero.
10. Indirect I/O port Addressing

11. Relative Addressing

12. Implied Addressing

Dr Abdullah Al Masrub ECE484 17


Instruction Set

Dr Abdullah Al Masrub ECE484 18


8086 Microprocessor
Instruction Set

 8086 supports 6 types of instructions:


 Data Transfer Instructions
 Arithmetic Instructions
 Logical Instructions
 String manipulation Instructions
 Process Control Instructions
 Control Transfer Instructions

Dr Abdullah Al Masrub ECE484 19


8086 Microprocessor
Instruction Size

 Each instruction has two parts.


 The first part is the task or operation to be performed.
• This part is called the “opcode” (operation code).
 The second part is the data to be operated on
• This part is called the “operand”.

 Depending on the operand type, the instruction may have


different sizes. It will occupy a different number of memory
bytes.

 Typically, all instructions occupy one byte only.

 The exception is:


 Instructions that include immediate data use two bytes.
 Instructions that include a memory address occupy three bytes.

Dr Abdullah Al Masrub ECE484 20


8086 Microprocessor
Instruction Size

Dr Abdullah Al Masrub ECE484 21


8086 Microprocessor
Instruction Size

Dr Abdullah Al Masrub ECE484 22


8086 Microprocessor
Instruction Size

1000 0101

Dr Abdullah Al Masrub ECE484 23

You might also like