Professional Documents
Culture Documents
MICROPROCESSORS AND
MICROCONTROLLERS
systems.
Unit- 3 I/O And Memory Interface; Serial About the interfacing techniques to 8086 and
Communication and Bus 8051 based systems
Interface
Unit- 5 Advanced ARM Processors About the basic concepts of advanced ARM
processors
Unit Name Description
Syllabus
Unit- 1 8086 Architecture; Instruction About internal architecture, organization and
Set and Assembly Language assembly language programming of 8086
Programming of 8086 microprocessor
Unit- 3 I/O And Memory Interface; Serial About the interfacing techniques to 8086 and
Communication and Bus 8051 based systems
Interface
Unit- 5 Advanced ARM Processors About the basic concepts of advanced ARM
processors
Unit Name Description
Syllabus
Unit- 1 8086 Architecture; Instruction About internal architecture, organization and
Set and Assembly Language assembly language programming of 8086
Programming of 8086 microprocessor
Unit- 3 I/O And Memory Interface; Serial About the interfacing techniques to 8086 and
Communication and Bus 8051 based systems
Interface
Unit- 5 Advanced ARM Processors About the basic concepts of advanced ARM
processors
Unit Name Description
Syllabus
Unit- 1 8086 Architecture; Instruction About internal architecture, organization and
Set and Assembly Language assembly language programming of 8086
Programming of 8086 microprocessor
Unit- 3 I/O And Memory Interface; Serial About the interfacing techniques to 8086 and
Communication and Bus 8051 based systems
Interface
Unit- 5 Advanced ARM Processors About the basic concepts of advanced ARM
processors
Unit Name Description
Syllabus
Unit- 1 8086 Architecture; Instruction About internal architecture, organization and
Set and Assembly Language assembly language programming of 8086
Programming of 8086 microprocessor
Unit- 3 I/O And Memory Interface; Serial About the interfacing techniques to 8086 and
Communication and Bus 8051 based systems
Interface
Unit- 5 Advanced ARM Processors About the basic concepts of advanced ARM
processors
Unit Name Description
Syllabus
Unit- 1 8086 Architecture; Instruction About internal architecture, organization and
Set and Assembly Language assembly language programming of 8086
Programming of 8086 microprocessor
Unit- 3 I/O And Memory Interface; Serial About the interfacing techniques to 8086 and
Communication and Bus 8051 based systems
Interface
Unit- 5 Advanced ARM Processors About the basic concepts of advanced ARM
processors
Computer Block Diagram
Microprocessor based System
(Computer)
Integrated Circuits
(Microprocessors and Microcontrollers)
Microprocessors Versus
Microcontroller
Microprocessors Versus
Microcontroller
Unit-I
8086
Microprocessor
Architecture
8086
Microprocessor
Program controlled semiconductor device
(IC) which fetches (from memory),
decodes and executes instructions.
16
Microprocessors Evolution
First Generation
Between 1971 – 1973
PMOS technology, non compatible
with TTL
4 bit processors 16 pins
8 and 16 bit processors 40 pins
Due to limitations of pins, signals
are multiplexed
Intel 4004 (4 bit processor)
17
Microprocessors Evolution
Second Generation
Between 1973 – 1978
NMOS technology Faster speed, Higher
density, Compatible with TTL
4 / 8/ 16 bit processors 40 pins
Ability to address large memory spaces and
I/O ports
Greater number of levels of subroutine nesting
Better interrupt handling capabilities
Intel 80386
20
Microprocessors Evolution
Fifth Generation
Pentium
21
Microprocessors
Evolution
First Generation
Between 1971 – 1973
PMOS technology, non compatible with TTL
4 bit processors 16 pins
8 and 16 bit processors 40 pins
Due to limitations of pins, signals are multiplexed
22
Microprocessors
Evolution
Second Generation
Between 1973 – 1978
NMOS technology Faster speed, Higher
density, Compatible with TTL
4 / 8/ 16 bit processors 40 pins
First Generation Ability to address large memory spaces and I/O
Between 1971 – 1973 ports
PMOS technology, non compatible with TTL Greater number of levels of subroutine nesting
4 bit processors 16 pins Better interrupt handling capabilities
8 and 16 bit processors 40 pins
Due to limitations of pins, signals are multiplexed Intel 8085 (8 bit processor)
23
Microprocessors
Evolution
Third Generation
During 1978
HMOS technology Faster speed, Higher packing
density
16 bit processors 40/ 48/ 64 pins
Easier to program
Dynamically relatable programs
Processor has multiply/ divide arithmetic hardware
More powerful interrupt handling capabilities
Flexible I/O port addressing
Second Generation
Intel 8086 (16 bit processor) Between 1973 – 1978
NMOS technology Faster speed, Higher
density, Compatible with TTL
4 / 8/ 16 bit processors 40 pins
First Generation Ability to address large memory spaces and I/O
Between 1971 – 1973 ports
PMOS technology, non compatible with TTL Greater number of levels of subroutine nesting
4 bit processors 16 pins Better interrupt handling capabilities
8 and 16 bit processors 40 pins
Due to limitations of pins, signals are multiplexed Intel 8085 (8 bit processor)
24
Microprocessors
Evolution
Fourth Generation
During 1980s
Low power version of HMOS technology
(HCMOS)
Third Generation 32 bit processors
During 1978 Physical memory space 224 bytes = 16 Mb
HMOS technology Faster speed, Higher packing Virtual memory space 240 bytes = 1 Tb
density Floating point hardware
16 bit processors 40/ 48/ 64 pins Supports increased number of addressing
Easier to program modes
Dynamically relatable programs
Processor has multiply/ divide arithmetic hardware Intel 80386
More powerful interrupt handling capabilities
Flexible I/O port addressing
Second Generation
Intel 8086 (16 bit processor) Between 1973 – 1978
NMOS technology Faster speed, Higher
density, Compatible with TTL
4 / 8/ 16 bit processors 40 pins
First Generation Ability to address large memory spaces and I/O
Between 1971 – 1973 ports
PMOS technology, non compatible with TTL Greater number of levels of subroutine nesting
4 bit processors 16 pins Better interrupt handling capabilities
8 and 16 bit processors 40 pins
Due to limitations of pins, signals are multiplexed Intel 8085 (8 bit processor)
25
Microprocessors
Fifth Generation Pentium
During 1993
Evolution
Fourth Generation
During 1980s
Low power version of HMOS technology
(HCMOS)
Third Generation 32 bit processors
During 1978 Physical memory space 224 bytes = 16 Mb
HMOS technology Faster speed, Higher packing Virtual memory space 240 bytes = 1 Tb
density Floating point hardware
16 bit processors 40/ 48/ 64 pins Supports increased number of addressing
Easier to program modes
Dynamically relatable programs
Processor has multiply/ divide arithmetic hardware Intel 80386
More powerful interrupt handling capabilities
Flexible I/O port addressing
Second Generation
Intel 8086 (16 bit processor) Between 1973 – 1978
NMOS technology Faster speed, Higher
density, Compatible with TTL
4 / 8/ 16 bit processors 40 pins
First Generation Ability to address large memory spaces and I/O
Between 1971 – 1973 ports
PMOS technology, non compatible with TTL Greater number of levels of subroutine nesting
4 bit processors 16 pins Better interrupt handling capabilities
8 and 16 bit processors 40 pins
Due to limitations of pins, signals are multiplexed Intel 8085 (8 bit processor)
26
After this…….
They Started calling it as…….
Pentium series
Xeon series
Celeron series
Itenium
Core 2 Duo
Core i series (i3, i5, i7, i9, …………)
8086 Microprocessor Overview
First 16- bit processor released by
INTEL in the year 1978
Execution Unit
(EU)
8086 Microprocessor
Architecture
BIU and EU functions separately
BIU fetches instructions, reads data from memory and I/O ports, writes data
to memory and I/ O ports.
8086 Microprocessor
Architecture
EU executes instructions that have already been fetched by BIU fetches instructions, reads data from memory and I/O ports, writes data
the BIU. to memory and I/ O ports.
Segment
Registers
8086’s 1-megabyte The 8086 can directly Programs obtain access to code
memory is divided into address four segments (256 and data in the segments by
segments of up to 64K K bytes within the 1 M byte changing the segment register
bytes each. of memory) at a particular content to point to the desired
time. segments.
50
8086 Microprocessor Bus Interface Unit (BIU)
Architecture
Instruction queue
51
8086 Microprocessor
Architecture Execution Unit (EU)
and
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OF DF IF TF SF ZF AF PF CF
BIU
Code Segment Register
Registers
Segment 16-bit
Registers
CS contains the base or start of the current code segment; IP
contains the distance or offset from this address to the next
instruction byte to be fetched.
58
8086 Microprocessor Bus Interface Unit (BIU)
Architecture
59
8086 Microprocessor Bus Interface Unit (BIU)
Architecture
60
8086 Microprocessor Bus Interface Unit (BIU)
Architecture
Points to the extra segment in which data (in excess of 64K pointed
to by the DS) is stored.
61
8086 Microprocessor Bus Interface Unit (BIU)
Architecture
Instruction Pointer
BIU
Registers
Instruction 16-bit
Pointer
Always points to the next instruction to be executed within the
currently executing code segment.
62
8086 Microprocessor Execution Unit (EU)
Architecture
AL in this case contains the low order byte of the word, and AH
contains the high-order byte.
63
8086 Microprocessor Execution Unit (EU)
Architecture
This is the only general purpose register whose contents can be used
for addressing the 8086 memory.
64
8086 Microprocessor Execution Unit (EU)
Architecture
When combined, CL register contains the low order byte of the word,
and CH contains the high-order byte.
Example:
EU
Registers
66
8086 Microprocessor Execution Unit (EU)
Architecture
67
8086 Microprocessor Execution Unit (EU)
Architecture
68
Registers and Special Functions
Register Name of the Register Special Function
Used to hold base value in base addressing mode to access memory data
BX Base register
Used to hold the count value in SHIFT, ROTATE and LOOP instructions
CX Count Register
Used to hold the base value in base addressing using SS register to access data from
BP Base Pointer stack memory
Used to hold index value of source operand (data) for string instructions
SI Source Index
Used to hold the index value of destination operand (data) for string operations
DI Data Index
69
8086
Flag Register
“One Day Indian Team Selected Zaheer And Played Cricket”
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
X X X X OF DF IF TF SF ZF X AF X PF X CF
70
8086 Microprocessor Execution Unit (EU)
Architecture
Flag Register
X X X X OF DF IF TF SF ZF X AF X PF X CF
71
8- bit Data
7 6 5 4 3 2 1 0
72
Data in 8086
16- bit Data
<- Higher Byte -
<- Lower Byte ->
>
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
73
8086 Microprocessor Execution Unit (EU)
Architecture
Flag Register
Carry Flag
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
X X X X OF DF IF TF SF ZF X AF X PF X CF
74
8086 Microprocessor Execution Unit (EU)
Architecture
Flag Register
Parity Flag
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
X X X X OF DF IF TF SF ZF X AF X PF X CF
75
8086 Microprocessor Execution Unit (EU)
Architecture
Flag Register
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
X X X X OF DF IF TF SF ZF X AF X PF X CF
Flag Register
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
X X X X OF DF IF TF SF ZF X AF X PF X CF
Zero Flag
77
8086 Microprocessor Execution Unit (EU)
Architecture
Flag Register
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
X X X X OF DF IF TF SF ZF X AF X PF X CF
Sign Flag
78
8086 Microprocessor Execution Unit (EU)
Architecture
Flag Register
Tarp Flag
If this flag is set, the processor enters
the single step execution mode by
generating internal interrupts after the
execution of each instruction
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
X X X X OF DF IF TF SF ZF X AF X PF X CF
79
8086 Microprocessor Execution Unit (EU)
Architecture
Flag Register
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
X X X X OF DF IF TF SF ZF X AF X PF X CF
Interrupt Flag
80
8086 Microprocessor Execution Unit (EU)
Architecture
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
X X X X OF DF IF TF SF ZF X AF X PF X CF
81
8086 Microprocessor Execution Unit (EU)
Architecture
Flag Register
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
X X X X OF DF IF TF SF ZF X AF X PF X CF
82
8086 Microprocessor Execution Unit (EU)
Architecture
This flag is set, when the result of any This flag is set, if the result of the computation This flag is set to 1, if the lower byte of the result
computation is negative or comparison performed by an instruction is contains even number of 1’s ; for odd number of
zero 1’s set to zero.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
X X X X OF DF IF TF SF ZF X AF X PF X CF
Used to hold base value in base addressing mode to access memory data
BX Base register
Used to hold the count value in SHIFT, ROTATE and LOOP instructions
CX Count Register
Used to hold the base value in base addressing using SS register to access data from
BP Base Pointer stack memory
Used to hold index value of source operand (data) for string instructions
SI Source Index
Used to hold the index value of destination operand (data) for string operations
DI Data Index
84
Memory Segmentation
Linear addressing
Segmented addressing
Memory Segmentation
Linear Addressing
In linear addressing: the entire memory
space is available to the process in one
linear array.
Segmented Addressing
In segmented addressing: the available
memory space is divided into “chunks‟
called segments.
Memory Segmentation
Linear Addresses
Segmented Addresses
Memory Segmentation
Segmentation is the process in which
the main memory of the computer is
logically divided into different segments
and each segment has its own base
address. It is basically used to enhance
the speed of execution of the computer
system, so that the processor is able to
fetch and execute the data from the
memory easily and fast.
Memory Segmentation
Such memory is known segmented
memory. In 8086 system the available
memory space is 1Mbytes.
Segment
Address
Example:
If CS=2500 h & IP=95F3 h, what is the physical address?
Segment
Address
Shifted by 1
digit in Hex
Example:
If CS=2500 h & IP=95F3 h, what is the physical address?
Offset
Address
Example:
If CS=2500 h & IP=95F3 h, what is the physical address?
Physical
Address
Example:
If CS=2500 h & IP=95F3 h, what is the physical address?
Segment
Address Segment
Address
Shifted by 1
digit in Hex
Offset
Address
Physical
Address
Example: The following operation illustrates the
generation of 20-bit physical address from CS and IP
registers.
Let: CS = 3 4 8 A H , IP= 4 2 1 4 H
Therefore,
Physical Address = Segment Register content
(Shifted by 1 digit in Hexadecimal) + Offset Register Content
Example:
If CS=24F6h & IP=634Ah, show the;
1- The logical address
2- The offset address Segment
3- The physical address Address
4- The lower range of the segment
5- The upper range of the segment Segment
Address
Shifted by
1 digit in
Hex
Offset
Address
Solution:
1- The logical address is the CS: IP content which is:
24F6:634A Physical
2- The offset address is the content of the IP register Address
which is: 634A
3- The physical address: 2B2AA
4- The lower range of the
segment:
Bottom of
the
segment
The Programming Model of 8086
The programming model of the 8086 through
the Pentium II is considered to be program
visible because its registers are used during
application programming and are specified by the
instructions. Other registers, are considered to
be program invisible because they are not
addressable directly during applications
programming, but may be used indirectly during
system programming. Only the 80286 and above
contain the program-invisible registers used to
control and operate the protected memory
system.
The Programming Model of 8086
Computer Languages
Assembly Language
English Alphabets
‘Mnemonics’
Assembler Mnemonics
Machine Language
Machine Language
Binary bits
8086 Microprocessor
Introduction to Assembly Language Program
Program
A set of instructions
written to solve a
problem.
113
8086 Microprocessor
Introduction to Assembly Language Program
Instruction
Directions which a
microprocessor follows
to execute a task or part
of a task.
114
8086 Microprocessor
Introduction to Assembly Language Program
Assembler Directive
Hints/Directions given to
assembler, which helps it
to correctly understand the
program for generating
OpCodes
115
8086 Microprocessor
Introduction to Assembly Language Program
Comments
Explanation or
Annotations, are
added with the
purpose of making
the source code
easier for humans to
understand, and are
generally ignored by
compilers and
interpreters.
116
8086 Pin Diagram
01/23/17
AD0-AD15 (Bidirectional)
Address/Data bus
8086 System
BHE = 0 A0 = 0
Odd Even
Address Address
Bank Bank
8086 1 2
Processor D0 – D7 D0 – D7
D8 - D15
D0 – D7
Physical Memory Organization in 8086
System
Read/Write Operation between Processor
and Memory
Pins and Signals
Of 8086
As observed earlier while discussing features of
Microprocessor 8086, that 8086 can operate into two
modes:
Minimum Mode
Maximum Mode
AD0-AD15 (Bidirectional)
Address/Data bus
Low order address bus; these
are multiplexed with data.
125
8086 Microprocessor
Pins and Signals
Common signals
126
8086 Microprocessor
Pins and Signals Common signals
(Active Low)/S7
(Output)
Bus High
Enable/Status
127
8086 Microprocessor
Pins and Signals Common signals
MINIMUM / MAXIMUM
128
8086 Microprocessor
Pins and Signals Min/ Max Pin
Minimum
Mode
Signals
Maximum
Mode
Signals 129
8086 Microprocessor
Pins and Signals Min/ Max Pin
130
8086 Microprocessor
Pins and Signals Min/ Max Pin
131
8086 Microprocessor
Pins and Signals Minimum Mode Pins
Minimum
Mode
Signals
132
8086 Microprocessor
Pins and Signals Maximum Mode Pins
Maximum
Mode
Signals
133
8086 Microprocessor
Pins and Signals Common signals
(Active Low)
READ
The signal is used for read
operation.
It is an output signal.
It is active when low
134
8086 Microprocessor
Pins and Signals Common signals
(Active Low)
This input is examined by ‘WAIT’ instruction.
135
8086 Microprocessor
Pins and Signals Common signals
READY
136
8086 Microprocessor
Pins and Signals Common signals
RESET (Input)
137
8086 Microprocessor
Pins and Signals Common signals
CLK
138
8086 Microprocessor
Pins and Signals Common signals
139
8086 Microprocessor
Pins and Signals Common signals
NMI
(Non- Maskable Interrupt)
140
8086 Microprocessor
Pins and Signals Minimum Mode Signals
Minimum
Mode
Signals
141
8086 Microprocessor
Pins and Signals Minimum Mode Signals
142
8086 Microprocessor
Pins and Signals Minimum Mode Signals
143
8086 Microprocessor
Pins and Signals Minimum Mode Signals
144
8086 Microprocessor
Pins and Signals Minimum Mode Signals
145
8086 Microprocessor
Pins and Signals Minimum Mode Signals
147
8086 Microprocessor
Pins and Signals Minimum Mode Signals
HOLD Input signal to the processor from the bus master (Bus Controller) as
a request to grant the control of the bus.
Usually used by the DMA controller to get the control of the bus. 148
8086 Microprocessor
Pins and Signals Minimum Mode Signals
Minimum
Mode
Signals
150
8086 Microprocessor
Pins and Signals Minimum Mode Signals
151
8086 Microprocessor
Pins and Signals Minimum Mode Signals
152
8086 Microprocessor
Pins and Signals Minimum Mode Signals
153
8086 Microprocessor
Pins and Signals Minimum Mode Signals
154
8086 Microprocessor
Pins and Signals Minimum Mode Signals
156
8086 Microprocessor
Pins and Signals Minimum Mode Signals
HOLD Input signal to the processor from the bus master (Bus Controller) as
a request to grant the control of the bus.
Usually used by the DMA controller to get the control of the bus. 157
8086 Microprocessor
Pins and Signals Minimum Mode Signals
Maximum
Mode
Signals
162
8086 Microprocessor
Pins and Signals Maximum Mode Signals
QS1 QS0
163
8086 Microprocessor
Pins and Signals Maximum Mode Signals
164
8086 Microprocessor
Pins and Signals Maximum Mode Signals
165
8086 Microprocessor
Pins and Signals Maximum Mode Signals
Active
166
8086 Microprocessor
Pins and Signals Maximum Mode Signals
LOCK
167
8086 Microprocessor
Pins and Signals Maximum Mode Signals
168
8086 Maximum Mode System
8086 Maximum Mode Read Cycle
8086 Maximum Mode Write Cycle
INTERRUPT
An Interrupt is a condition that causes the
microprocessor to temporarily work on a
different task and then return to its previous
task. Interrupt is an event or signal that
request to attention of CPU
Types of Interrupts in Microprocessor
8086 System
Interrupts
Software Interrupt
Hardware Interrupt
(INT n)
Software Interrupt
Hardware Interrupt
(INT n)
The Programmer
can Choose to
mask specific
Maskable Interrupt Non- Maskable
interrupts and re 256 Types of
(INTR) Interrupt (NMI) Software Interrupt
enable them later
Types of Interrupts in Microprocessor
8086 System
Interrupts
Software
The Interrupt
Programmer cannot
Hardware Interrupt Control when
(INT n) a Non-
Maskable Interrupt is
served.
The processor has to
execute the NMI Service
Routine
INT 02 (non-maskable)
INT 03 (breakpoint)
op-code byte:
- This byte is always present in each instruction .
This indicates the operation to be carried out by 8086
Op-code D W
Most of the opcodes in 8086 has a special 1-bit
indicates.
They are :
W-bit : Some instructions of 8086 can operate on byte or a word.
The W-bit in the opcode of such instruction specify whether
instruction is a byte instruction (W = 0) or a word instruction (W =
1).
D-bit : The D-bit in the opcode of the instruction indicates that
the register (REG) specified within the instruction is a source
register (D = 0) or destination register (D =1).
Instruction Format
The opcode/operand mode byte(s) may
be followed by :
No additional byte
One or two byte immediate operand
Two byte EA (For direct addressing only).
One or two byte displacement
One or two byte displacement followed by a one or two
byte immediate operand
Two byte displacement and a two byte segment address
(for direct intersegment addressing only).
Instruction Format
One Byte Instructions
This format is only 1 byte long and
may have implicit data or register
operands.
The least 3 bits of op-code are used
to specify the register operand.
Otherwise all the 8 bit form an op-
code and the operand are implied.
REG field
Register to Register
This format is 2 byte long
1st byte of code consist of operation code
of instruction and width of the operand
specified by w bit.
2nd byte of code consist of register & R/M
field.
REG indicates the name of the register i.e
source or destination.
R/M indicates source or destination operand
is located in register
R/M field
Register to/from Memory with no displacement
This format is also 2 byte long
1st byte of code same as that of
register to register format
2nd byte of code consist of MOD ,
REG,R/M field.
MOD indicates the displacement is
present or not .if present then it is
8bit or 16 bit.
Mod field
Mod Displacement
0 0 No displacement
208
Addressing Modes
3. Direct Addressing
210
Addressing Modes
211
Addressing Modes
Group V : Relative
12.Relative Addressing Addressing mode
212
Addressing Modes
Group VI : Implied
13.Implied Addressing Addressing mode
213
01/23/17
8086 Microprocessor Group I : Addressing modes for register and
Addressing Modes immediate data
3. Direct Addressing
The instruction will specify the name of the register which holds the
data to be operated by the instruction.
4. Register Indirect Addressing
Example:
5. Based Addressing
MOV CL, DH
6. Indexed Addressing
9. String Addressing
215
8086 Microprocessor Group I : Addressing modes for register and
Addressing Modes immediate data
Immediate Addressing
1. Register Addressing
2. Immediate Addressing
In immediate addressing mode, an 8-bit or 16-bit data is specified as
3. Direct Addressing part of the instruction
9. String Addressing
MOV AX, 0A79FH
10. Direct I/O port Addressing
The 16-bit data (0A79FH) given in the instruction is moved to AX
11. Indirect I/O port Addressing
register
12. Relative Addressing
(AX) 0A79FH
13. Implied Addressing
216
8086 Microprocessor
Addressing Modes : Memory Access
2. Immediate Addressing
Here, the effective address of the memory location at which the data
3. Direct Addressing operand is stored is given in the instruction.
4. Register Indirect Addressing
The effective address is just a 16-bit number written directly in the
5. Based Addressing instruction.
6. Indexed Addressing Example:
9. String Addressing The square brackets around the 1354 H denotes the contents of the
memory location. When executed, this instruction will copy the
10. Direct I/O port Addressing contents of the memory location into BX register.
11. Indirect I/O port Addressing
This addressing mode is called direct because the displacement of the
12. Relative Addressing operand from the segment base is specified directly in the instruction.
220
8086 Microprocessor Group II : Addressing modes for memory
Addressing Modes data
2. Immediate Addressing
In Register indirect addressing, name of the register which holds the
3. Direct Addressing effective address (EA) will be specified in the instruction.
4. Register Indirect Addressing Registers used to hold EA are any of the following registers:
5. Based Addressing
BX, BP, DI and SI.
6. Indexed Addressing
Content of the DS register is used for base address calculation.
7. Based Indexed Addressing
Example:
8. Relative Based Indexed Addressing
MOV CX, [BX] Note : Register/ memory enclosed in
9. String Addressing brackets refer to content of register/
memory
10. Direct I/O port Addressing Operations:
(CL) (MA)
(CH) (MA +1)
221
8086 Microprocessor Group II : Addressing modes for memory
Addressing Modes data
2. Immediate Addressing
In Based Addressing, BX or BP is used to hold the base value for
3. Direct Addressing effective address.
4. Register Indirect Addressing
5. Based Addressing
When BX holds the base value of EA, 20-bit physical address is
6. Indexed Addressing calculated from BX and DS.
7. Based Indexed Addressing When BP holds the base value of EA, BP and SS is used.
8. Relative Based Indexed Addressing
Example:
9. String Addressing
MOV AX, [BX]
10. Direct I/O port Addressing
(AL) (MA)
(AH) (MA + 1)
222
8086 Microprocessor Group II : Addressing modes for memory
Addressing Modes data
1. Register Addressing
Indexed Addressing
2. Immediate Addressing
3. Direct Addressing SI or DI register is used to hold an index value for memory data.
223
8086 Microprocessor Group II : Addressing modes for memory
Addressing Modes data
1. Register Addressing
Based Indexed Addressing
2. Immediate Addressing
3. Direct Addressing In Based Index Addressing, the effective address is computed from the
sum of a base register (BX or BP) and index register (SI or DI).
4. Register Indirect Addressing
5. Based Addressing
Example:
6. Indexed Addressing
MOV DX, [BX ][SI]
7. Based Indexed Addressing
Operations:
8. Relative Based Indexed Addressing
224
8086 Microprocessor Group II : Addressing modes for memory
Addressing Modes data
2. Immediate Addressing
In Relative Based Index Addressing, the effective address is computed
3. Direct Addressing from the sum of a base register (BX or BP), index register (SI or DI)
and 8-bit or 16-bit displacement.
4. Register Indirect Addressing
225
8086 Microprocessor Group III : Addressing modes for string data
Addressing Modes
String Addressing
1. Register Addressing
2. Immediate Addressing
Employed in string operations to operate on string data.
3. Direct Addressing
The effective address (EA) of source data is stored in SI register and
4. Register Indirect Addressing the EA of destination is stored in DI register.
These addressing modes are used to access data from standard I/O
1. Register Addressing
mapped devices or ports.
2. Immediate Addressing
In Direct Port Addressing Mode, an 8-bit port address is directly
3. Direct Addressing specified in the instruction.
227
8086 Microprocessor Group V : Relative Addressing mode
Addressing Modes
2. Immediate Addressing
In this addressing mode, the effective address of a program
3. Direct Addressing instruction is specified relative to Instruction Pointer (IP) by an 8-bit
signed displacement.
4. Register Indirect Addressing
12. Relative Addressing If ZF = 1, then the program control jumps to new address
calculated above.
13. Implied Addressing
If ZF = 0, then next instruction of the program is executed.
228
8086 Microprocessor Group VI : Implied Addressing mode
Addressing Modes
1. Register Addressing
3. Direct Addressing
Instructions using this mode have no operands. The instruction itself
4. Register Indirect Addressing
will specify the data to be operated by the instruction.
5. Based Addressing
Example: CLC
6. Indexed Addressing
This clears the carry flag to zero.
7. Based Indexed Addressing
9. String Addressing
229
8086 Microprocessor Instructions of 8086
2. Arithmetic Instructions
3. Logical Instructions
234
8086 Microprocessor Instruction Set
1. Data Transfer Instructions
Mnemonics: MOV, XCHG, PUSH, POP, IN, OUT …
235
8086 Microprocessor Instruction Set
1. Data Transfer Instructions
Mnemonics: MOV, XCHG, PUSH, POP, IN, OUT …
237
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
ADD A, data
238
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
ADC A, data
239
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
SUB A, data
240
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
SBB A, data
241
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
242
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
243
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
244
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
245
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
249
8086 Microprocessor Instruction Set
3. Logical Instructions
REP
REPNZ/ REPNE
MOVS
(MAE) (MA)
MOVSW
MA = (DS) x 1610 + (SI)
MAE = (ES) x 1610 + (DI)
CMPS
SCAS
SCASW
MAE = (ES) x 1610 + (DI)
Modify flags (AL) - (MAE)
LODS
STOS
Mnemonics Explanation
CALL reg/ mem/ disp16 Call subroutine
JS disp8 Jump if SF = 1
Parity
responding with JP disp8 Jump if PF = 1
JS disp8 Jump if SF = 1
JS disp8 Jump if SF = 1
JS disp8 Jump if SF = 1
Parity
responding with JP disp8 Jump if PF = 1
Used to :
specify the start and end of a program
attach value to variables
allocate storage locations to input/ output data
define start and end of segments, procedures,
macros etc..
8086 Microprocessor
Assemble Directives
DB EQU
DW PROC
SEGMENT ENDP
ENDS FAR
ASSUME NEAR
ORG SHORT
END MACRO
EVEN ENDM
278
8086 Microprocessor Assemble Directives
DB Define Byte
DW
Define a byte type (8-bit) variable
ASSUME
SEGMENT
Reserves specific amount of memory locations to each variable
ENDS
Range : 00H – FFH for unsigned value; 00H – 7FH for positive
ORG
END value and 80H – FFH for negative value
EVEN
EQU
General form : variable DB value/ values
PROC
ENDP
FAR Example:
NEAR
LIST DB 7FH, 42H, 35H
SHORT
DB Define Word
DW
Define a word type (16-bit) variable
ASSUME
SEGMENT
ENDS
Reserves two consecutive memory locations to each variable
ORG
END
Range : 0000H – FFFFH for unsigned value;
EVEN 0000H – 7FFFH for positive value and 8000H – FFFFH for
EQU
negative value
PROC
ENDP
FAR General form : variable DW value/ values
NEAR
Example:
SHORT
SHORT
ASSUME CS: CODE, DS:DATA Tells the compiler that the instructions of
MACRO the program are stored in the segment
ENDM CODE and data are stored in the segment
DATA
8086 Microprocessor Assemble Directives
SEGMENT EVEN : Informs the assembler to store the program instructions/ data in the
ENDS memory address starting from an even address
ORG
END EQU (Equate) is used to attach a value to a variable
EVEN
EQU Example:
ORG 1000H Informs the assembler that the statements
PROC
ENDP
following ORG 1000H should be stored in
FAR memory starting with effective address 1000H
NEAR
SHORT
Var EQU 10FEH Value of variable Var is 10FEH
MACRO
ENDM
DATA SEGMENT In this data segment, effective address of
ORG 1200H memory location assigned to A will be 1200H
A DB 4CH
and that of B will be 1202H and 1203H.
EVEN
B DW 1052H
DATA ENDS
8086 Microprocessor Assemble Directives
DB
PROC Indicates the beginning of a procedure
DW
ENDP End of procedure
ASSUME
DB
Reserves one memory location for 8-bit signed
DW displacement in jump instructions
ASSUME
SEGMENT
ENDS
ORG
END
EVEN
EQU Example:
PROC
ENDP
FAR JMP SHORT The directive will reserve one memory
NEAR AHEAD location for 8-bit displacement named
AHEAD
SHORT
MACRO
ENDM
8086 Microprocessor Assemble Directives
DB
MACRO Indicate the beginning of a macro
DW
ORG
END
EVEN
EQU Example:
PROC
ENDP macroname MACRO [Arg1, Arg2 ...]
FAR Program statements in the
NEAR … macro
SHORT
…
…
MACRO
ENDM ENDM
Macros
Writing a macro is one way of ensuring
modular programming in assembly language.
A macro is a sequence of instructions, assigned
by a name and could be used anywhere in the
program.
Sample Programs
Sample Programs
Addition using Indexed Addressing
8086 Microprocessor
Sample Programs
Sorting of an Array
8086 Microprocessor
Sample Programs
Strings Comparison Program
End of Lecture
Thank You
Queries?
*Discussion*