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

chapter 3 programming and instruction set L1_2025 (3)

Chapter 3 covers the programming and instruction sets of the 8086 microprocessor, detailing the structure of machine and assembly languages, including their specific mnemonics. It explains various addressing modes used in instructions, including register, immediate, direct, and indirect addressing, along with examples. The chapter also discusses how memory access is calculated and the role of segment and offset in forming physical addresses.

Uploaded by

Kenenisa Dadi
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)
8 views

chapter 3 programming and instruction set L1_2025 (3)

Chapter 3 covers the programming and instruction sets of the 8086 microprocessor, detailing the structure of machine and assembly languages, including their specific mnemonics. It explains various addressing modes used in instructions, including register, immediate, direct, and indirect addressing, along with examples. The chapter also discusses how memory access is calculated and the role of segment and offset in forming physical addresses.

Uploaded by

Kenenisa Dadi
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

CHAPTER 3

8086 Microprocessor Programming &


Instruction Sets

LECTURE 1
CONTENTS

 Introduction
 Addressing modes

 Instruction formats

 Instruction set

 Assembler directives

 Simple program examples

2
8086 Microprocessor
Introduction

Program
A set of instructions written to solve a
problem.

Instruction
Directions which a microprocessor follows
to execute a task or part of a task.

Computer language

High Level Low Level

Machine Language Assembly Language

 Binary bits  English Alphabets


 ‘Mnemonics’
 Assembler Mnemonics
 Machine Language
3
Introduction cont..

• A Machine language program to add two


numbers (2H + 4H)

• 0011 1110 ; Copy value 2H in register AL


0000 0010
0000 0110 ; Copy value 4H in register BL
0000 0100
1000 0000 ; AL = AL + BL

4
Introduction cont..

• Assembly Language of 8086


– It uses English like words to convey the
action/meaning called as MNEMONICS

– For e.g.
• MOV to indicate data transfer

• ADD to add two values

• SUB to subtract two values

5
Introduction cont..

• Assembly language program to add two numbers

MVI A, 2H ;Copy value 2H in register A


MVI B, 4H ;Copy value 4H in register B
ADD B ;A = A + B

• Note:
– Assembly language is specific to a given processor,
architecture dependent
– For e.g. assembly language of 8086 is different
than that of Motorola 6800 microprocessor

6
Introduction cont..

• Microprocessor understands Machine Language


only!
• Microprocessor cannot understand a program
written in Assembly language
• A program known as Assembler is used to
convert a Assembly language program to
machine language

Assembly Machine
Assembler
Language Language
Program
Program Code

7
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 I/O
10. Indirect I/O port Addressing ports

11. Relative Addressing Group IV : Relative Addressing mode

12. Implied Addressing Group V : Implied Addressing mode


9
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 the instruction.
2. Immediate Addressing
Example:
3. Direct Addressing
MOV CL, DH
4. Register Indirect Addressing

5. Based Addressing The content of 8-bit register DH is moved to another 8-


bit register CL
6. Indexed Addressing
(CL)  (DH)
7. Based Index Addressing

8. String Addressing

9. Direct I/O port Addressing

10. Indirect I/O port Addressing

11. Relative Addressing

12. Implied Addressing

10
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 data
2. Immediate Addressing 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 moved
6. Indexed Addressing to DL

7. Based Index Addressing (DL)  08H

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

11
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 left (same as
multiplying by 1610), then add the required offset to 16 bytes of
form the 20- bit address contiguous memory

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


F012  0F012 (Offset is already in byte unit)
+ -------
98AC2 (The absolute address)
12
8086 Microprocessor
Addressing Modes : Memory Access

Offset Value (16 bits)

Segment Register (16 bits) 0000

Adder

Physical Address (20 Bits)

13
8086 Microprocessor
Addressing Modes : Memory Access

To access memory we use these four registers: BX,


SI, DI, BP
Combining these registers inside [ ] symbols, we can
get different memory locations (Effective Address, EA)
Supported combinations:

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


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

