8086 Microprocessor Features Overview
8086 Microprocessor Features Overview
Microprocessor
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-1
microprocessor_ CHAPTER 1 :-8086
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-2
microprocessor_ CHAPTER 1 :-8086
Chapter-1. 8086
Features of 8086:-
1) It-has a 20-bit address bus, hence it can access maximum 220 bytes of main memory
.i.e..
1MB. The address range of main memory is from 00000H to FFFFFH.
2) It has a 16-bit data bus and it has a 16-bit ALU, hence it is called as a 16-bit. microprocessor.
3) It supports 2-stage pipelining. The process of fetching next instruction while executing the current
instruction is known as pipelining.
4) It supports Memory Banking i.e. In 8086, the main memory chip is divided in to two banks in order to
fetch 16-bits of data in one cycle. The banks are termed as Lower or Even bank and Higher or Odd bank.
5) It has two operating one modes,
i. Minimum mode.
ii. Maximum mode.
In Minimum mode, there is only one processor in the system (uniprocessor).
In Maximum mode, there are processors other than 8086 in the system such as 8087,
étc. (Multiprocessor).
6) It supports Memory Segmentation.
Segmentation means dividing the memory in to logical components.
In 8086, the memory is divided in to 4 segments and they are as follows:
i. Code Segment
ii. Stack Segment.
iii. Data Segment.
iv. Extra Segment.
7) It has 256 interrupts.
8) It has a 16-bit IO address, hence it can access 226 10 ports (= 64k ports).
1. Address bus carries the address of the location present in Even or Lower bank from which data needs
to be fetched .
2. Both the banks are enabled.
Even or Lower bank is enabled when Ao line is low i.e. Ao =0.
And Odd or Higher bank is enabled when BHE line is low i.e. BHE =0.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-3
microprocessor_ CHAPTER 1 :-8086
3. Since both the banks are enabled therefore one byte of data is fetched from the Even
or Lower bank and one more byte of data is fetched from Odd or Higher bank in one
cycle thereby 16-bit of data is fetched in one cycle.
Using memory banking concept we can fetch byte 16-bit of data in one cycle thereby we
are able to make optimal use of 16-bit data bus.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-4
microprocessor_ CHAPTER 1 :-8086
Architecture of 8086:-
1) ES:-
It is a 16-bit segment register which stores the segment or base address of the extra
segment.
2) CS:-
It is a 16-bit segment register which stores the segment or base address of the code segment.
3) DS:-
It is a 16-bit segment register which stores the segment or base address of the data segment.
4) SS:-
It is a 16-bit segment register which stores the segment or base address of the extra segment.
5) Instruction Pointer(IP):-
It is a 16-bit offset register which stores an offset address of the next instruction which is to be
fetched from a code segment.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-5
microprocessor_ CHAPTER 1 :-8086
2) Stack Pointer(SP) :-
It is a 16-bit special purpose register which is used to store the offset address of the stack top symbol.
3) Base Pointer(BP):-
It is a 16-bit special purpose register which is used to store the offset address of any random location
in the stack segment
4) Source Index(SI):-
It is a 16-bit special purpose register which is used to store the offset address of a location in a data
segment.
5) Destination Index(DI):-
It is a 16-bit special purpose register which is used to store the offset address of a location in an extra
segment.
6) ALU:-
In 8086 there is a 16-bit ALU which is used to perform arithmetic and logic operations.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-6
microprocessor_ CHAPTER 1 :-8086
7) Operand Register :-
It is 16-bit special purpose register which is used to store the data temporarily.
8) Control System :-
Inside control system there are instruction register and instruction decoder.
EU fetches the instruction from the queue and stores in the instruction register then the instruction
decoder decodes the instruction and sends the information to the control circuit for execution.
9) Flag Register :-
8086 has a 16-bit flag register.
It has 6 status flags and 3 control flags.
Status flags are those flags which are affected or updated due to ALU operations are known as Status
flag.
Control flags are those flags which are used by the programmer to control certain operations.
Diagram :-
Status Flags :-
1) Carry Flag(CY):-
It is set whenever there is a carry generated out of the MSB of the result.
2) Parity Flag(PF) :-
It is set when there is even parity (.i.e. even number of one's) in the result.
4) Zero Flag(ZF):-
It is set whenever the result of an operation is equal to zero.
5) Sign Flag(SF) :-
It is set whenever the MSB of a result is 1.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-7
microprocessor_ CHAPTER 1 :-8086
It is set whenever overflow is occurred (i.e. if result of a signed operation is large enough to fit in the
number of bits available to represent it then this situation is termed as an overflow).
Control Flags :-
1) Direction Flag(DF) :-
When this flag is set (i.e. DF=1) the microprocessor enters the auto-decrement mode.
3) Trap Flag(TF) :-
When this flag is set (i.e. TF=1) the microprocessor enters the single stepping mode.
Diagram:-
2) Stack Segment
3) Data Segment.
4) Extra Segment
In 8086 the maximum size of a segment can be 64KB and minimum size of a segment can be 16 bytes.
In 8086 a programmer can define multiple segments of a particular type but it can access maximum 4
segments at a time.
In 8086 there are 4 16-bit registers such as CS,SS,DS and ES to hold the base address of the
segments and it also has 16-bit offset registers to hold the offset address for each of the segments.
Code Segment:-
This segment is used to store programs and instructions.
CS is a 16-bit segment register which stores the Segment or base address for the code segment.
IP is a 16-bit offset register which stores the offset address of the next instruction which is to be fetched
from the code segment.
Stack Segment :-
This segment is used to store the data in a particular manner i.e. in LIFO manner.
SS is a 16-bit segment register which stores the segment or base address for the stack segment.
SP is a 16-bit offset register which stores the offset address of the stack top symbol.
BP is a 16-bit offset register which stores the offset address of any random in stack segment.
Data Segment :-
This segment is used to store the data.
Ds is a 16-bit segment register which stores the segment or base address for the data segment.
SI(Source Index) is a 16-bit offset register which stores the offset address of a location in the data
segment.
Extra Segment :-
This segment is used store the data.
ES is a 16-bit segment register which stores the segment or base address for the extra segment.
DI(Destination Index) is a 16-bit offset register which stores the offset address of a location in
the extra segment.
Address Calculation:-
8086 calculates 20-bit physical address using segment address and offset address using the
following formula:-
Physical Address = Segment Address * 10H + Offset Address.
Advantages of Segmentation :-
Using segmentation we can access 1MB of main memory using 16-bit address.
Disadvantages of Segmentation :-
Due to segmentation, at a time we can access only 4* 64KB of main memory i.e. 256KB instead
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-9
microprocessor_ CHAPTER 1 :-8086
CLK:-
In 8086 clock is provided to microprocessor by 8284 clock generator.
8086 has a 33% duty cycle so to provide 6MHZ clock we will need to connect 18MHZ external clock
frequency.
RESET:-
In 8086 the microprocessor is reset or formatted through reset pin.
8086 is reset by connecting an external 8284 clock generator.
When microprocessor is reset, it clears the flag register, the instruction queue, registers such as DS,ES,SS
and IP and sets the bits of CS register.
Therefore the reset vector address of 8086 is FFFFOH (i.e. after microprocessor is reset CS=FFFFH and
IP= 0000H therefore Physical or reset address = CS*10H+offset address i.e.
FFFFH*10H+0000H=FFFFOH).
READY:-
This pin is used to synchronize the microprocessor with the slower peripheral devices.
Devices inform the microprocessor whether they are ready or not through this pin.
The microprocessor checks this pin during T3 state of machine cycle and if suppose a device is not readyit
sends 0 on this pin thereby indicating to microprocessor that it is not ready.
Then the microprocessors insert wait states between T3 and T4 states and will come out of the
wait state only when the device is ready for further computation I.e. when it sees 1 on the
ready pin.
TEST:-
This pin is dedicated or reserved for 8087 co-processor.
The microprocessor checks this pin only when it encounters wait instruction.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-10
microprocessor_ CHAPTER 1 :-8086
If the 8087 co-processor is busy it makes this pin high indicating to microprocessor that it is that busy.
Then microprocessor enters the wait state and come out of the wait state only after this pin is made low
by the 8087 co-processor i.e. when 8087 is free or ready for further computations.
MN/MX:-
This pin is a multiplexed pin and it is used to indicate the operating mode in which the
microprocessor is operating or working in (i.e. minimum mode or maximum mode).
If this pin is high then the microprocessor is operating in minimum mode.
If this pin is low then the microprocessor is operating in maximum mode.
NMI:-
NMI is a non-maskable, edge triggered, high priority interrupt pin.
On receiving an interrupt on NMI line, the microprocessor executes INT2 i.e. control is shifted
to location 2*4=00008H in the IVT, to get the value of CS and IP register to locate the ISR and
service or execute it.
INTR:-
This is a maskable, level triggered, low priority interrupt pin.
On receiving an interrupt on INTR line, the microprocessor issues 2 INTA Pulses.
On the first INTA Pulse, PIC calculates vector number N and on the second INTA Pulse, PIC
sends the vector number N to the microprocessor through the data bus.
Now the microprocessor will multiply N*4 and go to the IVT to obtain the ISR address (I.e. CS & IP).
RD:-
When this pin is low it indicates the microprocessor is performing read operation either from memory
or I0.
AD15-AD0:-
In 8086 there is a multiplexed address and data bus.
When ALE pin is high it indicates that the multiplexed bus contains address in it and when the ALE pin
is low it indicates that the multiplexed bus contains data in it.
A16/S3-A19/S6:-
A16-A19 lines carries the address during T1 of every machine cycle and from T2 onwards status signals
S3-S6 are active.
S3 and 54 signals are used to indicate the memory segment which is currently used.
S5 gives the status of the Interrupt Enable Flag.
S6 goes low when 8086 controls the System bus.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-11
microprocessor_ CHAPTER 1 :-8086
BHE/S7:-
It carries BHE during the T1 machine cycle.
BHE line is used to enable the higher bank.
From T2 machine cycle onwards it carries S7 signal which is reserved for further development.
HLDA....RQ1/GT1:-
In minimum mode this line carriers HLDA signal.
This signal is issued by the microprocessor in response to DMAC'S HOLD signal i.e. when the
microprocessor is about to releases the System bus it acknowledges the Dmac with the help of this signal.
In maximum mode this line carriers RQ1/GT1.
WR....LOCK:-
In minimum mode this line carriers WR Signal.
When WR signal is low it indicates that the microprocessor is performing a write operation.
In maximum mode this line functions as LOCK output line.
When this signal is low the external bus master cannot take the control of the System bus.
This signal is activated when the microprocessor executes an instruction with Lock prefix.
DENSO:-
In minimum mode this line carriers DEN signal. When this signal is low the data trans-receivers are
enabled. In maximum mode this line carriers SO.
DT/RS1:-
In minimum mode this line carriers DT/R signal.
When this signal is high the data is being transmitted and when this is low the data is being received.
In maximum mode this line carriers S1 signal.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-12
microprocessor_ CHAPTER 1 :-8086
M/10 ...S2:-
In minimum mode this line carriers M/10 signal.
When this signal is high it indicates a memory operation is being performed and when this signal is low
it indicates an IO operation is being performed. Perto
In maximum mode this line carriers S2 signal.
ALE... QSO:-
In minimum mode this line carriers ALE signal.
When ALE signal is high then it is concluded that the multiplexed bus carriers the address in it and when
ALE signal is low then it is concluded that the multiplexed bus carriers data in it. In maximum mode this
line carriers QSO signal.
INTA... QS1:-
In minimum mode this line carriers INTA signal.
On first pulse of INTA signal, PIC calculates the vector number N.
On second pulse of INTA signal, PIC sends the vector number N to the microprocessor through the data
bus.
In maximum mode this line carriers QS1 signal.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-13
microprocessor_ CHAPTER 1 :-8086
Interrupts in 8086:-
• Interrupt can be described as a special condition that arises during the execution of the program
• There are two types of interrupts and they are maskable interrupts and non-maskable interrupts.
• In 8086 there are total 256 interrupts.
• In 8086 interrupts can be generated in three ways and they are as follows:-
2. Software Interrupts:-
In this type an interrupt is invoked by writing a software instruction INT n where
"n" can be any value from 0 to 255.
Eg. INT 03H is a software interrupt for breakpoint.
3. Hardware Interrupts:-
In this type, the interrupts occurs as a signal on the of the microprocessor.
In 8086 there two hardware pins and they are NMI and INTR.
• The microprocessor services an interrupt by executing a subroutine called as ISR (Interrupt Service
Routine).
• The address of the ISR is stored in a table called as IVT (Interrupt Vector Table)
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-14
microprocessor_ CHAPTER 1 :-8086
Interrupt Vector Table can be classified mainly in to three parts and they are as follows:-
1) Dedicated Interrupts:-
In 8086, Dedicated Interrupts are further classified in to five and they are as follows:-
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-15
microprocessor_ CHAPTER 1 :-8086
inefficient.
Its ISR displays the contents of all the registers
Its ISR address is stored at a location 3*4=0000CH in the IVT
2) Reserved Interrupts:-
Interrupts INT 5 to INT 31 are reserved in 8086 for the further development and these
interrupts are not available to the user.
In this type any of the two base registers BP,BX or any of the two index registers SI,DI to provide
the offset address for the data byte.
BX indicates Data Segment and BP indicates stack segment
Eg: 1)MOV DL, [BX].
2)MOV [BP], DL.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-17
microprocessor_ CHAPTER 1 :-8086
1. In 8086, the address bus is multiplexed with the data bus and the status signals.
2. When ALE is high it indicates the multiplexed bus contains the address.
3. 8282 is used to latch the address from the multiplexed bus.
4. Therefore ALE signal is connected to the STB(strobe) of 8282.
5. When STB signal of 8282 is high, the input is latched and transferred to the output. Hence address is
latched.
6. When STB signal of 8282 is low, the input is discarded so the data is not latched and the previously
latched address remains at the output.
7. The size of an address bus in 8086 is 20 bits and BHE signal is latched, so in all 21 bits are latched
and 8282 is a 8 bit octal latch so 3 latches are required.
8286-8 bit Data Trans-receiver:-
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-18
microprocessor_ CHAPTER 1 :-8086
8284-Clock Generator:-
BLOCK DIAGRAM:-
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-19
microprocessor_ CHAPTER 1 :-8086
1) When 8086 is operating in minimum mode it indicates that there is only one processor (8086) in
the system i.e. it is an uniprocessor system.
2) When MN/MX=1, then 8086 operates in minimum mode.
3) In minimum mode, 8284 clock generator is to the microprocessor to provide CLK, RESET and
READY Signals.
4) In minimum mode, 8282 8-bit latch is connected to the microprocessor to latch the address from the
multiplexed bus,
5) In 8086, the size of address bus is 20-bit therefore three such 8-bit latches are required.
6) The ALE of 8086 is connected to the STB of 8282.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-20
microprocessor_ CHAPTER 1 :-8086
7) In minimum mode, the microprocessor either transmits or receives data through 8-bit trans-receiver.
8) In 8086, the size of data bus is 16-bit therefore such two trans-receivers are required.
9) DT/R pin of 8086 is connected to T pin of 8286 and DEN pin of 8086 is connected to OE of 8286.
10) M/10, RD, WR signals are decoded using 3:8 decoder like IC 74138.
11) In minimum mode, HOLD and HLDA signals are used to perform direct memory access.
12) when microprocessor is interrupted on the INTR line, it issues INTA signal.
TIMING DIAGRAMS:-
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-21
microprocessor_ CHAPTER 1 :-8086
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-22
microprocessor_ CHAPTER 2 Instruction set of 8086
2. PUSH Src
Push the source (word) into the stack and decrement the stack pointer by two
Src Register, Memory location
PUSH DS ;DS←SS[SP,SP+1]
; SP←-SP-2
3. POP Destination
POP a word from stack into given destination and increment stack pointer by 2.
Destination must be word(16 bit)
Destination Register (except CS), Memory location
Eg POP CX; CH← SS[SP],CL←SS:[SP+1]
; SP-←SP+2
4. PUSHF
Push the value into flag register and decrement stack pointer by 2
Eg PUSHF ;SS[SP-1]←Flag, SS[SP-2] ←Flag, SP SP-2
5. POPF
POP a word from the stack into the Flag register
Eg POPF Flag SS: [SP], Flag, SS: [SP+1] , SP SP +2
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-1
microprocessor_ CHAPTER 2 Instruction set of 8086
[Link]
Move Into AL, the contents of the formed by the sum of BX and AL. memory location in Data Segment,
whose effective address
EG: XLAT ALDS:[BX+AL];
i.e if DS 1000H; BX =0200H; AL = 03H
10000 .... DS 16;
+0200 ….BX
+ 03 .....AL
= 10203H AL+[10203H);
8) LAHF
Loads AH with lower byte of the Flag Register.
9) SAHF
Stores the content of AN into the lower byte of the Flag Register.
Eg: IN AL, 8OH ;AL← [80H]/o as I/O Port 80H in an 8-bit port
IN AX, 8OH ; AX [80H]vo as I/O Port 80H in an 16-bit port
IN AL, DX ; AL← [DX]1/0 as I/O Port pointed by DX in an 8 bit port
IN AX, DX ; AX← [DX]1/o as I/O Port pointed by DX in an 16 bit port
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-2
microprocessor_ CHAPTER 2 Instruction set of 8086
Arithmetic Instructions :-
1) ADD/ADC destination, source
Adds the source to the destination and stores the result back in the destination.
Source: Register, Memory Location, Immediate Number
Destination: Register
Both, source and destination have to be of the same size.
ADC also adds the carry into the result.
Eg: ADD AL, 25H ; AL ←AL + 25H
ADD BL,.CL ; BL ←BL + CL;
ADC BX, CX ; BX ←BX + CX + Carry Flag
3) INC destination
IN AL, DX ; AL← [DX]/o as I/O Port pointed by DX in an 8 bit port
IN AX, DX ¡AX← [DX]1/o as I/O Port pointed by DX in an 16 bit port
Arithmetic Instructions :-
3) INC destination
Adds "1" to the specified destination. Destination: Register, Memory Location
Note: Carry Flag is NOT affected.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-3
microprocessor_ CHAPTER 2 Instruction set of 8086
4) DEC destination
It is similar to INC. Here also Carry Flag is NOT affected
9) NEG destination
This instruction form the 2,s complement of the destination ,and stores it back in the destination .
Destination: Register, memory location
ALL condition flags are updated.
Eg: Assume AL= 0011 0101 35 H then NEG AL AL← 1100 1011 CBH. i.e. AL← 2's Complement
(AL)
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-4
microprocessor_ CHAPTER 2 Instruction set of 8086
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-5
microprocessor_ CHAPTER 2 Instruction set of 8086
1) NOT destination This instruction forms the I's complement of the destination, and stores it back in the
destination. Destination: Register, Memory Location. No Flags affected. Eg: Assume AL=0011 0101
NOT AL
; AL ←1100 1010 ... i.e. AL = I's Complement (AL)
3) OR destination, source
This instruction logically Ors the source with the destination and stores the result in the destination. Source
and destination have to be of the same size. Source: Register, Memory. Location, Immediate Value.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-6
microprocessor_ CHAPTER 2 Instruction set of 8086
Shift Instructions
1) SAL/SHL destination, count
LEFT-Shifts the bits of destination. MSB shifted into the CARRY. LSB gets a.0
Bits are shifted 'count' number of times.
If count1, it is directly specified in the instruction.
If count > 1, it has to be given using CL Register.
Destination: Register, Memory Location.
for this Eg: SAL BL, 1; Left-Shift BL bits, once. Assume:before Operation: BL = 0011 0011 and
CF=1.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-7
microprocessor_ CHAPTER 2 Instruction set of 8086
Program Execution and transfer Instructions These instructions cause a branch in the program sequence
There are 2 main types of branching:
i. Near branch ii. Far Branch,
This is an Intra-Segment Branch i.e. the branch is to a new location within the current segment
i. Near Branch only.
Thus, only the value of IP needs to be changed. If the Near Branch is in the range of -128 to 127, then it
is called as a Short Branch.
ii. Far Branch
This is an Inter-Segment Branch i.e. the branch is to a new location in a different segment. Thus, the
values of CS and IP need to be changed.
JMP (Unconditional Jump) INTRA-Segment (NEAR) JUMP The Jump address is specified in two ways:
1) INTRA-Segment Direct Jump The new Branch location is specified directly in the instruction. The new
address is calculated by adding the 8 or16-bit displacement to the IP. The CS does not change. A +ve
displacement means that the Jump is ahead (forward) in the program. A-ve displacement means that the
Jump is behind (backward) in the program. It is also called as Relative Jump. Eg: JMP Prey; IP offset
address of "Prev". JMP Next; IP ← offset
address of "Next".
2) INTRA-Segment Indirect Jump The New Branch address is specified indirectly through a register or a
memory location (in DS only). The value in the IP is replaced with the new value. The CS does not change.
4) INTER-Segment Indirect Jump & The new Branch location is specified indirectly through a register or
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-8
microprocessor_ CHAPTER 2 Instruction set of 8086
a location. memory Both CS and IP get new values, as this is an inter segment jump.
Eg:JMP DWORD PTR [BX]; IP (DS[BX], DS:[BX+1])
;CS (DS[BX+2], DS[BX+3]}
Eg: CALL subAdd SS[SP-1], SS[SP-2]) ←IP, SP (SP-2, IP← new Offset Address
of subAdd
INTER-Segment (FAR) CALL
The new subroutine called is in another segment (hence inter-segment). Here CS and IP both get new
values. The CALL address can be specified directly OR through Registers or Memory Location The
following sequence is executed for a Far CALL: [Link] CS into the Stack. ii. Decrement SP by 2. iii.
PUSH IP into the Stack. iv. Decrement SP by 2. v. Load CS with new
segment address. vi. Load IP with new offset address. vii, Control transferred to a subroutine
in the new segment. Eg: CALL subAdd; (SS:[SP-1J, SS:(SP-23) F CS, SP F SP-2, (SS:[SP-1], SSISP-
2D E-CS, SP F SP subAdd. -2,; CS (-New Segment Address of subAdd, IP F New Offset Address of
There is NO PROVISION for Conditional CALL.
RET Return instruction RET instruction causes the control to return to the main program from the
subroutine.
4) LOOP Label
jump to specified label if CX not equal to 0; and decrement CX
Eg:
MOV CX, 40H
BACK: MOV AL, BL
ADD AL, BL
MOV BL, AL
LOOP BACK ; Do CX CX-1.
Go to BACK if CX not equal to 0.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-9
microprocessor_ CHAPTER 2 Instruction set of 8086
Eg:
MOV CX, 40H
BACK: MOV AL, BL
ADD AL, BL
MOV BL,AL
LOOPZ BACK : Do CX f-CX-1.
;Go to BACK if Do not equal to O and ZF =1
Type 6) Processor Control Machine Control Instructions (these are instructions that directly operate on
Flag Reg)
For Carry Flag
1) STC
This instruction sets the Carry Flag. No Other Flags are affected.
2) CLC
This instruction clears the Carry Flag. No Other Flags are affected.
3) CMC
This instruction Complements the Carry Flag. No Other Flags are affected.
For Direction Flag
4) STD
This instruction sets the Direction Flag. No Other Flags are affected.
5) CLD
This instruction clears the Direction Flag. No Other Flags are affected.
For Interrupt Enable Flag
6) STI
This instruction sets the Interrupt Enable Flag. No Other Flags are affected.
7) CLI
This instruction clears the Interrupt Enable Flag. No Other Flags are affected.
7) External Hardware Synchronization Instructions.
1) ESC
This is an 8086 instruction-prefix used to indicate that the current instruction is for the 8087 NDP. We
write a homogeneous program for the two processors 8086 and 8087. Instructions are fetched by 8086 In
to its queue, 8087 duplicates the instruction queue of 8086 and monitors this queue. When an instruction
with ESC prefix (binary code 11011) is encountered, 8087 is activated, and hence it executes the
instruction, 8086 treats the instruction as NOP. ESC has to be written before each 8087 instruction,
2) WAIT
This instruction is used to synchronize 8086 with the 8087 Co-Processor via the TEST input pin of 8086.
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-10
microprocessor_ CHAPTER 2 Instruction set of 8086
Whenever 8087 is busy it puts a "1" on its BUSY o/p line connected to the TEST i/p of
the
The WAIT instruction makes the up check the TEST pin. If the up checks the TEST pin and finds a "1"
on it, 8086 understands that 8087 is busy and so it enters wait state. Here it does no processing. It can
come out of this idle state in 2 ways:
1. TEST input is made low l.e. 8087 is no longer busy. This takes 8086 completely out of the IDLE
state.
ii. Valid Interrupt on INTR or NMI In this case 8086 exits wait state, executes the ISR for the interrupt,
and then re-enters th4 WAIT state. (This is because the address of the WAIT instruction is what was
pushed into the stack before executing the ISR.)
Thus if we write a WAIT instruction before every 8087 instruction, we can ensure that 8087 i ready for
executing its own instruction whenever it arrives. WAIT can also be written before an 8086 instruction
that requires the result of a previous 8087 operation.
3) LOCK
This is an 8086 instruction prefix. It prevents any external bus master from taking control of the system
bus during executor of the instruction, which has a LOCK prefix. It causes 8086 to activate the LOCK
signal so that no other bus master takes control of the system bus.
4) NOP
There is no operation performed while executing this instruction. 8086 requires 3 T-States for this
instruction. It is mainly used to insert time delays, and can also be used while debugging.
5) HLT
This instruction causes 8086 to stop fetching any more instructions. 8086 enters Halt state. 8086 can come
out of this halt state only if there is a valid hardware interrupt (NMI or INTR) or by reset.
8) Interrupt Control Instructions
1) INT Type
This can be a number between 0...255 This instruction causes an interrupt of the given type.
The following action takes place:
i. PUSH Flag Register onto the Stack. SP decremented by 2.
ii. IF and TF are cleared. No other flags are affected.
iii. PUSH CS onto the Stack. SP decremented by 2
iv. PUSH IP onto the Stack. SP decremented by 2. In all SP decremented by 6.
v. New value of IP taken from location type x 4.
Eg: INT 1
;IP← ([00004] and [00005]) (as1x4=00004H)
vi. New value of CS taken from location (type x4)+2
Eg: INT 1
CS← (100006] and [00007])
Execution of ISR begins from the address formed by new values of CS and IP.
2) INTO (Interrupt on Overflow)
This instruction causes an interrput of type 4. Only it overflow flag (OF) is set . The above
sequence is followed and the control is transferaed to the location pointed by 0001011
Eg: INTO ;If OF = 1 then execute INT 4 please note this is INTO ( 0 for Overflow ) and NOT INT
0 (i.e. Type 0==> Zero Divide Interrupt).
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-12
microprocessor_ CHAPTER 2 Instruction set of 8086
5) SCAS: SCASB/SCASW (Scan String) It is used to compare the contents of AL (or AX) with a byte (or
word) in the extra segment. The offset of the byte (or word) in extra segment is in DI. DI is incremented
/ decremented depending upon the direction flag (DF). Comparison is done by subtracting a byte (or word)
from extra segment from AL (or AX).
The Flag bits are affected, but the result is not stored anywhere.
Eg: SCASB; Compare AL with ES:[DI] ... byte operation
DI ←DI ± 1... depending upon OF
SCASW; Compare (AX) with (ES:[DI], ES: [DI+1]} DI ←DI ± 1... depending on DF
REP (Repeat prefix used for string instructions)
This is instruction prefix, which can be used in string instructions.
It used with string instructions only. I
It causes the instruction to be repeated CX number of times.
After each execution, the St and DI registers are incremented/decremented based on the DF (Direction
Flag) in the Flag register and CX is decremented. i.e. DF = 1; SI, DI decrements. Thus, it is important that
before we use the REP instruction prefix the following steps must be came out: CX must be initialized to
the Count value. If auto decrementing is required, DF must be set using STD instruction else cleared using
CLD instruction.
- EG: MOV CX, 0023H
CLD
REP MOVSB
The above section of a program will cause the following string operation ES: [DI] ← DS:[SI], SI←
SI+1, DI ←DI + 1, CX CX-1 to be executed 23H times (as CX = 23H) in auto incrementing mode (as DF
is cleared).
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-13
microprocessor_ CHAPTER 2 Instruction set of 8086
This document is property of RKDEMY and cannot be used, disclosed or duplicated without the prior written consent of RKDEMY pg. 1-14
MICROPROCESSOR CHAPTER : 3 8259 PIC
ARCHITECTURE OF 8259:-
v. Control Logic :-
Control Logic unit consists of INT and INTA lines.
INT line of 8259 is used to interrupt the microprocessor on the INTR line of the
Microprocessor.
The microprocessor sends the response of the interrupt request made by 8259 on the INTA
line of the 8259.
It is also used to control the remaining blocks of 8259.
2. SP/EN:-
In Buffered mode, EN line is used to enable the buffer.
In remaining mode, SP line is available and SP line for master =1 and for slave SP line =0.
1. The bits are set in the IRR for those IR lines on which the interrupts occur.
2. The priority resolver checks IRR, InSR and IMR and determines the interrupt of highest priority and
interrupts the microprocessor on the INTR line.
MICROPROCESSOR CHAPTER : 3 8259 PIC
3. On the receiving the interrupt on the INTR line, the microprocessor finishes the current
instruction and acknowledges the interrupt by sending first pulse of INTA on the INTA pin of
the 8259.
4. On receiving the first INTA signal from the microprocessor, 8259 sets the corresponding bit
in the InSR and the bit in the IRR is reset and 8259 now prepares to send the vector number
N to the microprocessor.
5. Now the microprocessor sends the second INTA pulse on the INTA pin of the 8259.
6. On receiving the second INTA pulse 8259 sends the Vector Number one byte to the
microprocessor
7. Now the microprocessor multiplies N*4, to get the values of CS and IP from the IVT.
8. The microprocessor pushes the contents of flag register, CS, IP In to the stack, clears IF and
TF and transfers program to the address of the ISR and the ISR thus begins.
MICROPROCESSOR CHAPTER : 3 8259 PIC
In cascaded configuration there are more than one 8259's connected to the microprocessor.
A cascaded configuration increases the number of interrupts handled by the system.
A cascaded configuration increases the number of interrupts handled by the system.
In cascaded configuration, the maximum number interrupts handled by the sated are 64. In cascaded
there is 1 master 8259 an interrupts and master 8259's SP/EN is connected to vcc(i.e. SP/EN=+5v) and
slave 821398 8259's and master De SP/EN=0). Each slave's INT pin is connected to the
IR lines connected to the INTR line of the microprocessor.
It is necessary or compulsory to initialize each 8259's (master as well as slaves) individually with ICWS.
First the INTR signal of the microprocessor is enabled using the STI instruction.
And in cascaded configuration, the master addresses the individual slaves through the CAS2, CAS1,
CASo lines connected from the master to each of the slaves.
When an interrupt occurs on the IR lines of slaves, the following events takes place
1. The slave 8259 will resolve the priority of the interrupts and will send the interrupt of highest priority
priority to the master 8259 on the IR line.
2. Now, the master 8259 will resolve the priorities among it slaves and will send the interrupt of highest
3. On receiving the interrupt request, the microprocessor will finish the execution of its current
instruction and will send the first INTA pulse to the 8259 on the INTA pin.
4. On receiving the first INTA pulse, the master 8259 will send a 3-bit slave identification
number on its CAS lines and it will also set the corresponding bit in its InSR and the
slave 8259 will identify its number on the CAS lines and will set the corresponding bit bit in its
InSR and will also start calculating or preparing the vector number N.
5. On receiving the second pulse of INTA signal, the slave 8259 will place the vector number N
on the data bus.
6. Now the microprocessor will push the flag register on the stack along with CS and IP registers
and then it will perform N*4 and fetch the ISR address from the IVT and now now the
microprocessor will load the ISR address in to CS and IP registers and thus then the ISR
begins.
MICROPROCESSOR CHAPTER : 3 8259 PIC
MICROPROCESSOR CHAPTER : 4 8255 PPI
Architecture of 8255:-
2) Read/Write Logic :-
MICROPROCESSOR CHAPTER : 4 8255 PPI
This unit is used to accept address and control signals from the microprocessor.
A_{1} and A_{0}lines of 8255 are connected with A_{2} and A_{1} of the microprocessor
and A_{1} and A_{0} lines of 8255 are used to select ports and control word register in
3) Group A Control :-
The architecture of 8255 is divided in to two groups namely Group A and Group B.
Group A consists of Port A and Port Cupper i.e. PC7-PC4- It accepts control signals from the
control word and forwards them to the respective ports.
4) Group B Control :-
The architecture of 8255 is divided in to two groups namely Group A and Group B.
Group B consists of Port B and Port Clower i.e. PC3-PC0.
It accepts control signals from the control word and forwards them to the respective ports.
follows:-
1) The peripheral devices places the data on the port bus and informs the 8255 by making STB low.
2) The input port accepts the data and makes IBF high, indicating the peripheral device that its port is
full, so that the peripheral devices should not send more data and should wait until the port is empty
thereby preventing loss of data.
3) And 8255 interrupts the microprocessor through the INTR line provided that the INTE flip-flop is
Set.
4) On receiving the interrupt, the microprocessor will issue the RD signal and will read the data and
in the above way the data byte is transferred to the microprocessor.
5) After the data byte is transferred I to the microprocessor, 8255 makes the IBF low thereby
indicating the peripheral device that it can send more data in the above sequence.
1) The output port is empty that is indicated by a high on the INTR line, then the
microprocessor writes data on the output port by giving the WR signal.
2) As soon as the WR operation is complete, the 8255 makes the INTR low, indicating the
microprocessor should wait and this prevents the microprocessor from sending more more data
to 8255 thereby preventing the loss of data.
3) Now, 8255 also makes the OBF low to indicate the peripheral device that the data is available on
the data bus and then the peripheral device performs the read operation (i.e. accepts the data from
the data bus) and acknowledges 8255 by making ACK low
4) In this way the microprocessor transfers the byte of data to the peripheral device through 8255.
5) Now, OBF and ACK lines go high.
6) The INTR line also goes high and thereby indicating the microprocessor that an another byte
can be sent i.e. the output port is empty.
This process is repeated for further bytes.
MICROPROCESSOR CHAPTER : 4 8255 PPI
Chapter-5. 8253PIT
Architecture of 8253:-
Read Operations :-
This buffer is used to interface the internal bus of 8253 with the external bus
(i.e. with the data bus of the microprocessor).
MICROPROCESSOR CHAPTER : 5 8253 PIT
following manner:
Read Operations :-
There are 2 ways in which the microprocessor can read the count and they are as follows:-
Ordinary Read :-
In this method, the next count value is read and the current counting process is stopped by controlling
the gate input of a selected counter.
Read on Fly :
In this method, the microprocessor reads the next count value without stoping the current counting
process and this method is termed as Read on Fly.
MICROPROCESSOR CHAPTER : 5 8253 PIT
4) 3 Independent Counters :-
In 8253, there are 3 16-bit down counters.
Each counter can operate in one of the available six modes.
Each counter can have a BCD or Binary count depending on the type of count.
Each counter mainly has 3 signals and they are viz... CLK , GATE and OUT.
The input clock is applied on the CLK.
Counting is controlled through the GATE input.
The Out pin is used to trigger the microprocessor.
2) Mode1-Monostable Multivibrator:-
In this mode, the out pin is initially high and then the count value is loaded and to enable the
counting process a rising edge is applied on the gate input The out pin goes low as soon as
counting process starts and remains low during the counting process but on terminal count the out
pin goes high and remains high.
Effect of GATE:- Low- No Effect, High-Starts Counting, can also re-trigger it.
3) Mode2-Rate Generator:-
In this mode, the out pin is initially high and then the count value is loaded and to enable the counting
process the gate pin is made high.
During the counting process the out pin remains high but it goes low for one clock cycle just before
the terminal count and the initial count value is reloaded and the above process repeats.
Therefore this mode produces a continuous pulse.
Effect of GATE:-
Low- Disables Counting, High-Enables (Restarts) Counting.
1. DREQ3-DREQO(Data request)
These input pins are used by the I/O device to request the DMAC for DMA Transfer.
These pins can be active high/active low through program.
By default they are active high.
There are 4 DREQ pins as there are 4 channels.
At a time only one channel can perform DMA transfer.
Thus, for multiple requests, priorities are fixed.
DREQO has the highest priority while DREQ3 has the lowest priority.
2. DACK3-DACKO(Data Acknowledge)
These input pins are used by the DMAC to inform the I/O device that it has acquired the
System.
bus, and hence the DMA transfer can begin.
These pins can be made active high/active low through program.
By default they are active low.
There are 4 DACK pins as there are 4 channels.
MICROPROCESSOR CHAPTER : 6 8237 DMAC
3. HRO(Hold Request)
This output pin is used by the DMAC to request microprocessor to release the system bus.
It is connected to HOLD pin of microprocessor.
[Link](Hold Acknowledge)
This input pin is used by the microprocessor to inform the DMAC that it as released to system bus.
It is connected to the HLDA pin of microprocessor.
5.(Address Enable)
This is an output pin from the DMAC.
this pin is high, it disconnects the microprocessor from the system bus.
It is also used to enable the external latch.
6. ADSTB(Address Strobe)
It is an output signal.
It is used to strobe the higher order address byte into the latch.
7.DB7-DB0(Data Bus)
These are 8 bi-directional data lines used to connect the the internal data bus of 8237 with th
external data bus.
In idle cycle microprocessor writes or reads from 8237 using this bus. carries the 8 higher order bits
of the 16 bit address. In active cycle tis bus
During memory to memory transfer this us carries the data byte to be transferred
8.A7-A4(Address bits)
These are 4 output address lines.
In active cycle these lines carry A7-A4 bits of the address at which the transfer is to be done.
As this address is generated by the 8237 these are output lines.
9.A3-A0(Address bits)
These are 4 bi-directional address lines.
In idle cycle microprocessor sends the address A3-AO, to select one of its registers.
Since microprocessor sends the address to 8237 these are input lines.
In active cycle these lines carry A7-A4 bits of the address at which the transfer is to be done.
As this address is generated by the 8237 these are output lines.
[Link], IOW
These are bi-directional control lines.
During idle state the microprocessor issues these signals to read from or write into the 8237 During
active state the DMAC issues these signals to read from or write into an I/O device.
[Link]
This is a bi-directional signal indicating the end of DMA process
MICROPROCESSOR CHAPTER : 6 8237 DMAC
During active cycle after each byte is transferred through DMA the count register decrements
by 1.
When the terminal count is reached it means that all the require bytes are transferred.
At this point the DMAC issues this signal and the DMA operation is terminated.
Hence it is an output signal..
During the course of the transfer the DMA operation can be explicitly terminated by giving this signal
externally to the DMAC.
Hence it is also as input signal.
13. CLK
This is a clock input signal for the DMAC It is usually connected to the system clock,
14. RESET
This is reset input signal for DMAC
This signal clears the internal registers of the DMAC and causes it to enter Idle state.
15. READY
This is input signal to the DMAC It is used to synchronize the DMAC with slower peripherals If a
peripheral is slow it put a low on this line causing the DMAC to wait. Only after the DMAC finds a
high on pin it executes the DMA operation.
Architecture of 8237
During idle cycle microprocessor writes the starting address of the data transfer into the BAR.
Thereafter the contents of BAR do not change throughout the transfer.
[Link] Register
It is a 4-bit register having individual bits per channel. It is used to store the DMA request of the
peripheral device. The request bits can be set/reset as follows:
6. Temporary register
It is an 8 bit register.
It is used to store data temporarily during memory to memory transfer only.
7. Mask Register
It is a 4 bit register having individual bits per channel.
This register holds the masking information about the channels.
By changing these bits the channels can be masked/unmasked in the following two ways:
MICROPROCESSOR CHAPTER : 6 8237 DMAC
8. Command register
It is a 8 bit register
It is used to store the command word.
The microprocessor writes the command word.
MICROPROCESSOR CHAPTER : 6 8237 DMAC
9. Mode Register
It is a 8 bit register.
Each channel has one mode register It is used to program the operational mode of that channel.
MICROPROCESSOR CHAPTER : 6 8237 DMAC
[Link] Register
It is a 8 bit register.
It stores the status word of the 8237.
The microprocessor can read the status register.
MICROPROCESSOR CHAPTER : 7 8036
Chapter-7. 8036
Features of 8036:-
1) In 80386, the size of address bus is 32 bits, therefore the maximum main memory can be
accessed is 232 =4GB.
2) In 80386, the size of the data bus is 32 bits and the size of ALU is also 32 bits, therefore
80386 microprocessor is known as 32 bit microprocessor and since the size of data bus is 32
bits the main memory is divided in to four banks, each bank's maximum size can be 1GB,
therefore A2.A31 address lines are used to access these banks and Ag and A₁ are used to
produces 4 bank signals viz... BE3 to BEO.
3) 80386 supports address pipelining.
4) 80386 supports virtual memory and the total virtual memory that can be accessed is
246=64TB.
5) 80386 supports protection mechanism, in protected model 4 privilege levels are used.
6) 80386 supports multitasking to give higher System performance.
7) 80386 has a 16 bit I/O address, therefore it can access total 216=65536 ports.
Now, DMAC is the bus master and after performing the bus operations, it will return back the
Control of the system bus to the microprocessor by making HOLD=0.
ERROR:-
This pin is used by the co-processor 80387.
Whenever 80387 will encounter any errors it will make ERROR =0, thereby informing the
microprocessor about these errors.
BUSY :-
This pin is used by the co-processor 80387.
Whenever the co-processor is busy, it makes BUSY =0.
Whenever the microprocessor encounters the WAIT instruction, it will check the BUSY pin and if the
BUSY =0, indicating the co-processor is busy and will enter wait states until BUSY =1.
And if the BUSY =1, the microprocessor will or will continue.
Address Bus:-
80386 has a 32 bit address bus.
And A2-A31 address lines are used to access the main memory and address lines Ao-A₁ are used
to produce the bank signals.
MICROPROCESSOR CHAPTER : 7 8036
Data Bus:-
80386 has a 32 bit data bus.
BS16:-
80386 can operate with 16 bit data bus also.
So this makes the process easier and cheaper to upgrade from 8086 to 80386.
So if BS16 =0, then the 16-bit data bus is available for use.
And if BS16=1, then the 32-bit data bus is available for use.
M\10,D\C.W\R:-
These signals are used to perform control operations in the following manner:-
LOCK :-
Whenever there is a LOCK prefix written in the instruction, it indicates the
processor that it should not release the control of system bus just after the machine cycle instead it
should release the control of the system bus after the execution of the current instruction is completed.
So by making LOCK =0, it will inform the peripheral devices that it will not release the control of the
system until the execution of the current instruction is completed.
ADS:-
This signal is made low, when an address is placed on the address bus by the
microprocessor.
In a non-pipelined cycle, the ADS goes low during the T1 T-state of a cycle. machine
In a pipelined cycle the ADS goes low during T2 T-state cycle. of the previous machine
It is used to signal the external devices that the microprocessor has placed a new address on the
address bus.
NA:-
This signal is used to inform the microprocessor whether it should implement address pipelining or
not.
If NA =0, address pipelining will be implemented.
If NA =1, address pipelining will not be implemented.
MICROPROCESSOR CHAPTER : 7 8036
ARCHITECTURE OF 80386:-
2) Prefetch Unit:-
80386 supports pipelining, so this unit is used to prefetch the next instructions and store them in
to the prefetch queue.
In 80386, the maximum size of an instruction can be 15 bytes, therefore this unit fetches the next 16
bytes of the program and stores them in to the prefetch queue.
The prefetch unit gets refilled after every 4 bytes.
Whenever Execution unit and prefetch unit makes the request to the bus unit simultaneously then
higher priority will be given to the execution unit.
3) Decode Unit:-
This unit is used to decode (i.e. interpret) the instructions.
After decoding the instruction, the decoded instructions are stored in an instruction queue.
And in an instruction queue at a time, next 3 decoded instructions are stored.
4) Execution Unit:-
The main task of execution unit is to execute the instructions.
80386 has a 32-bit ALU, so this unit to perform operations on 32-bit operands in one cycle.
In 80386, the ALU has a dedicated multiplier and a divider, this makes its ALU more powerful.
MICROPROCESSOR CHAPTER : 7 8036
1) Bus Unit:-
The data transfer to and from the microprocessor takes places using the bus unit and the bus
unit is connected to external memory and I/O devices and to fetch the data and the instruction
it needs the physical address and the physical address is calculated by memory
management (MMU) and passes this physical address to the bus unit.
2) PreFetch Unit:-
80386 supports pipelining, 50 this unit is used instructions and store them in to the prefetch
queue. to prefetch the next
In 80386, the maximum size of an instruction can be 15 bytes, therefore this unit fetches the
next 16 bytes of the program and stores them in to the prefetch queue.
The prefetch unit gets refilled after every 4 bytes.
Whenever Execution unit and prefetch unit makes the request to the bus unit simultaneously
then higher priority will be given to the execution unit.
3) Decode Unit:-
This unit is used to decode (i.e. interpret) the instructions.
After decoding the instruction, the decoded instructions are stored in an instruction queue.
And in an instruction queue at a time, next 3 decoded instructions are stored.
4) Execution Unit:-
The main task of execution unit is to execute the instructions.
80386 has a 32-bit ALU, so this unit to perform operations on 32-bit operands in one cycle.
In 80386, the ALU has a dedicated multiplier and a divider, this makes its ALU more
powerful.
MICROPROCESSOR CHAPTER : 7 8036
5) Memory Unit:-
Memory Unit comprises of segment unit and page unit. This unit is used to convert the virtual
address in to 32 bit physical address.
Segmentation is compulsory and the virtual address is an input to segment unit and after
performing segmentation this virtual address is converted in to 32-bit linear address and
paging is optional if paging is not performed then this 32-bit linear address is treated as 32-bit
physical address. And if paging is performed then the 32-bit linear address is an input to page
unit and after performing paging the 32-bit linear address is converted in to 32-bit physical
address.
MICROPROCESSOR CHAPTER : 8 80386
Chapter-8. 80386
Flags of 80386:-
There are four new flags are added and remaining flags are same as of 8086 flags and new flags
are explained as follows:-
There are five 16-bit offset register are available and they are viz...
IP, SP, BP, SI and DI.
There are four 16-bit general purpose registers available and they are viz...
AX, BX, CX and DX.
Only the lower 12 bits of the flag register is available.
CRO and remaining control registers are not available. remaining bits of
In real mode, the size of main memory can be up to 1 MB only and address ranges from 00000H to
FFFFFH..
In real mode, the size of I\O address is 16 bits and therefore the total number of ports can be accessed
=65536.
80386 supports the protection mechanism and in protected model four privilege levels are available
where privilege level=0 is the highest and privilege level=3 is the lowest
Level0:-
Privilege level=0 is the highest privilege level and it is assigned to the kernel of the os.
Any program at privilege level=0 can access any data at any of the privilege but the data present
at this level can be accessed only by the programs present at this level and not by the programs
present at remaining privilege levels.
Level1:-
It is the 2nd most privileged level. This level is assigned to the system services. Any program present at
this level can access the any data which is present at this level or lower than this level but not the data
present at privilege level0.
Level2:-
It is the 3rd most privileged level. This level is assigned to os extensions. Any program present at this
level can access the any data which is present at this level or lower than this level but not the data present
at privilege levelo and privilege level1.
Level3:-
It is the least privileged levels. This level is assigned to the user applications and programs. The programs
present at this level can access any data from the programs present at this level and not at any other level.
MICROPROCESSOR CHAPTER : 8 80386
In 8086, there are four control registers available and they are explained as
follows:-
ET (Extension Type):-
In 80386, Extension Type is used to indicate the type of the Math Co-processor interfaced with 80386.
If ET-1, then 80387 Math Co-processor is interfaced.
If ET=0, then 80287 Math Co-processor is interfaced.
TS (Task Switched):-
80386 supports multitasking and TS bit is used to indicate whether task switch is performed or not.
If TS=1, then Task switch will be performed.
If TS=0, then Task switch will not be performed.
EM (Emulate Co-processor):-
If co-processor is not connected to the 80386 so the EM bit will always be 1.
If EM = 1 then this will indicate that the co-processor is not present in the system and microprocessor
will emulate the co-processor (i.e. will execute the instructions of the co-processor).
If EM = 0 then the microprocessor will not emulate the Co-processor.
MICROPROCESSOR CHAPTER : 8 80386
PE (Protection Enable):-
80386 enters in the protected mode by making PE bit=1 On reset, by default this bit is 0.
1) In 80386, the maximum physical memory (i.e. main memory) that can be accessed is 232 =4GB.
2) Virtual memory is the total space that can be accessed by the processor using its Registers.
3) Virtual address is made up of 16 bit segment address and a 32 bit offset address, therefore the .
virtual address is of 48 bits.
4) Here the segment register is used as a selector which selects a descriptor for the segment.
5) The size of the selector is 16 bits but two bits are used to give the privilege levels, which is used for
the protection mechanism.
6) Each selector value corresponds to a different segment, hence there can be max 2¹4 segments.
7) The total virtual memory that can be accessed 246 =64TB.
8) The total descriptors are 16k which can be stored either in LDT (Local Descriptor Table) or in GDT
MICROPROCESSOR CHAPTER : 8 80386
11 In 80385, the size of virtual address is 48 bits (1.0. and 32 bit offset address) 16 bit segment address
21 Out of 16 bits of segment address, 2 bits are used for protection mechanam and 1 bit is reserved for
Ti
31 So remaining 13 bits of segment address is used as selector to select a descriptor from LDT/GDT,
depending upon the Ti bit, if If Te, then GDT, bir Tin 1, then LDT and
4 The size of each descriptoris of & bytes
5 The descriptor is copied into an on chip segment descriptor cache.
There is a Pbit in the descriptor which is used to indicate whether the segment is present in the physical
memory or not.
Pbit then the segment is present in the physical memory and the base address in the descriptor gives the
starting address of the segment. If Pibit, then the segment is net-present is not present in the physical
memory and the base address in the descriptor does not gives the starting address of the segment.
And then the segment will be copied from virtual memory in to the physical memery and the base address
in the descriptor will be updated for the further use
21 Now, the offset address of 32 bits will be added on the base address to get the 32 bit linear address
of the desired location in the segment.
MICROPROCESSOR CHAPTER : 8 80386
Before giving the access to the desired location a series of protection checks are performed based on the
information given by the access rights
in the descriptor, such as limit not exceeded, type of segment, type of access, privilege level etc.
9) If the checks are valid, then the access to the desired location is given else a general protection fault
occurs.
10) If paging is not implemented, then the 32 bit linear address is treated as 32 bit physical address
PAGE Translation:-
MICROPROCESSOR CHAPTER : 8 80386
11 The virtual memory is divided in to equal size blocks of 4KB called pages.
2) The physical memory is also divided in to equal size blocks of 4KB called page frames.
32 31 The maximum size of physical memory can be 4GB l.e. 2" and size of each frame is 4KB i.e. 2,
therefore the physical memory can be divided in to 3M such page frames.
4) Now, there is a need to map which page is stored in which page frame in the physical memory since
any page from virtual memory can be loaded in to any
available page frame of main memory, so for the above reason there is a need of a page table.
5) Now, instead of having a single page table containing 1M entries upright, since it will make the
search process very slow, so we should have Ik page tables each containing 1k entries.
6) So this will help to make the search process little faster and each entry in the page table will be
called as PTE (Page Table entry) and each entry will be of 4 bytes and therefore size of each page
table will be of 4KB and each page table
will be stored at a 4KB aligned location. 7) Each PTE will give following information
Upper 20 bits will give the starting address of the page frame and the last 12 bits will be O as
explained earlier.
D: Dirty Bit indicates whether the page has been modified or nat If D=1, page is modified. If D=0, page
is not modified.
A: Accessed bit will indicate whether the page has been accessed
If A=1, page is accessed.
If A=0, page is not accessed.
This bit is used by page replacement algorithms
U/S: User or Supervisor.
R/W: Read or Read and write.
P: Present bit will indicate whether the pace is present in the physical memory or
not.
If P=1, the page is present in the physical memory and the address indicated by the upper 20 bits is valid.
If p=0, the page is not present resent in the by the upper 20 bits is invalid physical memory and the
address indicated (And if the page is not present in the physical memory it is termed as a page fruit or
page miss and the memory management unit will copy the desired page from the virtual memory in to
available page frame in physical memory using zags replacement algorithms).
8) Now, we also need to keep the track of which page table contains which sat entries and for that a
MICROPROCESSOR CHAPTER : 8 80386
i) Upper 10 bits are used to select the desired PDE from 1K PDE's present in the page directory.
ii) The next 10 bits are used to select the desired PTE from 1k PTE's present in the corresponding
page table.
iii) The last 12 bits are used as a offset to select a desired location from in the 4KB page.
13) In this way, the paging is implemented in 80386 and after performing we conve the 32 bit linear
address in to 32 bit physical address
MICROPROCESSOR CHAPTER : 9 sun sparc
Architecture of sunsparc:-
SPARC ARCHITECHTURE
The SuperSPARC manufactured by Texas Instruments (TI) in co-operatic. With Sun Microsystems. As
shown in Fig. the Sun SuperSPARC processor contains Integer Unit(IU), Floating Point Unit (FTU),
Memory Management Unit (MMU), Floating split cache (20KB code and 16KB data). It is a three issue
superscalar system i e it can execute upto three instructions simultaneously.
Cache coherent bus interface unit:
The Sun SuperSPARC has 36 address line :s and can hence access up to a total of 64 GB physical
memory. The number of data lines in SuperSPARC is 64; hence we have eight banks as in Pentium
processor system.
Split cache:
The Sun Supersparc has 20KB of code cache (instruction cache) with five way set associative mapping.
The data cache is 16KB which is four way set associative.
executed simultaneously
• The integer unit dynamically selects "a group" of up to three instruction in each cycle .
• This is accomplished by grouping logic which scans the next available instructions, and selects from
zero to three for execution.
• The remaining instructions from either the sequential or target instruction and selects from zero to
three for execution.
• It allows for most combinations of independent as well as dependent integer operations to be
Completed.
• Memory reference address calculation are performed using a dedicated set of register file ports and
a dedicated virtual address adder.
• The virtual address is then used by the cache and NMI to access load/store data Floating point unit
• It is capable of executing single and double precision floating point operations
• It is optimized fur double precision operations
• The FPU provides a 4-entry floating point instruction queue and a five port floating point register
file.
• One unique feature of the FPU is that dependent floating point instructions may be issued in the same
instruction group.
• The SPARC memory model defines the method of memory operations such as load and store, and
specifies how the order in which these operations are issued by a processor is related to the order in
which they are executed by memory.
• A standard memory model called as Total Store Ordering, (TSO) is defined for SPARC. The model
applies to both the uniprocessors and the shared-memory multiprocessors.
• The memory model guarantees that the stores, FLUSHes and atomic load-stores of all processor are
executed by memory serially in an order that match to the order in which the instructions were issued
by processors.
• All SPARC implementations must support TSO.
• Another model called Partial Store Ordering (PSO) built. ) allows higher-performance memory
systems to be built.
• Machines (including all early SPARC-based systems) that implement Strong Consistency (also
(also known as Strong Ordering) automatically satisfy both the TSO sad the PSO. Machines that
implement TSO also automatically satisfy PSO.
• Programs written using single-writer-multiple-readers locks will be Strong Consistency. portable
across PSO, TSO and
MICROPROCESSOR CHAPTER : 9 sun sparc
• Programs that use write-locks but read without locking will be portable across PSO, TSO and Strong
Consistency only if writes to shared data are separated by STBAR instructions. If these STBAR
instructions are omitted, then the code will be portable across TSO and Strong Consistency only. The
guidelines for other programs are as follows
1. Programs written for PSO machine will work automatically on a TSO machine or on a Strong
Consistency machine
2. Programs written for TSO machine will work automatically on a Strong Consistency machine
3. Programs written for Strong Consistency machine may not work on a TSO or PSO machines
4. Programs written for ISO machine may not work on a PSO machine.
• Multithreaded programs where all threads are restricted to run on a single processor will behave the
same on PSO and TSO machines as they would on a Strongly Consistent machine.
• Input/Output SPARC assumes that input/output registers are accessed via load/store alternate
instructions, normal load/store instructions coprocessor instructions or read/write ancillary state
register instructions i.e(RDASR and WRASR)
• In the load/store alternate instructions case, the I/O registers can be accessed by the supervisor only.
• If normal load/store instructions, coprocessor instructions or read/write Ancillary State Register
instructions are used, whether the I/O registers can be accessed besides the supervisor or not is
implementation dependent.
• The contents and addresses of I/O registers are also implementation-dependent.
Before we see these memory models in detail, we need to know some definitions according to
SPARC
1. Real Memory: Real (or main) memory is defined as those memory locations accessed which have
either of the following.
Memory is byte-addressed, with half word (16-bit accesses aligned on 2-byte boundaries, word (32-bit)
accesses aligned on 4-byte boundaries, and double word (64-bit) accesses aligned on 8-byte boundaries.
The largest data that is atomically read or written by memory hardware is a double word.
The memory references to different bytes, half words and words in a given double word boundary are
treated for ordering purposes as references to the same location. Thus the unit of ordering for memory
is a double word.
A processor initiates the memory operation via its port in what is called the issuing order. Each port
contains a Store Buffer used to hold stores, FLUSHes, and atomic load-stores operation. A switch
MICROPROCESSOR CHAPTER : 9 sun sparc
connects a single-port memory to one of the port at a time, for the duration of each memory operation
(kind of time multiplexing) The order in which this switch is thrown from One port to another is
nondeterministic and it defines the memory order of operations.
For this memory each processor consist of an idealized Processor(IP) and instruction Buffer (IBuf)
• IP executes one instruction at a time as specified by the TSP, without overlap, in what is called
program order. For each instruction the IP fetches the IBuf. IBuf may also prefetch the instructions
via memory port. Thus IBuf models the prefetch queue of instruction pipelining and/or a instruction
cache, in a processor implementation
The issuing order of data loads rind stores match to the order of the coressponding instructions in
program order. However, the issuing order of instruction loads in general does not match to the order
of the instructions fetches, defines program order.
• The FLUSH instruction synchronizes instruction fetches with data loads and stores. For e.g. when a
processor executes FLUSH A, the data corresponding to location A is removed from the IBufs of all
processors in the system some time after the execution of the FLUSH.
Total Store Ordering (TSO) Total Store Ordering guarantees that the store, FLUSH and atomic load-
store instructions of all processors appear to be executed by memory serially id a single order called the
memory order. Also, the sequence of store, FLUSH, and atomic load-store instructions in the memory
order for a given processor is identical to the sequence in which they were issued by the processor. Fig.
below shows the ordering constraints for this model graphically.
FLUSHes, and atomic load-stores issued by processor, are placed in its dedicated FIFO Store Buffer.
The order in which memory executes the operations for a given processor is the same as the order in
which the processor issued them. The order of these operations corresponds to the order in which the
switch is thrown from one port to another.
• To maintain consistency, a load by a processor first checks its Store Buffer to see if it contains a store
to the same location (atomic load-stores do not need to be checked because they block the processor). If
it does, then the load returns the value of the most recent such store from the buffer; else the load
goes directly to memory.
• Match between issuing order and memory order is provided by use of the STBAR instruction. If two
of the instructions are separated by an STBAR in the issuing order of a processor, or if they reference
the same location, then the memory order of the two instructions is the same as the issuing order.
•Fig. 16.8.4 shows the Partial Store Ordering (PSO) Memory Model
Here also Stores, FLUSHes and atomic load-stores issued by a processor are placed in its dedicated Store
Buffer, However, this buffer is not guaranteed to be FIFO as it was in TSO; it does maintain the order
of stores and atomic load-stores to the same location, but otherwise it is partitioned only by the
occurrence of STBAR instructions.
MICROPROCESSOR CHAPTER : 9 sun sparc
• Thus the order in which memory executes two stores or atomic load-stores that are separated by an
STBAR for a given processor is the same as the order in which the processor issued them.
Data format
Sun SPARC implements two types of data formats viz. Integer and Floating point data formats.
Floating Point
Besides the IEEE 754 standards of floating point representation, Sun SPARC also supports a higher
precision called as Quad-precision format. Hence Sun SPARC supports Single precision format as
shown in Fig, which is a 32-bit IEEE 754 floating point standard. Sun SPARC also supports Double
precision format as shown in Fig, which is a 64-bit IEEE 754 floating point standard. Sun SPARC also
supports Quad precision format as shown in Fig. 16.4.2 (c), which is a 128-bit Mating point format.
As shown in the figure, single precision has 8 bits for biased exponent, while double precision has 11
bit biased exponent and quad precision has 15 bits for exponent. The MSB of each of these formats is
the sign bit. The remaining bits 23 bits in case of single precision, 52 bits in case of double precision
and 112 in case precision are meant for fraction (mantissa) part.
RISC processors have less number of instruction format. There are three bask instruction formats in Sun
SPARC
1. CALL
2. Branch Instructions
3. Operate instructions (register to register)
As seen in Fig below, each format has 2 bits for the opcode. The fields marked op2 or op3 are also
opcodes (additional information of the opcode for integer instruction), while opf field (floating point
opcode field) are opcode to indicate, the, floating point operation.
In the first, format (Format 1), as shown in, the remaining 30 bits are for the displacement for the call
instructions.
The second format (Format 2, case 1) is specially meant (Or the SETHI instruction, which sets the first
22 bits of the destination registered to the 22-bit immediate data given in the instruction.
The trird format (Format 2, case 2) is meant for branching instructions. This format has four hits for
condition and 22 bits for displacement from the current value of program counter.
The "i" hit in the format. ;t, indicate"; if the data is immediate or register addressing mode: (i=0 indicates
register addressing mode; i=1 indicates immediate addressing mode.)
MICROPROCESSOR CHAPTER : 9 sun sparc
The Fields rs1 and rs2 are the source rogisters, while the field rd is destination register. The instructions
in SunSPARC are normally three operand instructions where the two source operands and the destination
operands are different. In case of the immediate addressing mode format (where i=1); there is a field
called as simm13, which is immediate 13-bit data. In the register addressing mode format (where i=0),
there is a field called as ASI (Address Space Indicator). The ASI is used to indicate the normal or
privileged memory locations. For the last format, which floating point format instruction, also two source
operands (rs1 and rs2), a destination operand (rd) and a opcode information using the bits opf.