Professional Documents
Culture Documents
Physical Address Segmentation
Physical Address Segmentation
Decoding
Execution Unit
& (EU)
Execution
BIU/EU
The 8086 CPU logic has been partitioned into two functional units
namely BIU & EU
The major reason for this separation is to increase the processing
speed of the processor
BIU contains Instruction queue, Segment registers, Instruction
pointer, Address adder
BIU performs all external transactions (bus operations) such as
instruction fetching, reading/writing operands from/to memory and
I/O devices. It also calculates 20-bit physical addresses
BIU pre-fetches instruction bytes (upto 6) in a FIFO register called
instruction queue
EU contains Control circuitry, Instruction decoder, ALU, Pointer &
Index register and Flag register
EU decodes & executes instructions from instruction queue. Control
unit in EU generates various control signals
While EU is executing instructions, BIU keeps on fetching instruction
(but upto a max. of 6) in the queue. This parallel processing of both
units is called pipelining which speeds up the overall process
Memory
∑ Interface
Instruction
Decoder
AH AL AX
BH BL BX
ARITHMETIC
CH CL CX LOGIC UNIT
DH DL DX
CONTROL
SYSTEM
STACK POINTER (SP)
BASE POINTER (BP) OPERANDS
SOURCE INDEX (SI)
DESTINATION INDEX (DI)
FLAGS
EU
8086 REGISTER ORGANIZATION
Type Register Name of the
ES Extra Segment size Register
CS Code Segment
SS Stack Segment General 16 bit AX, BX, CX, DX
DS Data Segment purpose
registers
IP Instruction Pointer 8 bit AL, AH, BL, BH,
CL, CH, DL, DH
AX AH AL Accumulator
BL Pointer 16 bit SP, BP
BX BH Base Register
registers
CX CH CL Count Register
DX DH DL Data Register Indexed 16 bit SI, DI
Stack Pointer registers
SP
BP Base Pointer
Instruction 16 bit IP
SI Source Index
Pointer
DI Destination Index
FLAGS Segment 16 bit CS, DS, SS, ES
registers
AX 16-bit Accumulator Stores the 16-bit results of arithmetic and logic operations
AL 8-bit Accumulator Stores the 8-bit results of arithmetic and logic operations
BX Base register Used to hold base value in base addressing mode to access
memory data
CX Count Register Used to hold the count value in SHIFT, ROTATE and LOOP
instructions
DX Data Register Used to hold data for multiplication and division operations
SP Stack Pointer Used to hold the offset address of top stack memory location
BP Base Pointer Used to hold the offset or base value in based addressing
mode to access data from stack memory
SI Source Index Used to hold index value of source operand (data) for string
instructions
DI Data Index Used to hold the index value of destination operand (data) for
string operations
Flag Register
Flag register is a 16-bit register with 9 active flags
U U U U OF DF IF TF SF ZF U AF U PF U CF
1. CF CARRY FLAG
2. PF PARITY FLAG
Conditional Flags
3. AF AUXILIARY CARRY (Compatible with 8085, except OF):
4. ZF ZERO FLAG Set/Reset by ALU on the basis
5. SF SIGN FLAG of results of arithmetic
6. OF OVERFLOW FLAG
operations
This is set, if there is a carry from the lowest This flag is set, when there is a
nibble, i.e, bit three during addition, or carry out of MSB in case of
borrow for the lowest nibble, i.e, bit three, addition or a borrow in case of
during subtraction. subtraction.
This flag is set, when the result This flag is set, if the result of the This flag is set to 1, if the lower byte of
of any computation is negative computation or comparison the result contains even number of
performed by an instruction is zero 1’s ; for odd number of 1’s set to zero.
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
Tarp Flag
Over flow Flag If this flag is set, the processor
This flag is set, if an overflow occurs, i.e, if the result of a signed operation enters the single step execution
is large enough to accommodate in a destination register. The result is of mode by generating internal
more than 7-bits in size in case of 8-bit signed operation and more than 15- interrupts after the execution of
bits in size in case of 16-bit sign operations, then the overflow will be set. each instruction
3
4
4
5
Only 4 such segments can be 6
addressed (active) at a time 7
8
1MB
9 Address
10 Range
11
12
13
14
15
16
FFFFFH
Memory
Code Segment 1
00000H
2
4
Data & Extra 5
Segments 6
8
1MB
9 Address
• Segments may or may not be Range
10
consecutive 11
13
(adjacent), disjointed or overlapping
14
15
Starting Addresses
8
1MB
9
We can take any value Address
Range
of Segments
of starting address of a 10
segments but it must be 11
divisible by 16 and
12
lowest 4 bits (lowest
hex digit) must be 0 13
14
15
Memory address
Examples
CS 3 4 8 A 0 SS 5 0 0 0 0
IP + 4 2 1 4 SP + F F E 0
Instruction 3 8 A B 4 Stac 5 F F E 0
(code) k
address 1 2 3 4 0 addr
DS
ess
DI + 0 0 2 2
Data 1 2 3 6 2
addr
ess
Example of Physical Address Generation for Code Segment
Memory
Start of Code Segment
1 00000H
(348A0H) Data
Segment
IP = 4214H 3
4
Code Byte at 38AB4H
Code
Segment
Extra
Segment
7 1MB
8 Address
9
Range
CS 348A0 H 10
11
IP + 4214 H 12
Physical Address 38AB4 H 13
14
15
Stack
Segment FFFFFH
Example of Physical Address Generation for Data Segment
0H
05C00H
DS: 05C0
05C50H
SI 0050 DS:EA
Memory
05C0 0
Segment Register
Offset + 0050
0A00 0A000H
SS:
0A100H
SP 0100 SS:SP
Memory
0A00 0
Segment Register
Offset + 0100
This set of
pins works in
two modes
This is an acknowledgement
signal from slower I/O
devices or memory.
It is an active high signal.
When high, it indicates that
the device is ready to transfer
data.
When low, then
microprocessor is in wait
state.
RESET(Input)
It is an interrupt request
signal.
It is active high.
It is level triggered.
NMI (Input)
It is a non-maskable
interrupt signal.
It is an active high.
It is an edge triggered
interrupt.
TEST (Input)
This is an interrupt
acknowledge signal.
When microprocessor
receives INTR signal, it
acknowledges the interrupt
by generating this signal.
It is an active low signal.
ALE (Output)
This is a Data
Transmit/Receive signal.
It decides the direction of
data flow through the
transceiver.
When it is high, data is
transmitted out.
When it is low, data is
received in.
M / IO (Output)
It is a Write signal.
It is used to write data in
memory or output device
depending on the status of
M/IO signal.
It is an active low signal.
HOLD (Input)
It is a Hold Acknowledge
signal.
It is issued after receiving
the HOLD signal.
It is an active high signal.
Pin Description for Maximum
Mode
QS1 and QS0 (Output)
0 0 No operation
1 0 Empty queue
S2 S1 S0 Status
0 0 0 Interrupt Acknowledge
0 0 1 I/O Read
0 1 0 I/O Write
0 1 1 Halt
1 0 0 Opcode Fetch
1 0 1 Memory Read
1 1 0 Memory Write
1 1 1 Passive
LOCK (Output)
Octal
transceiver
51
8086 Maximum Mode
In the maximum mode, the 8086 is operated by connecting MN/MX
pin to ground (logic 0).
In the maximum mode, there may be more than one processor in
the system (e.g. math co-processor 8087)
A bus controller (8288) is also used in this mode which is connected
to 8086 by using status signals S2,S1,S0. Some of the control
signals in this mode are generated by 8288 instead of 8086
8288 derives (regenerates) various control signals like ALE, DEN,
DT/R, Memory read/write (MRDC, MWTC), I/O read/write (IORC,
IOWC), AMWC & AIOWC by using information at status signals
S2,S1,S0 supplied by 8086
Other supporting components in the system are same as in
minimum mode (latches, transreceiver, clock generator, memory
and I/O devices)
This mode is costly due to greater hardware but is useful in large
multiprocessor systems
8288 Input & output
Derived
control
signals
Octal
transceiver54
T1 T2 T3 TW T4 READ BUS
CYCLE IN 8086
CLK
M/IO
ALE
RD
DT/R
DEN
T1 T2 T3 TW T4 WRITE BUS
CYCLE IN 8086
CLK
M/IO
ALE
ADDR/
DATA A15- DATA OUT (D15-D0)
A0
ADDR/
STATUS A19-
A16
WR
DT/R
DEN
8086 MEMORY ORGANIZATION
8086 supports 220 = 1,048,576 bytes (1Mbytes) of memory over the
address range 0000016 to FFFFF16 (00000H to FFFFFH)
Two consecutive bytes can be accessed as one word (16-bits)
The lower-addressed byte is the least significant byte of the word, and
the higher-addressed byte is its most significant byte
Address of lower byte of word is called address of the full word
Memory space of 1MB is divided into two chips (called banks) of
512KB each having even & odd addresses
This is done because most memories are ‘byte-oriented’ (1 byte
read/write at a time), but as 8086 is capable to read/write 16-bit (2
bytes) at a time, we need to use two chips for 16-bit word operations
Two banks have alternate addresses because 16-bit words are stored
in consecutive locations & at the same time 8086 must access both
banks simultaneously for 16-bit operations
If we had used only 1 chip of 1MB, 8086 could read only 1 byte at a
time & thus would need two operations (bus cycles) for every 16-bit
word operation. Thus process would have been slower.
8086 MEMORY ORGANIZATION
A, B = any assumed
memory location address in
even, odd banks. Brackets
indicate contents of
location & not address
BYTE/WORD TRANFER IN 8086
Aligned
word
Misaligned
word
Hardware
Hardware Software
SoftwareInterrupts
Interrupts
Interrupts
Interrupts INT
INT nn
Maskable
Maskable Nonmaskable
Nonmaskable 256
256Types
Typesof of
Interrupt
Interrupt Interrupt
Interrupt software
softwareInterrupts
Interrupts
(INTR)
(INTR) (NMI)
(NMI) INT
INT 00
00 to
to INT
INT FF
FF
The
Theprogrammer
programmer The
The programmer
programmer cannot
cannot
can
can choose
choose to
to mask
mask control
control when
when aa non non
specific
specific interrupts
interrupts maskable
maskableinterrupt
interruptisisserved
served
and
and re-enable
re-enable them
them
later
later The
Theprocessor
processorhas
hastotostop
stop
the
the main
main program
program to
to execute
execute
the
theNMI
NMIService
ServiceRoutine.
Routine.
8086 Interrupt Processing Steps
If an interrupt has been requested, the 8086 Microprocessor processes it by
performing the following series of steps:
1. Pushes the content of the flag register onto the stack to preserve the status of
IF and TF flags, by decrementing the stack pointer (SP) by 2
2. Disables the INTR interrupt by clearing IF in the flag register
3. Resets TF in the flag register, to disable the single step or trap interrupt
4. Pushes the content of the code segment (CS) register onto the stack by
decrementing SP by 2
5. Pushes the content of the instruction pointer (IP) onto the stack by
decrementing SP by 2
6. Performs an indirect far jump to the start of the interrupt service routine
(ISR) corresponding to the received interrupt.
Steps involved in processing an interrupt instruction by
the processor
Executes the Interrupt instruction
Executes ISR
Non-
Maskable
Interrupt
Available Interrupts
(224)
Interrupt Vector Table (IVT)
CS LSB MSB
Offset = 02 x 4 = 08
= 00008H
256 Interrupts of 8086 are Divided into
3 Groups
1. Type 00 to Type 04 interrupts -
These are used for fixed operations and hence are called
dedicated interrupts
8. String Addressing
8. String Addressing
MOV AX, 0A9FH
9. Direct I/O port Addressing
10. Indirect I/O port Addressing The 16-bit data (0A9FH) given in the instruction is moved to
AX register
11. Relative Addressing
(AX) ← 0A9FH
12. Implied Addressing
1. Register Addressing
2. Immediate Addressing
3. Direct Addressing
Here, the effective address of the memory location at
4. Register Indirect Addressing which the data operand is stored is given in the
instruction.
5. Based Addressing
The effective address is just a 16-bit number written
6. Indexed Addressing directly in the instruction.
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
Example:
8. String Addressing
6. Indexed Addressing
8. String 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
4. Register Indirect Addressing register and the EA of destination is stored in DI register.
5. Based Addressing
Segment register for calculating base address of
source data is DS and that of the destination data is ES
6. Indexed Addressing
2. Immediate Addressing
3. Direct Addressing
In this addressing mode, the effective address of a
4. Register Indirect Addressing program instruction is specified relative to Instruction
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
2. Immediate Addressing
3. Direct Addressing
5. Based Addressing
I/O devices
⇒ Ports
Ports/ /Buffer
BufferIC’s
IC’s
Microprocessor
Microprocessor I/I/OOdevices
devices
(interface
(interfacecircuitry)
circuitry)
Interrupt driven I/ O
I/O device interrupts the
processor and initiate data
transfer
Direct memory access
Data transfer is achieved by
bypassing the microprocessor
Memory mapped I/O vs I/O mapped I/O
Memory mapping I/O mapping
20 bit address are provided for I/O devices 8-bit or 16-bit addresses are provided for
I/O devices
The I/O ports or peripherals can be treated Only IN and OUT instructions can be used
like memory locations and so all for data transfer between I/O device and
instructions related to memory can be processor
used for data transmission between I/O
device and processor
Data can be moved from any register to Data transfer takes place only between
ports and vice versa accumulator and ports
When memory mapping is used for I/O Full memory space can be used for
devices, full memory address space addressing memory.
cannot be used for addressing memory.
⇒ Suitable for systems which require large
⇒ Useful only for small systems where memory capacity
memory requirement is less