[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 14
8086 Microprocessor Group II : Addressing modes for
Addressing Modes memory data

1. Register Addressing

2. Immediate Addressing
Here, the effective address of the memory location at
3. Direct Addressing
which the data operand is stored is given in the
4. Register Indirect Addressing instruction.

5. Based Addressing The effective address is just a 16-bit number written


directly in the instruction.
6. Indexed Addressing
Example:
7. Based Index Addressing
MOV BX, [1354H]
8. String Addressing MOV BL, [0400H]
9. Direct I/O port Addressing
The square brackets around the 1354H denotes the
contents of the memory location. When executed, this
10. Indirect I/O port Addressing
instruction will copy the contents of the memory location
11. Relative Addressing into BX register.

12. Implied Addressing This addressing mode is called direct because the
displacement of the operand from the segment base is
specified directly in the instruction.

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

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


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

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


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

(CL)  (MA)
(CH)  (MA +1)
16
8086 Microprocessor Group II : Addressing modes for
Addressing Modes 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 or
2. Immediate Addressing unsigned 16-bit displacement will be specified in the
instruction.
3. Direct Addressing
In case of 8-bit displacement, it is sign extended to 16-
4. Register Indirect Addressing 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 used.
7. Based Index Addressing

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)


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

(AX)  (MA) or,

(AL)  (MA)
(AH)  (MA + 1)
17
8086 Microprocessor Group II : Addressing modes for
Addressing Modes 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-bit
2. Immediate Addressing displacement will be specified in the instruction.

3. Direct Addressing Displacement is added to the index value in SI or DI


register to obtain the EA.
4. Register Indirect Addressing
In case of 8-bit displacement, it is sign extended to 16-
5. Based Addressing bit before adding to the base value.
6. Indexed Addressing
Example:
7. Based Index Addressing

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

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
MA = BA + EA
12. Implied Addressing
(CX)  (MA) or,

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

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

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


computed from the sum of a base register (BX or BP),
2. Immediate Addressing 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 Index Addressing
EA = (BX) + (SI) + 000AH
8. String Addressing BA = (DS) x 1610
MA = BA + EA
9. Direct I/O port Addressing
(DX)  (MA) or,
10. Indirect I/O port Addressing
(DL)  (MA)
11. Relative Addressing (DH)  (MA + 1)

12. Implied Addressing

19
8086 Microprocessor Group II : Addressing modes for
Addressing Modes 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 in SI


register and the EA of destination is stored in DI
3. Direct Addressing register.

4. Register Indirect Addressing Segment register for calculating base address of


source data is DS and that of the destination data is ES
5. Based Addressing

6. Indexed Addressing
Example: MOVS BYTE
7. Based Index Addressing
Operations:
8. String Addressing
Calculation of source memory location:
9. Direct I/O port Addressing EA = (SI) BA = (DS) x 1610 MA = BA + EA

10. Indirect I/O port Addressing Calculation of destination memory location:


EAE = (DI) BAE = (ES) x 1610 MAE = BAE + EAE
11. Relative Addressing

12. Implied Addressing (MAE)  (MA)

Note : Effective address of If DF = 1, then (SI)  (SI) – 1 and (DI) = (DI) - 1


the Extra segment register If DF = 0, then (SI)  (SI) +1 and (DI) = (DI) + 1

20
8086 Microprocessor Group III : Addressing modes
Addressing 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 address is
3. Direct Addressing 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 will
9. Direct I/O port Addressing specify the name of the register which holds the port
address. In 8086, the 16-bit port address is stored in
10. Indirect I/O port Addressing 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. 21
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 Instruction
4. Register Indirect Addressing Pointer (IP) by an 8-bit signed displacement.

5. Based Addressing Example: JZ 0AH


6. Indexed Addressing
Operations:
7. Based Index Addressing
000AH  0AH (sign extend)
8. String Addressing
If ZF = 1, then
9. Direct I/O port Addressing
EA = (IP) + 000AH
10. Indirect I/O port Addressing BA = (CS) x 1610
MA = BA + EA
11. Relative Addressing
If ZF = 1, then the program control jumps to new
12. Implied Addressing address calculated above.

If ZF = 0, then next instruction of the program is


executed.

22
8086 Microprocessor Group IV : Implied
Addressing Modes Addressing mode

1. Register Addressing

2. Immediate Addressing Instructions using this mode have no operands. The


instruction itself will specify the data to be operated
3. Direct Addressing by the instruction.

4. Register Indirect Addressing Example: CLC

5. Based Addressing This clears the carry flag to zero.

6. Indexed Addressing

7. Based Index Addressing

8. String Addressing

9. Direct I/O port Addressing

10. Indirect I/O port Addressing

11. Relative Addressing

12. Implied Addressing

23

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy