Professional Documents
Culture Documents
8086 CH 2 Architecure
8086 CH 2 Architecure
In 1978, Intel came out with the 8086 processor. The Intel 8086 is a 16-bit
miaoprocessor, implemented in N-channci depletion load, silicon gate technology
(HMOS), and packaged it in a 40 pin dual in line package. I,n this chapter, we study
features, architecture, register organisation, bus operation and memory segmentation.
8. The 8086 is possible to perform bit byte, word and block operations in 8086. It
perfonns lhc arithmetic and logical operations on bit, byte, word and decimal
numbers including multiply and divide.
9. The Intel 8086 is designed to operate in two n1odes, nan'lely the minimum mode
and t�e maximum mode. When: QfijiY. yne. soir, CPU ,is to be lL'k.>d in a
.
microcomputer· system, the 8086 is us� ""! the ffli.n.imum mode of operation. In
thLs ·mode the CPU i,.ues the -control •iffel�tt,qutred by memory and 1/0 devices.
Jn multiprocessor (more th.an one proc:essor·in the system) systefl?.,.� Oj."ICrates in
maximum mode. ln maximum mode, control signals arc genernted wilK the hClp of
external bus controller (8288).
JO. The Intel 8086 supports multiprogramming. In multiprogramming, the code for
two or more processes is in memory at the same time and is executed in a
time•multiplt>xt..-d fashion.
I 1. An interesting feature of the 8086 is that it fetches upto six instruction bytes
(4 instruction bytes for 8088) from memory and queue stores them in ordl'r to
Spt."'L"Ci up in�lruction execution. Later we will discuss this i.f'I detail.
12. The 8086 provides powerful instruction set with the following addressing modes :
Register, immediate, direct, indirect through an index or b.ase, indirect through the
!'iwll1 uf :i base and an ind�x register, relative and implied.
.
1. It �nd� .,ddn-:--s of th._• memory or 1/0.
2. h fctcht...� in�tru,tion frvm memory.
'.l. ll n.•..h.ls data from port/memory.
-1. It \\'1tit1..� ...l,tta into port/memory.
5. It ..;.upports instruction queuing.
C,. It f'"''·1d,·-. 1hc .,Jdn.-:,.s rdc1u1tion facdty.
r ..rt
' (
,
Micropr(!C�•
� �
-...
,---------
-!::=:::::-..:..- - ---- - -�- �- ..,,,..._ __,....,..._-.i_ ..,..,_ ,,..,
d lntertac,ing
lnlelfacc
2 •3 Architecture of_ 8086 Microprocess9<
/'- - -------------------------------------------
·, I J
BU C,8u,
J'
J
' .
.
's
.,..
lnSINC6on
s..am
es 3
Queue
cs 2
ss 1
OS
IP
'' ''
'' EU
'' . A.Sus ''
''
' ''
'\' ' I
: AX AH AL ''
: 6X BH BL Arithmetic ''
: ex CH CL logic Unit/ ''
'' OX OH OL
'' ''
; I
SP
'' BP ''
''
'
SI
01 • I
I
I
I
�--------------------------------------------------------'
''
''
Fig. 2.2 6066 Internal block diagram
To implement lhese functions the BTU contains lhe instrut::tion queue, segmt�f registers
instruction pointer, address summer and bus con:rol logic,
Instruction Queue
To speed up pro1,..,.am e,cecution, the tsJU fetches six instruction bytes ahead of liml;'
from the memory. These prefetched instruction bytes are held for the execution unit in �
group of registers caUOO Queue. With the help of queue it is pos.�iblc to fetch� next·
instruction when current instruction is in exccL:tion. For example, current instructi9n jn
execution is a multiplication instruction. In �. operands for multiplication operntiom arc
within registers. Still it requires 100 dock cycles to execute multiply ins' truction. Like
multiplkation there are number of other instructions in 8086 which need quite a l:1..rge
number of dock cydes for execution. During tht; execution time the BIU fotchc-s the next
instruction or instructions from memory into the instruction queue instead of rem.,1.ining
idle. The SIU continues this process a.s long as the queue •
is not •full.
•
Due
•
to this,
I
execution
unit gets the ready instruction in the queue and instruCtiori fetch time is elimimited. Ths is
illustrated in Fig. 2.J.
The queue opera.le!'> on the principlP fini.t in firs.t out (FIFO). Sn that thP ex�ution unit
gel� the instructions for exccutjon In the order they are fetched. In c.1.-.e of JUMP and
CALL instructions, instruction already fetched in queue are of no use. Hence, in these
Microprouasors and Interfacing 2-4
BIU
OYerlaPC)Clg {
phases
eu jo,I e, I0,I o,I E3 .••..
li,,... �fo, tatieuliOn Oftwo
1-- -instruction& becauleof pipeliniog .I
Fig. 2.3 Pipelining
cases queue is dumped and newly fanned by loading instructions from new oddress
specified by JUMP or CALL instruction. Feature of fetching the. next instruction while the
current instruction is executing is called pipelining.
The length o f the queue should be such that EU should get the next ·instruction from
the qvet.1e of t_hf?, Bill imme,di.ltely lifter the E''l(e('\1tion of thP. current i_nst-n. 1ction. To s.Misfy
this, number of pre•fotched instruction :n the queue and hence the queue length depends
on the fetching speed and the execution speed. Sometime queue length mar be restricted
due to the space available o n the CPU chip.
SP
15 87 0
AH AL cs BP
BX BH BL DS SI
ss
ex CH CL es DI
DX DH DL
offset address for some partkolar addressing modes. The register AX is used as 16-bit
a=unolator whereas register AL (lowerbyte of AX) is used as 8-bit accomolator. The
register BX is also used as offset storage for generating physical addresses in case of
certain addressing modes. On the other hand, the register CX is also used as a delaolt
counter in case of string and loop instructions.
the 16-bit segment registers are provided by the bus interface unit (BIU) of the 6re6. These
lour registers are :
Address
FFFFFH
E.xtta segment
Stack segment
}64K 1 Mbyls
physical
memo,y
K
�
Oaia segment
} 64
K
Code segment
}64
OOOOOH
•
II! !Mlcrr"_...,� Interfacing 2-7 Arc ��-r.�� �t
3. ES register and DS register •re used to hold the upper 16-bits �f the starling
address ol the two memory segments whkh are used for data.
2.3.3 Pointers and Index Registers
All segment registers are l�bit wide. But it i s necessary to generate 2()...bit address
(physical address) on the address bu.,. To get 20-bit physical addn.>ss ore or more pointer
o r index registers are associated with each Sfgment register. The pointer registers IP, DP
and SP are associated with code, data and stack segments, respectively. They hold the
offset within the code, data and stack segments, respectively. The index registers DI and SI
are used us a general purpose registers as well as for offset storage in ei,se of indexed,
based indexed and relative based indexed addressing modes. The detail description o f
pointe-.rs and index regi,;;tcr is given in section 2.5.
IIIIIIIIIIIIIIIII
BIT 15 14 13 12 11 10 9 8 7 6 !• 4 3 2 1
u u u u OF OF IF TF SF ZF u AF u PF u CF
I I I out°'
U • Undefined cany Flag : Set by cany MS8
Parity Flag : Set If result has even parity
Auxil ary
i Carry Flag for BCD
Zero Flag : Set If result -a0
Sign Flag • MSB of resuft
Slogle step '"'P
lnterrupe enable
String dife<llon
Overflow
1. Can-y Flag (CF) : In case of addition this flag is set if there is a carry out of the MSB.
The carry flag al so SC.->rYt.."S as a borrow flag for subtraction. In case
of subtraction it is set when borrow is needed.
2. Parity Flag (PF) : It is set to 1 if result of byte operati0t'\ or lower byte of the word
operation contain an e,·en number of ones; otherwise it is zero.
3 . AulClllary Flag (AF):This nag is set if then: is an overflow out of bit 3 i.e., carry from
lower nibble to higher nibble (D3 bit to D, bit). This flag is used for
BCD o�rations and it is not ovailable for the programmer.
M�IOP.f'OUSs.91$ aQCl · lnlerfaclng 2-8 Architecture of SOM MIC,oproqt"9'
4 . Zero Fl1111 (ZF) : ·n,e zero flag sets if the result of operation in ALU is zero and
flag resets if the result is nonzero. The zero flag is also set if a
cer-lcti,, ceglster co,,h :ml beooane:, u,-o following an il'M.:n:,neut Ol'
decrement operation of that register.
5 . Sign Flag (SF): After the execution of arithmetic or logical operations, if the MSB
of the result is 1, the sign bit is set. Sign bit 1 Indicates the result is
negative; otherwise it is positive.
6. Overflow Flag (OF):This flag is set if result is out of range. For addition this Rag is set
when there is a carry into the MSB and no carry out of the MSB or
vice-versa. For subtraction, it ls set when the MSB needs a borrow
and the-re is no borrow from the MSB, or vice--versa.
,. Example 1 Give> tlrt contenls of tlte flag register aftrr txecution offo/l(IU}ing oddi,;on.
3. Directi on Flag (OF) ;It is used with string instructions. If OF = 0, the string is
processed from its beg;ming with the first element having the
lowest addres.,c;. Otherwilie, the string i s processed &om the high
address towards the low 1ddress.
,,
\� , ,
. ':)i�ro proeesso�s i"\II '1�orfaclng
0 ' .
2-10 Archltec-\vre of $086 Mier,;,proe•s�or
, ;I
Pl,-f Ad<lttl$5
6,\K
64K
64K
T
2FfFFH h----,--,---.1 - To,>Ofdalase.gmoril
641'<
00000H
Pl'i\ "Meal rt!GMOIY
To access a spt..">Cific memory location, from any segment we RL--ed 2Q..bit physic.ti
address. llw 8086 generates this address using the contents of se:gment register and the
offset register associated with It Le t us ..., how 8086 occe,;s code byte within the code
segment.
We know that the CS register holds the b.lSc addross of the rode "-1;ment. 11,c 8086
provides an instruction pointer (IP) which holds the 16-bit address of the next code byte
within the code segment. The value contained in the IP is referred lo as an offset. Thus
value must be offset from (added to) the s,gment b..., add«'SS in CS to produce the
required 20-bit physia,J address.
The contents of the CS register are multiplied by 1 6 . i.e. shifted by 4 position to the
left by i.J\S<.'tting 4 uro bits and then the offset i.e. the contents of fP register are added to
the shifted contents of CS to generate physical address. As shown in the Fig. 2.8, the
contents of CS register are 348AH, therefore the shifted conten� o f CS register are
348AOH. When the 8JU adds tl1C offset of 42HH in the IP to this starting address, we get
38A84H as a 20-bit physical address of memory. TI,is is illustrated in Fig. 2.8 (b).
cs 13 •• 2 I
0 A 0 - i mplleO Uf'O
-)
IP•
Physicaladclr\llS I� • " • •I•I 4 zero bits
I
t-------4 - Codt�3aA84H
IP a 4214H
CS� 3-48AH - S&ll1 ofCode &egmerrt
(a) (b)
F ig. 2.8
We have "'-"-'" that how 20-bit physical address is gen..-ated within the code segment.
In the simila r way the »bit physical .kidn..>ss is generab..--d in the olh...-r �-sm-..-'flb.
However, it is important to note that ea(h �ent n.:.quires particular St."gment register
and offset register to gene,-ate 20-bit physia,J address.
St..ck Pointer (SP) : The stack po inter (SP) register contains the 16-bil offset from the
start of the segment to the top of stack. For stack operation, physical address is produced
b y adding the contents of stack pointer register to the segmPnt ba.se addre:.s in SS . To d o
this th e contents of the stack S<.>gment register are shifted four bits left and the contents of
S P are added to the shifted result. If the contents of SP are 9F20H and SS are 4000H then
the physical address is calculated as follows. (Refer Fig, 2,9)
SS = 4000H afier shifting four bits lefl SS = 40000H
Now
ss 40000H
+ SP 9F20H
Physical address 49F2QH
I
>- --<
- - End of stack segment 4FFFFH
1-----1 - Topof�acft49F20H
_SP =9F20H
These three l&.bit registers c-an be lued as general purpose registers. However, their
main use is to hold the 16-bit offset of th• data word in one of the segments,
Base pointer : We can use the BP register instead of SP for accessing the stack using
the based addressing mode, I n this case, the 20.bit physical stack a<idress is calculated
from B P and SS, Addressing modes are dl.scussed in later section.
Sourc., Index : Source index {SI) can be used to hold the offset of a data word i n the
data segment, In this .case, the 20.bit physic.,! data address is calculated from SI and OS .
Destination Index : The E S register points to the extra segment in which data is
stored. String instr\lctions always use ES and 01 to determined the 21).bit physical address
for the destination.
4) MOV CS : [BX], AL
This instruction ropics a byte frCN:n the AL register
1000@:jH CS to a memory location. The effectjve address for the
• oo 2 o H ex memo:y location is contained in the BX register. By
Physical AddteS$ 10 02 0 H default an effective address in BX will be addoo to the
data segment (OS) to produce the physical memory
addre,s. In this instruction, the CS: in front of (BX)
Indicates ttutt we want BJU to add the effective address to the code segment (CS) to
produce lhe physical a.ddress. The CS: is ca.Jled segment overrlde prefix.