All 2
All 2
- - Me mor 1
Mi r J-
proc :-.sor Input
utpuL
microcontrollers
Microprocessor
l/0
I
Input/ Output
A U I Register
I Array
I System Bus
_ _ _ j_ _ _ ,-----~ ~----✓
Memory
Conlrol
.---R-OM~I I.---R/WM------.,
Register Arra. This area of th microprocessor con i t of vari I reg· ters identified
by I tters su ·h as B, C, , , H, and L. h s r oi t r.., are pri11 rily u e I to tore data
L mporarily durin the , e uti n fa pr gran1 and are ace ssibl lo the user through in-
struction . .
Control Unit The control unit provide the nece. ary tin1ing m d c ntrol ~ ignal l all
th perati ns in th microcomputer. ll c ntroL th fl \ f da c betwe n the mi ro-
proc . or anc.J m ·mory and p riph ral. .
SYSTEM BUS
Th system bus is a con11nunication pa h betwe n the 1nicroproc sso · and pe ·ipherals; it
i nothin but a g ·oup f wires t carry bits. ln fact , ther are s veraJ bu e in the y ten1
that wHl be is us in the ne t chapt r. All p ·ipherals and memory ha· th 1ne
bu ; how ver, th t 1icr proc sor cornn1l111·cate. ith only one periphe ·al at a ti11e. The
f 1ning i provided by th contro unit of the 1nicrop ·oc ssor.
A,, t - - - - - - - - - - - - - - - - - - - - - - -
1\i t------~
Memo1y
8085
Real
MPU World
capacity to identify different memory tocati.ons (or peri.ph r.:ils) . The 8085 MP with ilS 16
add1~ s li nes i. capable of add res.! ing 2 1n = 65,536 (generally known as 64K) tuemory oca-
DATA BUS
he data u. i. a roup of ei ht lines used for data flow (Figure 3.1).* Th se line· ar
bidir tionn l da1a It l m b th ir rion. h twten the MPO nd me, my nd pel'iph -
ra l devices. Th PU u - s the da ta bu · to p r~ rm th cond fun 1ion: 1ran. fi rrin bi -
nary in formation Step_ .
Th ci hl ti rn linec;; n ble th MPU to manipu late 8-hit darn ran in from 00 to FF
(28 = 256 number.-}. The larg sl numb ' r thm ca pp d' on th la1a bus i I l l l l 11 J
l
(255 10). The 8085 is knm: n as an 8-bil microprocessor. Mi ·r pro ·es ·ors ·uch as lh lnL I
8086, Zilo Z8000. and otorol, 68000 have 16 daLa lines; thus they m· known as 16-
bit micr p1 ·e·· 1 ·. h~ Jnt 180386/486hrw· . 1 data lin s~ Ihus1 h la.. ifi I~
2-biL microprocess r .
CONT - 01 BUS
Th conrr 1 bus js comprised of ·11arious single lines thal carry synchronization signal.s.
h J\.llPU u es ·tu h Jines top rf rm ~h third f u11cl ion: pmvirliner Ii,; ·ITT:. si nals , S1ep 3).
A151--1 - - - - - - - - - - - - - - ------
-Bit Memory Address Address us
Ao ,---------------
Memory C 1p
06 = 0 00 0110 2000
78 :e: 0 I I 1 I 000 2001
8085
3 =0011 11 10 2002
MPU D7 F2-1111 0010 2003
8 ?004
0 2005
200
0 t Bus
.I
I .. I
I , I I I
Accumulator A (8) fla~ Register
B (8) (8)
D (8) (8)
H (R) L (8)
Stack Poin11:r (SP) (16)
Address Bus
z AC p CY
ACCUMULAT O
'lh n llmulator is Ill 8-bil re 'stcr t .il ii; pa 'I of U1 arilhmeti ·/1 gi · unit {A l U). This reg-
ister is used lo tor 8-bil data and Lo p rfonn milh1netic and logical opernli ns. The result
of an OJ eration is ·t y; in th ri u1 ml or. Th "' a<.: ·umulator i. lso identified as r gist 'f .
D Z Zero: ,'h Z r I-tag is set to 1 , hen the re. ull i · zero: otht:rwise ii i.· r ~et.
0 C ·1rry: Ir an al'ithnu.:1ic opernlin n re. ults in a c:my, th C llug is ct: otherwise it is re
<; I.
D -Sign: TI1~ Sig11 llag h set if biL D7 or th t , ult= I; othcrwis it is sec.
D P - Pari t 1 : If the resu lt hH, an even number or Is. the flag is set: for nn ocld m1111bcr of I s, the
Llag i~ reset.
0 C-Auxiliary an l11 au arit llln tic p ratio11. vhen a c;m, i ge nerakd by digit f) 1 a11d
1:
pt11-sed L digi l D.1, the> C nag is set. Th i. f!.,g is used internally ~ r BCD bi11ar coded <.I ci-
mal} orera1 iou,; thc1 • is 11 Jump instruct ion a, sociated \ ith thL AalT ,
10
OL1
The low-mder address bus of rhc 8085 micropmc essor is tJmEtiplexed (tjme-shared)
with the data bus. The bu · s n ~eu o be demu ltiplexed.
The 8085 co11111101il known as the 808 ) ii-. an 8 bit general-pu q o. t.: micr proce,. OI'
capable.: J' adclr ssmg ( I< of rncmm . Tli device has fo11y pins, r quir s a +5 V single
power ~upply. and can 01 rate with a 3-MI 11 in°1 -phasv cit ·k. 'I he 8085A-2 version
, n pc1ate at th~ lllaximum frequency of 5 MHz. he 8085 is an e nhanc d v rsinn ol its
p1\:dc<.: ,~ r. the 8080A: it ins(ruction set 1s upward-compatihlc wilh thaL of the 8080A,
111 ,ming that the 085 1n-.,t1 11 ·tion · I includes all the 8080 in tI uc.:tions plus ,omc adcli
tional ones .
f,'i 0 ur 4. r sh w, Lh logic: pint 111 ul th · 8085 nucruprocessor. II the signals can be
classified int l six group : (I) addr ·ss bu . (2) data bus. (3) control and srntus si nal.s, {4)
ower supply a11cl frcq11 •nc "ignat,. (5) exkrnnlly 111itial · I signal • and (6) c.;erial I/ pons.
A DRF.SS BUS
Tile 808. ha 16 signal linec.; (pins) th;11 ar' used as the address h11s: hnwcv r. these lines
,Ir·-;pJit into two segment,: ,., As anc.l A 7 - AD 0 . Th~ {ighl ,ignal Imes. 1s- s, arc
unidirectio n, I and u:cd for the mo. t . i!!nificaur bib. called !he hi h~ord r utldr •s-;, fa
16~hil ad tJ r, ·\. h signal lin . AD 1 D11 ar used for a dual puq> '. as explajned in the
11 .. ' ( s ct ion.
D ALF Addi •ss luLch Enable: Thi. i. a positive going pul. e gen rateu ever time Lhe
8085 begins an )pcnit im1 (machine cycle ; it indicate. that lh hit~ on AD 7 - AD 0 aie
acldres.s hit. . Th i~ . i •1ml is used 11ri111arily to lal h th low-order ilddress fr m lb mul-
l i ple,, cd bus m1<l generate a s pn1. t" -;cl of ighl address Ii ne , 7- 11.
D R - cml: This is a Read control si0 nal (aclive low . This . if nal ind i ·ates that the se-
1 cl tl l/ or memory d vi ' i,;; to read and data ore a Hi lnble on lhe data bu..
WR- Write: hi .s is a Write control si nal (act iv JnwJ. This signal indicate.s tha t the
dat~ n the datu bu · are to I e wri1tc1 i11lo n s •l ·ted memory ol' [/0 I > ·:1lion.
D IO/ : ,is i: a slalll~ . ignul w,"'U lo <lifferentiat bet, een T/0 ind memory operations.
hen it is 1111::,h, il i11<li ·at s an 1/0 operat ion: wh nit LJ_ w, it indicares a memory op-
erati n, his ·ignal 1s omhined wi11l Rr> (Reau) and WR (Wi itc) 10 gc 11cratc 1/0 and
111cm r I control signals.
D •1 and S0 : The. c st.illls signal , . imilar to 10/M. ·:ui it.I 111ify various ren1tions, hul
the I re rnrdy lls~d in s mall s , Lem. , ( 11 the operations and thcii- a-.;<.;ocialeu slulus
. i, 11ah m' listed in Table 4. I fur r ·foren .
signal c·,llec HLDA (T old Acknowledge). The functi 1 s of th se ~ignals were previously
dhcL1ssed in Sec tion 3 .. 3. he RESET is gain d cribed below, and otl ers a ·· Ii ted in
Table 4.2 I~ r l' .r ·rence .
RESET I : W hen lh "' · gnal on thi s pin goes low, the program counter · t to zero,
the bus s at t i-st. teJ, and the MPU is res t.
D S TOUT: his signal ind ' at-s thal the MP is being cset. , he signal can u d
tu reset other d v i
Data Bus
Memory
B C
2000
ALU In. rru lion D
Decoder
H L
2004
S1ack
4F 200S
Pointer
Program
Coun1 r
Con1rol
2005
Logic Addres Bus
4F
RD
Ste() l: Til1e co11trol. un i[ s nds the control sig1 al RD t enable the mer ory c hip (Figm·,
4.2). This is similar co l'ingi. ng the doorbell in our analogy of .-1 package pickup.
Step 3: The byte fro1 lh memory location is plaoed on lhe data bus.
Step 4: The byle i::; plm;ecJ in the instn1ction d,:!eoder of the microprocessor, and the
la ·k i::; carried out accorrlin ° ro th . instruction.
CLK
Low-Order
AD1 ""'•----- -----~
0511 4FH Opcode
ALE
IOtM
Stalus (OfM = 0, Su ;; I . S , - I
0 A,~
Ats
0
A 14
• I An
0 A1! High-Ord r
07 AD1
0
0
~H::? Q ,, 0 A1
L-.il. A,,
AD,,
AD, 0 - ,_Q A~
0 0 A~
051l = ~
AD.i
!AD.1
AD 1
0
1
74 1.S37J -
1- L
0
A-.
A,
Low-Orde,
Addrc~~ B 11~
AD 1
0 ___JL A,
Du AD(1 I
oc .---l A11
I
~
0
D7
I D6
0 Ds
/ l _ _ •ll· H 0 04
I Dau Ru~
D1
I Dl
I o,
l l)"
first clock period. hi. add1· s ne d · 1 he latched and u ·ed for identifying the memory
addre . lf lhe bus D.,-A O is used to identify the memory location (2OO5H), the ad-
dress will change t 204FH aft r the first Clo k peri d.
Figure 4.4 show, a schemt ti · t af u. es u latch amJ the LE signal to demultiplex
lhe bus. The bus AD7- AD0 is connected a · th ·· inpuL to U1e lat ·h 74 S373. 111e ALE sig-
nal is con11ected to th Enable (G) pin of the latch, and the Output control (OC) . ignal of
lhe latch i:- rrounded.
Figure 4.. shows lh aL the ALE go l1i.:,h during T 1• Wh •u the ALE is high, t •
la tch is transparent; th i' n nns that l he output chan 0 s according to input data. During T 1,
the oulpttl of the latch is O5H. Whe the ALE goes low, the da ta byte 05H i latch d un-
ti l the next ALE, arid 111 outpu t of the Ja tcl represen ts lhe low-order address bus r 11
flcr the latching operation.
8085
74LS32
101M i.----------,1'"--~
iffi t>----+-_,
WR
low anti generat MEMR (M mory Read) nnd M ~MW (Memor Wnle) ontrol sig
mlls. When Llle TO/M si •nal goes hi 0 h, it indicates th pcriph ·ml 1/0 opel'ation. igure
. 5 shew that ti~ .sign I__!_'.!_ complemented usin° _ili_e Hex inverter 74LS0 and
AND ·d with the RD and WR signals to gen rate lOR (TIO Read) and lOW l/O
Write) control sigllrll&.
10/M
M MR
RD
MEMW
WR
Control
Signals
IOR
iow
32H Data
Memory Addrc~,
o,s I , S., 0
fW
3. At the ri ing edge of 2 tie 8085 activates th da t.1 bus as an input bus, memory
place, the d la byt • 32H on l lP data bu s and the 8085 reads and . _re, the I yre in ti
a cumulator during TJ.
T-st 1/e i •
fined as 11 1.; ubdivision f the op ration performed in 011 -lock p riod.
Thcs su div i ioni; are int rnal slat . ynchr ni zed ~,j1h th' sy. t ·m ·I ck, a nd each
·Late i preci. el ·quaJ t one I ck p<:riod. The term . Stale anti c lock period nr · flen
used . yn n mou ·I 1•
rr
D Clo ·k ·qu nc:y f = 2 MHz
D T-state = clock period J/f} = 0.5
D Execution ti me for Ope.: cl Fet ' : (4 • ) x 05 = ~ls
D x ution time !'or Memory Read: 3 T) x . = 1.5 µ~
'xecutio n Lime for lnstrnction: (7 T x 0.5 = 3.5
Step 1: The inle1rn pl pro ·es · should b enab l d by \ rili ng th inslru tion El in th
main pro ram. Th is is imilar to keepin the phon re eiver on th hook. The
illSll1J lion El ~ ,. lh l nterrnpl ".nahl ' tlip-flop. h in. lntcti ,, DI re.<, 1-. the
flip-0 p an<l di:rnbl •s th · i11 l rrnp l procc s.
Stt:p 2: When th· ruicroproc ·s or b ·xccuting a pro •ram, ii cb ·ck~ lh · INTR tin· <lur-
ing the execution of each instrucli n.
Step 3: If th line I TR i hig h and lhe inte1r upt 1s enabled. the micr pr ce,,s I om-
pl ·t th url'cnt in. truction, di. hies the lntcrrurt •11abl' flip-nop, nd . end a
. ignnl call cl [NT - Int rmpt A ·knnwl ·dg (net iv - l w). The pro ,;or annot
accept any interru t requests until the interrupt fl ip-flop is enabled again.
Step 4: TIP signal INTA i. 11. ed to in. rl a re. tart (RST) in tructicm (or a Call i11st rll -
ti n thr ugh e.rtenwl l,ard11·arc. I h · RST instrn ·Lion is a 1-byl ' ·all instt u ·-
tion explained below that tran sfers the pro ram control le .i specific memory
locnt ion on p:.i e OOTI and rcstaI1. th c, cc11tion ::it 1ha1 memory locntiot aftc
xe ·u1ing St 'P 5.
Step 5: When Lhe microprocessor receives an RST in truct ion (or o 'al l instruction , iL
sa\' . the memory ac1 It ~ss or the n xi instru tion on the st, k. Thi is , imil, r to
inserting a bookmark. h program is trnnsfi 11 •d lo Lh · 'A L location.
Step 6: Assuming that the Lask lo b performed i \\,.nllen as a sub1oulme at the speci-
fied lm:atmn , the p10 essor perform tht: task. Tlm, snhrnut tll.: is kn< wn · s a
serv ice routin•.
Step 7: 1 he service routine hould include the insu·ucllon l:.L to em.hie the intemtpl
Huain. This is • i Ill i la, ro pulltn • the I ccc1' 'I' h::ick on t Ii IH )I .
Step 8: t tlic end of th· subtul1ti11 '. the ~ mslntctio11 1 ·hi ·v · th • m ·mor, m.ldr · ·
\ 'here the program Will> mletTupletl and continues the execution. Thi. is smtilar
'h 8085 in ·truclion sel include. eight RST (Restart) insLruction. Ii . led in SecLion 9.3.
Th are I-byte all instruction:-. that tran . fel' the prng1..11ll e ecu1 io11 to a ,pecifk loca-
tion o n page OOH, a li t cl in T,,bJ · 1-. 1. '1' RST in trn lions are executed in a similar
wa l that o all in ·truct1 11 ·• The addre:s in the prog·am unler (meaning the addre. s
or th ne t ins tru ction to an R T instrncLion) i. . 10.-ed on the tac k before the pro1?rnm
execution i. 1ra11sfcrred to the RST all locat ion. WI, n 1h • proc s: r nc 1111lcrs a R turn
instl'tl ·tion in t he ~ubrou1ine associated with the R T instruction , the program returns to
th address that was stored on the stack. l n ca. of. hardware in terrupt, w wi ll u. c an
RST in tru lion 10 rc1;,1nrt the progrnm c u1i 11 .
Rimll"y ode
h1c111onk.11 07 n6 D-: , D.i 03 02 01 Do
R~TO ()
-0- 0 7
RST I 0 Cl·
RST :! ( 0 D7 001()
RS'l 3 () I DF 0018
RS I 4 0 0 E7 002
R.S ') 0 I El· 0028
RS t I (1 F7 001()
RSJ 7 I FF 00~8
and tJ1e status lin s (] O/M , S0 and S 1) m·c J I in l .id of 0 I l ( c Fi ur L.2 . Duri n°
1• the RST 5 is decoded, a ]-byte all instruction to location 0028 . TlP rnachin ·y-
dcs M1 and M 1 arc Memory Wri1c ycle. lhtll store the onte nts of the program counter
on the stad·, un<l the n a n ~w i nstrnction ·y l ·gins.
ln this nex Lin. lruction ycl e, the program is lrnnsferr d to locaLion 0028H. h s ·r-
vicc routi ne i. written . m whcr ls in memo ·y, and the Jump instruction is written al
00 H to specif'y the adtlr ss of 11i ~ ser i '" rou1i n . All th o;;e tep:; llf ll lu. !rated in rhe
foll w ing xample.
ID k Ji.Stat
Bu et
Pl,
Dt11
0
EFH ⇒ o..us,
Dl1
.. 01 1
Dlo
The 8085 has fi in Ie1rnpt inputs (Figure 12.5). One i1 callc I INTR (discussed i11 rh pre-
vi us section) thr ar called RST 5. , 6.5, and 7.5. r p ·liv ly, and the fi rth i · called
TRAP, a nonmn. kubl' inten upl. These last tour (RST. and TRAP) ar f\ Ll lomatically vec.:
tored (transferred) to specific locations 011 memory p.. 111 c 001-1 wi thoul an I xt rnal hard-
war . 11,ey do not requi 1c the TNTA signal I an inpul port; the nece.ssary han1war' is al-
ready implc111c11ted im,ide lht.: 8085. These intern1pt<; and their call lo ·atinns are as fo lio
lnterru1>ts Call Localiuns
I . TRAP -4 11
2. RST 7. 00 'H
3. RS'l 6. 0034H
4. ST .5 002 I I
The TRAP hm: the highest p1ioriIy. ~ II wed by R T 7.5, 6.5. 5 5. and INTR , in that
ordc1; however, th ~ TRAP has a low r prioriL · than lh Ho ld si nal used for DMA
CLR
Q
oo Cu;
Reset
RS 7 .5 lntem1pt Recognized
003816
J~_n_ RS1'
6.5 003416
00 o,,,
4-_n_ RST
5.5 002c, 6
0028 ,,,
1---4-fi 002416
002016
Dl
El s Q
0018 16
Reset R
Any Interrupt R ognized Interrupt 00101<,
5--~_n_ INTR
Enable
frorn E 1emul
llardwarc
00081<,
0000,(,
TRAP, a nonmaskablc i11lermpt known ns NMl, is analogous to 1he smoke u,etecror de-
sc:ribtld i..:arlier. ]t has lh · highe1 t priority among the inre1n1pl signals. it need not be ~n-
ab led, 011d it ca nn t b~ di. nblecJ. 11 is le'tc l and edgc-sen\iliv , meaning thot lhc mput
hould go high and ':i la high to be a k1101vledged. It c:.inuot be acknowlerlp. ·d :~ ,ain unti l
it makes a tinnsi tion from high to low lo high.
Figure 12.5 shows that when thi5 i11l·rrupt i.'i triggered, the program c ntrol is
trnnsfcn- cJ to location 0024H vithou1 .iny external h rtlwar ~ ur 1he in1en up1 enable m-
slmction I. TRAP is g ncrally us ·cJ for such ~rit ical ·vents as pow l fa ilur~ and emer-
gency shu1 off
Th -·se maskable inrcrrup ls (sl,own in f igure 12.5) are c11, blt!c.l under progl'am con trol wi th
two in structio ns: El (Enable ln1 c rru pl) de cribed 1.:arlier, 111d SIM (Set Inte1rnpt l\•fa. k)
described belu v:
5 4 3 2 0
: ~ :~
M7.S M6.S M5.5
l { Mask Se l Enable
~~~~
RST5 .5 MASK
{
{ O
I
, rna~ 1
RESET RSTI .5: If I, RST7 .5 flip-nop j5 re\et Off
Ignored
ff I, bil 7 i ou tpul to Seria l Ou1pu1 Data Laich
Serial Output Da111: ignored if b11 6 =0
D On fun ·ti<11 is Lo set mask f r RST 7.5, 6.~, and 5 .5 i11l ~rrupl ,. This i nstru ·1ion reads
th cont nl uf tl1c. u cumulalor and enables r ch · ble. the int rmpls accordi ng Lo 1l1c
con tent of the accum ul m r. Bil D3 is a o ntrnl bit and should= I ror bits D0, D1. and
2 tu b, ffeel ive. Logi · 0 on 0 0, D 1, and 1 \ iII enabJ th~
correspondi ng interrupts,
and logi · l wi II disable th inl 'trupts.
These ond fu11c11on is I re:el RS 7. fli -flop (Figure 12.6). Bil D i~ addit.ionul
control fo1 RST 7.5. l f D..i = l. RST 7.5 is r~set. This h, us to overric.J · (or ign e)
RST 7. without ~ervi ing it.
D ' he thi rd function is co implem ·nl serial 1/( (di'Scuss cl in Chapter 16 . Bit. D7 and D6
of the accum u1. tor ar u ed for setial I/O and do nut :1lfoct the i ntenupts. Bi l D6 = l
enable.\. lhc crial 1/0 m1d it . 7 is used L trn11~1ni t (output) hit~.
In truction RIM: Read lnl rrupt Mask. Thi i. • I-byte instruction Lhat ·.mbe u. d for
the followin ftmc tion .
o r ad inlerr pt m. sk~. This instruction loads the acc umulal r with 8 bits imlica tin
Lhe cun nt status of lh · interrupt mask (Figure l .7 .
D To idenlif>, p nding interrupt . its 0 , s, and 0 6 (Figure 12.7) id nt1f lhe pending
i11t1,;,1 rupt. .
D lb r ·eive . erial data. Bit 0 7 (Figure l .7 is useu lo r~ eive serial d l .
The RfM instruc1io11 loads 1lte a~umulator with the following inform· ion;
7 6 I 5 4 3 2 l 0
SJD I f6 ..5 !5.5 lb M7.S M6 ..5
11 ..s M5.5
Ly-)l~ -~y---" -y-Jl~- -y
l
J
OOJ ] 1100 is m1 inst ·ucf on that incre nent the number in the register caHed the
accumu~ator by one.
JOOO 0000 is an instruction that add the 1u nber in Ll e regi ter call d B to lhe
nun ber in the ccu11nu[alor, and kc ps the sum in the accum dato ·.
i:
The 8085 n1kroproces or has 246 such b1l palterns, amuunLing tn 7 different i1 -
:t ·uctio 11s for perfon ling vario 1 operaf ons. These 7 different inslructions are caHed its
instructio 1 set Th. s binary Jan 0 uage ,vith a predeterm.ined insln ction set is called the
808 5 n1achine Ian uage.
INRA INR ·Land f r incr n nl. and A r pr ·nts th accumulator. This symbol
ug 0 t · th op r, lion of incr n1 nting th , c umulator ont nls by on
l. I -byte ins1n.1·1i ns
2. hyt " i nslrncti ns
3. 3-byL in. 11uctions
Progra1nmin 0 Ian uage that are intended to be machine-ind pen lent are call d high-level
languages. Th e includ su h lan mwes as BAST PAS AL C C++, and Ja a 11 of
which hav certain t of rules and draw on symhoJ and convention fro1 Engli h.
In tru ti n written in th languag s ar known as statements rath r than mn monic . A
pr gram writt n in BASIC for a n1i rocompul r with th 8085 n1icr pro e. or c, n °en r-
ally b run on another microc n11 uter with a diff rent mi ropr ce sor.
Compil r
Object
Sourc Code ~
or
ode
Inlerpreter
Monitor pmgrum-a progrnm thaL inte1-prels the input from a keyboa rd and con-
vert. the inpuL into its binal'y equivalent.
Flags
g. = 80 OA/8085 Regi t r S = Sign
M 111. = Me1nory Location =Zero
R = Re j t r
0 A = uxili· ry Carry
R· = Regj ter Source P = Parity
d = Regi t r D ·[ination Y = Carry
M emory
= ontent of
XX = Randon, nformation
Flags All n..i g~ nre modi tied to r 'n •ct th re. uh of the add ition.
Example A':,, 1Jmi ng the accumnl.ilnr ·ontains 26H ancJ Lhe pn.:vio11s opnation has ~er
the Ca, r fl ag. a<lcJ b 1 te 57H to th accumulator.
Addition:
(A): -6 H =0 0 I O 0 I 0
(Data): 57H =0 J O l O I I
I I
7EH =0 I I l I 1 0
Flags: S O Z=0 - 0
P = I CY = 0
C'omtut'nts:
AD Reg. Reg. Hx
Mem. 7 B 88
89
D 8A
E 88
H 8C
L 8D
M 8~
A 8~
Description The contents of the op nwcl (re,aisrer or m mury) ri nd the Carr' flag · r ·
add d Lu the contents of tl accumulator and the re. ult i. placed in Lh acc utnulat r. Th
ontent of the operand ar not alter d; however, th pr ions Carry llag i · re ·t:t
Example Assume rc 0 i. t r pair B contai, ,s 24981 1 and reg 1st ·r pail' DE contain,
54A IH. Add these 16-bil numb 1s ancl save Lhe result in B registers.
The sc ps in ridding J6-bil nu mb.,rs are as follows:
Flags All nags are modi fied lo reflect the r suit of the addition.
Examp Register B has S IH nd tb accum ulato1· hes 47H. Add Ill c.:ont nls of re 1s-
tcr B to the cont nts of the ac 11rnulator.
De cription he 8-bit daLa (operand are added t the onl ·nls of th ac mnu lator. and
th r · ult is plac d in I he accumula 1or.
Example The accumulatot ontains 4AH. Add the dat, byte 59IJ to the contents of lb
t1ccurnulator.
Addition:
(A) : 4Afl=0 0 0 0 I 0
+
(Daw) 59H O I O l OO I
A3H =1 0 10 0 O J J
Fla •s: S = l, Z - ,A =I
P = I. Y=O
Flags S, Z, P at c modi ed to reflect the res uTr of Lhe operation. CY is 1 & t. l n 8085 A
is set, and in 8080A AC is th resull of ORing bits D3 o the op!ntnd ·.
Example Th co ntents of the accumulator n d the register D are 54H and 82H. 1 sp c-
t ively. Lo
ically AND the contents of 1 gister D with th content of Lhe accumulator.
Show th tlags ,md the ontenls of each register aft r A Din .
Description Th contents of the accumulator Hr logically AN eel wi1h the 8-bil daLa
op rand) and the r sulls ate placed in the accumuJa t r.
FJag.s S, 'l, J> are modifi d to reflect the result of the operation. CY i re. et. In 8085,
AC i · sec.
Example AND data byte 97H with the con tent · of lhe accum ulator, which ontain
A3H.
Description The program sequ nee is tnmsfer d to the addr ss speci fied by t
ope and . Before lh t1 nster the addr ss of Urn next instrm.:tion to CALL (th contents of
the prngr m counter is pu ·1ed 011 the slack. TI e sequence of events is de cribed i11 th
example b l w.
Exampl Write CALL in truct~on at mcmoty location 2010H to caH a ·ulbroutine lo,..
cated at 2050H. Explain lhtl sequence of eve t when the st.lck po"nter is at location
099H.
Example Compl e11enl the accumula tor, which has data bylc.: 89H.
MC None 4 3F
Th c.:mpari:on of two byt --s i performed by subt1, cl ing Lhe contents of th -- operand
from l.h · contents of the a ·cumuli t 1·; h wever, neither c:ontcnl · , re modihecl.
Flags S, , AC are also modifi :din. ddition Lo Z amJ Y to ren ct the results of the op-
eration
E a npl R ister B contain: d:lla by1e 62f I and 1he a ·cunllllator contains datu b e
5711. omp, P th ' con tent s or register B with tl1ose of th a::: u1 ululor.
De.Ii r'1>Ho11 These o ncl byt (8-bit dat. i. compared with 1he contents of the ·cu mu-
lat r. The value. h ing ·umpared remain unchanged and rh · resu lts of the comparison are
incli "tell by s ·Hing the Ha s ti. foll )WS .
Jf (A) < Data; arry Ila i, set ancl Zero fl g is l'e · ·t.
If (A) = Data: Zero tla is -. l and Carry ft g i · reseL
D Ir (A)> Data: Carry nnd Zero tlag. ar' 1 : t.
The comrnrison of two hytcs is p rformed by s~1btrncting the JaH, byl' from th onte111
or ltl' ac ·umulator; how· ·r, neither c ntcnt · ,tre modifi I.
lt'lags . P, A are al modified i n '1ddition lo Z nncl CY tu refl ·•cl Lhe re. ult
of th operation.
Rxan>J)le ~sume the n ·c11111ulator contain data byt C-H, ompare 98H wi th th . a·-
cumulalor contents.
DAA one 27
Description The coritents of the a umu lat r a, chan ed from a bi nary v, lue to two
-bit binary-cod <l decimu l B DJ dioit. . This is the uni>' i11 ·t1u ·tio n that use · the auxil-
iary tfo, (i11 temally to perform th inary-to-BCD conversion; the con 1cr. ion procedure
is de ·<.·lib d b low.
Flags S, Z. A . P, Y flu12s are altered to reflec t th r ·sult. of the operation. In ·tr wti n
D A converts the bi nary cont nls of the accumulator as f lk)W,:
Dt:!SC ·ipUon 111e J6-bit t:onlcnt · of the spe ified re ister p;iir are m.lded lo the conten1.
of the HL reglster · nd th· um is saved in the I IL r gist r. he conlen s of' the so111· r g-
bter pair ai n ( ah red.
Flags Tf th· r • ·ult is larger than 16 bits the CY flag L set. oth~r flags are affected.
Example A"-. um r gis ter pair IJL cont:1in 0242ll Multiply the onL ' 11(1) by .
Descriptio 1 h • ·onl ' Ills of th e desig nated regist r/memory is tJ , Tt!111 ··11tcd by l und
the 1· suit. ar stored in the sam place. ff 1he perand L a memory location, it i: pec1-
fi d by th cont nt~ or the 1lL register pair.
Fags S, Z, P, A(' are modified to reUecl tlP r suit or th· operali 11. Y is not modified .
.l!:xamp e D ·crement regi. ter B, which 1s lear d. and s pcci ry ii!-. co nten ts after the
decrement.
Example Register pai DE contains 'O0OH . S1)ecify the con tents of the entire r gist ·r if
il is de,cremented y 1.
D Cl'iptio The 1ntcrrupt Enable flip-flop 1s rese t and all the interrupts except lh
TRAP (808S) arc disabled.
Comment: Thi. insl.J uction is ommonly used when the execution of a ad s ·qu ·nc'
·annal b interrupted. ◄or example. in c rit ical time delays, this instruction is used at th
beginning of th code and the int 1nipts ar nahl cl nt th end of the code. The 8085
TRAP cannot be disabled.
EI: E a le Interrupts
Opcode Operand Bytes M-Cydes T-State H x Code
I N n 4 FB
Oesc iption The Interrupt Enable flip-flop is set anc.l all interrupts are enabled,
Comments: After a syst •m reset or the ad· 10wl dgn,ent or an rnterrupt the Interrupt
Enable flip-flop is reset, thus disabling th int •n·upls. his instru 1io11 i. necessary to
1· ennhle the intel'rupts (except TRAP).
Descriptio l The MP fJ11i . hes executin the cu1Tent ins ·uction and halt~ any fu1tl1cr
xecuLion. The MP t.ml ·rs the Halt A ·k.nowl ·dgc 11H.1cll ir1e c clc an<l Wail stales a1e in-
serted in eve1y dock peri . he address ,rnc.l th· data bus ,u pla · cl in th higl imped-
anc · :-.tat . Th · contents of U1 r gisters ar unaffected durin the HLT state. 11 in terru[Jl
or reset is neces ary to exit from the lla lt stare.
Deseription T l. e content. of tl input port designa ted in the operand are read and
loatlcc.l into th· accumL1 lator.
ormn nts: Th OJ ra nd is an ~-bit addr ss; th re1'0 1·e po1 I , ddr , . n ra n from
OOH to FFH. While executin g the im,t1·uctio11, il p rt ad 1r ss 1~ tlupli ·,Hcd 0 11 low-order
(A 7 - Ao anti hi,eh -orde1 ( 1~ A8 ) uddres · buses. Any one of the se ts ol' address Jines can
I t= 1,h.:od ·d lo ·1nbl · th' inpul port.
Flags S, Z, P, A nr m uified to ref! ct the re. ull of che operation. CY i. uot mod1ikd.
Ex,1mplc Regi sl r D contain~ FF. Spe ·if the l:0111 'nls ui' the register after th incre-
ment.
Example Register pa ir HL comai ns IJFFFH. Specify !he co nten ts of the entire register
if il is inct menl d by 1.
Description The program sequen e i. transferred 10 Lhe mem ry location p ' ·ifi d by
Lhe 16-bi Laddress. Thi ~ is a }-byte i I srructio11 ; the ·ccom.1 byl spe · ifies Lhe low-order
byte a nd the third hy tc specif· the high- rd er byte.
Example Writ the instruction al loc.tion 2000H to lram,fer the program equence l
memory lo at ion 050H.
J mp Condition ly
Op rand: 16-bit address
Op rlag Hex
Code Description Stah1 Cude . )'des/T-States
JC J l1ll1p 011 HJTY CY= I DA 2M/7T (if condit ion
J Jum p on No Carry Y=O D2 is not lru )
JP Jump nn po. itive F2 M/IOT {if condition
M Jump on min u · S=I FA is 1nie)
Jp 7 Jump on Parily ven P= I EA
JPO Jump on Pd'ity OJ<l P- 0 E2
JZ Jump 011 Z ·m Z= I CA
JNZ Jump on No Zero Z=O C
Example As..<; ume memory localion 050H ' n1a i11 s by1' 8H. ,Id 1h ac ·umtdator
with th '01H •111-, f lo alion 050H .
Description The content. or 1he <lesig11aLed rcoistc1 air point lo ,J m 'mrny lo ·at ion.
his in~1rnctio11 copie~ th· ·unt ·111. ul' that rn ·mory lo ·ation into !he acc um ula tor. fhe
·uni ·nts or ilh r lhe regis ter pair or the me m ry location are not a1£ereJ.
Example s umc th c nt nl ol 1 • •i ·1T 8 - - UH, C - 50H, an<l mcm r ' loca tion
OSOH - 9FH. Tranc..fi r tl1e cc ntent~ r,f the rn m r I cation _QSOJ I to the accumu-
lator.
Description Th insLrucLion opi s th' con tents uf the memory lo ·atiun pointed out by
the 16-hil nclclre.,;;.s in register L :incl c pies l h con tent. of the nexl memory location in
11 gist r H. Th · ·n111 nt, of '-O ll i'· ,n mury lu ati 111-i are not ,dt I cl.
l!:xamplc Ass ume memory location 050H contains <JOH and 2051 H contai ns OI H.
Tr:crnsfer mem ry contents to register:-. IIL.
DescrjpOon 1l1e instn1 tion loads 16-bit data in lhe register pair designated in th·
operand. This is a 3-byte instruction; the second byte specities tthe low-order byte and tbe
rh ird hy1c specifics I he hioh-orcb hyre.
MOY M,R · 2 7
MOY Rd,M
Description This instruction copi "S th · conten ts of the source reg ister into the c.le$tina
tion register; the conten of the sour · regi ter :u· nol alte1 d. If one of the operands i ·
a m mar lo alion, it is pccified hy the con tents of HL registers.
Hex Code
Sour'e ca1ion
B C D E H L M A
B 40 41 42 43 44 45 6 7
48 4A 4B 4
9 4D 4 4F
D 50 ~ J 52 53 54 55 56 57
De. tina tion E 58 59 SA 5 5 5D SE SF
Locati 11 JI60 61 62 3 64 65 66 67
68 69 6A 6B 6 ' 6D 6 6
M 70 71 7 73 74
A 78 79 7A 7B 7
Ex.a nple /\SSlllOC registe, 8 co ntains 72H and regist r <.unt;;i i11 · 9Hl. Transfer the
con te nts of register C to regi1-tcr B.
H 26
L E
M 6
A 3E
Descript·on The 8-bi l data are stored in the de.,;tina1ion r i te or m rnory. If the
operand is a memory location, it is speci(i d hy th ' nt nls of HL registers.
NOP: No Operation
OJ)code Operand Bytes M-Cycl s T-State.-. Hex Code
NOP None 1 1 4 00
Description No opera tion is perform ti. he in ·trucli n is fotch ·ti and <l ·i;;odc;d; ho -
ever, no operation is executed.
Comment : The ins11 1clio11 i u. d 10 19 11 in tirn <l lay. OI' to dcl re and in. e c i11srruc1ion.
whi le troubleshooting.
Flags Z, S, P are modified t reliecl the results of the operati n. AC and Y are reset.
ExampJe Assume the accumulator has data byte 03H and regisler C holds byte 81H.
Combin the bit. of register with th accurnul t r hits.
0 : Logically OR Immediate
Op ode Operand By~ M-Cycles T-Statcs Hex Code
ORI 8-hit 2 2 ? F6
data
Description The content of the accumulator ar logically OR d with the 8-bit data in
th op rand and th· r ·sults ,u placed in th accumulator.
Flags S, Z, Par modified t 1 fl t the r suits of Lhe operation. Y and A are re1-et.
D ·cription The conlents of 1e a umulaL01 are c pi u inlo the OUIJJU l porl spec ified
by the operand.
Description The conl nts of th · m mory location poin ted out by the stack. point r r •g-
ister a .e copied to the low-order regi ler (sll ·h :-t'i , , L, ::ind fla s) o l' the operand. The
:ta ·le poi nter i:- i11cr inented JY I and the conten s of that m mory Jo atio11 arc copi d 10
th high-on.l r regisl •r (B, , H, A) of th operand. T he sta k point r register ii-. ag< iu in
cremented by I.
Desc ription Each binary bit o ' lhe accumulator is rotated l ·ft by one positim1 thrnugh
the nrry flag. Bit D 7 i , placed in the l it i11 the Carry flag and the Cany flag is placed i 11
the least significan L position Dtl·
Description Each binary bit of th" ai:.:cumula[ r is r rar d righ t b one position through
h Cimy flag. Bi1 Du i::- placed in the Carl'y flag and the bit in th' Carry flag j ~ pla ed in
the most sig11ilkanl po ition, D,.
Example Rot, tc th 'Ont nl f the a cumul dor lefL, a. . urning it conlains 7H and the
Carry fl, g i r s t to 0.
Op Flag He
Code Description Status Code M~Cycles/T~States
RC R turn on a1 -y y =I 08
R Return with No Carry CY =0 DO 1/6 (if condition is not true)
RP Return on po. itive S=O FO 3/12 (if condit ion is true
RM Return on mi nu S=I F8 Nott': If c 11 dition i, not true, il continue
RP ·tum on Parity Even P= I E8 the sequence and thus requires
RPO Return on Parity Odd P=O EO fewer T-states.
RZ Return 011 Zer Z- 1 C8 If c ndition is true, it r turn lo Lhe
RNZ cturn on No Zero z = () () calling program and thus requires
more T-states.
Description This is a multipurpose instrnction used to read the . tarn. of inl rru1 ts 7.5,
6.5 , 5. ~ and lo read seria l datu inpuL bit. Th in t1 t<.:tio11 loads •ighl bit · in th accumula-
tor wi th the followin i111erp erntion.:
17 16 15 IE 5.5
Restart
0 code/Operand Binary Code Hex Code Address (H)
RST0 000 I I I 7 0000
RST I l 001 I I 1 CF 0008
RST2 I l 010 I 1I D7 0010
RST I I 0 I I Jl 1 .;
00]8
RST4 I I 100 I 11 E7 0020
RST II I O1 J I I EF 0028
RS1 6 I I JI 0 J 1I F7 0030
RST 7 I I I I I I I I F 0038
DcscripOou he RST in. truct ions are equhalenl to l -bytc call instruc Lions lo one of h ·
ight memory locations on 11~ 0 0 . The instrncLions are • n rnlly used in conj unction
wit lt int rrupt. and inserted using ext ·rnal ha1clware. However. th se can be 1sed as soft-
ware in ·tructions in a pm mm Lo transfer progrnr11execution to one of the eight locations .
D cription The 8-bil data (operand) < nd the boITov ar . 11b1racted from Lh ontents
of the .i ·cumulalor, and lhe resul ts are pla · d in lh accumu lator.
HLD l -bit J 5 16 22
addres
Descdpti n The conlenls f e i. Ler L are l red in the memory lo ation spe ·ineu by
the 16-bil ad Ir ss in the operand. aud the cont nts of H register ar stored in the n xl
m m ry I cation by incrementing th operand. The cont ms f regi ters H nr not al-
tere<l. his i a 3-byl instruction; the econd byt . pecifies the low order address am.l th
I hi rd byte speci fie. lhe high-or r ddress.
O,; o, ~ 02 D, Do
jsoo I snE 'XX R7. MSE M7. I
J
M6.5 5.51
J l
I
Desc iption Th im,truc;tioo loads the content. of tile H and l, registers into the s t. ck
poinLer regist r; the contents or
lite H register provide the high-order add t-ess, an<l the
con tents of lhe L regi~tet" provide the lo\ -ord r addr 'S'-, T he contents of th H and L reg-
isl ,,·s al' , 1101 alter d.
STA 16 it 3 4 13 32
Description The contents ol' th n umulat r ar' copied Lo a 111 mory I ation sp cified
by the operand. ' 'hi is a 3-byl in.·truc1i on ; th secoud l}yte srecifie: th· l W·l rder ad-
un.:ss and Ihe thlrd byl · ·1,xifies the high order address.
Flags N flags arr affi cted.
ST : Set Carry
01>code Operaud Bytes 1- yclcs T-Stalt:s Hex Code
ST None 4 37
SUB R g. 4 ex
Mem. 2 7 90
91
D 92
E 93
H 94
L 95
M 96
A 97
Flags All fla )S are aff t cl lo retlect Lhe resu lt of the ubtraction
SUI 8-b1t 2 7 6
da ta
Dcscd1,tion 1 8 hil data (th ' op ra nd) are wt 1racted from lhe content, or lhc accu -
111u lator, and the resu lt ' arc placed in th acc umulator.
Flags All flags are modified to reflect the rc:,; ult.'i of rhe subtrac1ri, ,n.
Description 'C he 8-bit data operand) , re Exclu~ive ORed with the contents of th · · c.; -
cumulat r, and the re ult · arc pJ ced in the accumulator.
Flags Z, S, Par ult 1' .d to reftec L th res ult of 1he operation. Y and AC are reset.
,,...
r
Mo,,;• Ml>•• fco I lliio•• ' 411\1' IOCf• I 09' et•
A.,. a,
A.S "
78
5F A. byl OE
.,.,
C A A1
f
• t,ylo 00 8 IIO 04 AQ
AC 10 $9 C, tr,10
f
OE C C Al
MO't' ,.,0 7A MOIi M MVI o.w,, Hl R u AHA· II?
,oo
I~
A, 1 E, t,,,,i.. IE ~ 1c E Al
TC
"·A,l 10
6C
30
byle
L byl•
20
2£
M
~
N
2C
H
L
II ◄
A!
A,M n: S£ M.......
• l~ M
"°
.r
♦1
.,
67 A 8F
'"'i~ O:t A AF
r
◄ H.ll 60 00 13
I"·
l41•11 AO
8,C 11.C I 8!1 It 2
M V ,0 41 MOV D
C G3
o, 111•dl•I•
AOC AA SP OJ IIAA
C
0 ,.,.
A
i ,,
8,E 4;l ble 01 88
,H HH 84 E AB
◄◄ L 0 dbl" 6C
BL 46 ►t L s 0.-c.r,menr • H AC
RM 4ft ... 66
H. .,blO
SP, dbl•
21
:11
80
,. 3(l
L
M
AD
~F L,11 6f'
••
~
I ,fl
LC
L..-r&loto u ~,· ft
C
05
00
A 87
4A MOIi I> A
LMX e QA OCA 0 IS C 81
!17 ORA
LOA;( IA 10 0 ?
.a LE 68 E
"{ -
Llll.D adr 2.4 ~ E a,
◄C L.H 91 H I'S
40 l.L GD LOA M L 70 H ◄
ii?
3~ L 65
L,t.C STAll 8 <l7
...
93
~. ··f ,.
•'TAX 0 M
0 ,A 1 n 12 II 08
r
D,B so M,8 70 s 0 lh n L 9S A
o.c MOli M,C
•a;. tdr J:l 28 a 88
1' ,o
MO\I DO la M.D 12 SP C
o.r ~:, M.F 1:) CJ
CMP 0 BA
!)
O,H l,4 "1.11 1◄
I ~:. Ml 1 g,. H B
D"1 !ill !IS UAA J1
EB ~ BE
-....
lfCHQ
flC CMA 21
net
!>yle
_,.., t, o• DO
CMCt
J7
:11 "''" at.
untdf•••
It co l\~b:,ltl C:8
.
trrh
ACI byte u
.... ..,..., "'"' ,. .. t
,,
lhll•l• 1
I 06
..
1~ otl-btt •h
••
{~ ,.
681 ..,, •• r>r
••
an,
I •1p,nn 11,/W d CC> A 19
If
A ◄ I l>yla E6
)(RI uyh• f
l F OHi bylo F&
CP1 byht IL
All n4!:".t tqf¥t I I• CClifJ'61f'iN
' ' )$
r"nsfi r th con nts of IOU and ' l0OH to r gist -r s F and L r sp ·ti
. h n stor · th · HL nt nt 1 , m mor l ·. ·ation 9·,..0 l 1 and 9'300H r sp cti
M 11.eni.011ics Opco,de Co11.u1.i.e11ts
L D 100 H 00 l Lo· .d .. and L ..r rn m m r lo .,. ti n ' 10 lI . and
l00H
LD 9·300I 00, 9·3 .r .rn Hand L m m r l 'ati n 9 OlI
·md 9· 00 I r sp · ti "'1 .
START
End
·---------------------------------------------~---------------------------------------·
: Data : Re. ·ult :
t---------------------------------------------,---------------------------------------1
1 Me m rv 1€ c ati n : Data -I• M m ry ] c ati. n. : Data 1
l----------------------~----------------------~------------------------~--------------J
I
I I
( ( _H
I
I (
I
I
I
I
I
I
·----------------------~----------------------~------------------------~--------------·
Incre ment C by 1
C =01 H
E nd
MSBs of s111.m
,OOH 2B 0 'X H ddrcss >f l st Til!ll.m oc r, 0 1 i111 HL pair
'(l () ' 66 DD M ddi ion of 1sl mi:mbt.·T and 200 m1m bcr
,00D D2, 11 , 8 j LE :;-L l I f carry ,cio c-'> n >I gclJl ·ml. \ j111.mp t L - -L l
,(HO 0 l[ R \.VbclJl 'c;:IH)' is ~ocralcd, i111 :Tl"IJll ·111tR ·gis t ·r 1
·---------------------------------------------,---------------------------------------~
1 Data : R.e.m/J 1
•~---------------------------------------------,-----------------------,---------------i
M ·mury loc-aLion : a ta M ·mnry loc-ati rn Ia ta • I
I I I I I
,----------------------T----------------------1-----------------------~---------------1
1 850 1 f2H 1 1 8 ff' • 2H LSBs ol' s111.m 1
~----------------------~----------------------J-----------------------~---------------~
l 02 : 2FH l 80 : Ol H ·1SBs ifsL.1.111 l
~----------------------~----------------------~-----------------------J---------------~
START
N,o
Slore LS B o·r S um
Store MSl3 of Sum
c End )
Dr. Anwar Sadat, Electronics Engineering Department, A M U Aligarh. 7
,11em fJJ"J,1 ua ./l i m!
mldress Cod e~; Opem11d~;
F( 0 () 21. 00. F l LX!l H.Fl<l()H ddrcss >f n111.mb ·r of byl ·sill HL n.:gist ·r paiw-
Ft 03 E Tra11sfi:rr1111.1111be..-ofbyLcs from mcllmry lo ·.ati n
lo Rcgi-.1 ·r. '
FOO .F XRA , ' I ~r a 'LU!lllllal.o r n:gi'>t ·w-
F( O 06,(H> M 1.nilializc R ·gist ·w- B willn OOH U> sl. )TI: 1SR'>
of s 1m1.
F( O I. X H ddrcss of l sl llL.111i11 ber in HL pair.
F( 08 66 DD M dd IIIL"m ny I. ) a ·u:m 11lal.or
F( () D2. OD. F() J LE :;-L l Lf carry drn:s TI >I gcm:rat · • j L.l.lllp lo L - -L 1
FOO ( I. R B If carr is g ·m:ralcd. i n.:111cll R ·gisl.c r. B
F( OD OD L - EL 1 0 'R De :t1:mcnl. 'OLl:llt by 011 •
F( UE , ·2.0. F0 1 J z L f ,p T ·st t > ·ln1.sck v lrictlncr additioll of a ll nwnbl."rs
an.'. dom:
FO l l "'2. 00. f2 STA F200 S~u~ L Bs of s111.m i11 · 1crn1 ry I J .. llio11 F20UH
Fl 1 .B ' opy J ill ·11 l 1f B i11 a '. llllill ulaI Jr
FO l , 2.0 l. F2 ST F20 1 Slon.: M SBs 1f s111m in m ·mory lo ~ Lion F201H.
F0 18 6 HLT S~up
1 Dllla --- --- - --- - --- ---- ---- ---- ---- ----T-- Rl!!IIIII -- - --- ---- ---- ---- ---- ---- ---- --- - ---1
t-----------------T---------------------t--------------------------,-----------------1
I M~mol)' loc ion I llit:a : M~mol}' loc ion I 03.t:a. I
•-----------------T---------------------1 __________________________ _,_ _________________ ~
1F l OO , 0 H : F200 , OHi LSRsofsum I
L-----------------•---------------------r--------------------------...1...-----------------J
: FlOl i ffl H : Fllll I OOH MSRs ofSlDll :
I~-----------------t---------------------r--------------------------J------------------
1
Fl02 I 02H I I I
~-----------------r---------------------~--------------------------~------------------t
i Fl 03 , OJH I I i
t-----------------t---------------------l---------------------------<-------------------1
1 F l 04 1 04H I :
1-----------------T---------------------t--------------------------.------------------1
: Fl05 I o -H :
L-----------------i _____________________ i __________________________
I : _l_ _________________ J
START
Increment B by 1
B= 01 IHI
End
Fl OB ( BR B lm.Tclillcnl. R ·gisl.c r B
•---------------------------------------T---------------------------------------------•
: D "1tJ R l!'IM II :
t-----------------T _____________________ LI ____ -------------------r--------------------1
, Memo!)' loc ion I Data I Memo!)' location , Data ,
I~-----------------f---------------------+------------------------t--------------------J
F050 , 52H I FO 2 1 89 H I.SD!i of sum I
~-----------------+---------------------i------------------------i--------------------1
IL-----------------~---------------------i
1-"0 " l : 85H : Fll "J I Il l H MSDs of sum
________________________ L ____________________
I J
End
5111d
[ D llla i Re.w t 1
It------------------r-------------------------,---------------------,-----------------i
Mc:mo:ry location I Data. I Memory locat ion I Data I
t--- . --------------r------------------- . -----~----------------------.-------------------1
1 &00 1 1 RlHLSB:sofdata- 1 1 &005 1 FFHLSB:sofsum 1
f------------------~-------------------------~----------------------+------------------i
I 8002 : RlH MSBs:of data- I : &006 : OF'H LS Bs of sum I
1------------------~-------------------------~---------------------+-----------------l
1 &003 , OFH LSB:sofdata-2 1 &007 , OlH MSB:s of sum 1
t------------------r-------------------------,---------------------...,..-----------------1
iL------------------L
8004 I _________________________
l F'H MSBs:of data-2 : i i
J _____________________ ...J.... _________________ J
STA'RT
End
Memory M diine
adJres., ,C oda Lzbeh J\'fnemonks ~rand!i -C ommmt.,
8000 2 l, 50, &O I..XI H,l!OSOH I.. d ddre.s:!l of nwnbcr in HI.. registc- pair
8003 E MOV A,M M O'i/C the number into rumul.ator
8004 3F CMA c~mplancnt ccwnul tor
&Oil - 32, -1, &O STA &05l H Ston the resu'lt in &05 lH
&Oil 6 HL'f top
STA.fU Atgorithm
I. Tran'.~fe:r the content of the me:m.or , !oc:.a:t iun 8.'lOOH to
Load dala in accumu'la10r aroumubtor.
from me.noory locaU@n 8500H
2. Complleinen'I the roa'lent of the acoumufator.
3. AddO IHw ilh aroumt.illatorto ~-a1 t""o ':s oamplemen'l o f a n'umber.
Comp'lement lhe mment Store the re.~ult irn the memory Il · a:tion 8501H .
of u1ator
Boo
f---------------------------------------r---------------------------r-----------------l
D/IJa , R'511ll
---------------T-----------------------~---------------------------~-----------------
1
i M~mol)' Joe I I i
r&500 __________ t_________FOH __________ !_ &SOl ______________________t___ lOH __________ j
ion : l!l:lm M~mol)' location llita,
Sl'AIU
AlgorJthm
I. Load memo. , location o f dati 80 ·H in. HL re •i'ilerpaix.
2. Move data frum memo1y to a m ator.
3. Content of a )'Umulator rotate l!eft by om:bit.
lo.re the Je_~utt in 1ihe memory l!aca:tion 800 I
End
Memary i'dacliine
'ildres. Otdi!. UJbel., Mnemonic., Opi!roNI. ,C ommml.
80111 21,00, 30 DJ H,&000 Load mcmmy addr of d!l.t a &OOOH ill HL pair
80lJ E MO\' A, M MO'i/C data. in acrumu lator
8014 07 RLC C~ntmt of ccwnul tor rot:ak kft by ooo bit
801 - 23 INX H lncmncnt H t n?gistcr pa ir
8016 MO\' M, A Smn? 1ihc IT&U lt inmcmmy loc ,l ion l!OOlH
801' 6 HLT Ha.It
r DoJo 1 ROMII r l
[Mcmol)' loc ion:=[:==::==::= lllti =::=::==t==::= Memo])' loc :ion :==::==t:=
: !!;050 : 04H : 80 l i
CAltl ::==::==:] 08H :
~---------------~-----------------------~---------------------------~-----------------~
Algorithm
from I. Load 16-bii or 2-lbyte data [rum memo. loc.a:tion m lil. ie •-ic~ter pl! ir.
2. Content~of HL re •·ii! ter pl! ir are added to itself on and the result , tared in HL pair for :sh ift l'e · by
onebii
3. Store the result in OO.'i3H and 8053 location_~ .
End
i'demary i\fa.:lun e
adJN!!I.¥ ,Code.¥ Label. J\1nemank:. ,Opi!rands 0:mmi enl!I
811111 2A, 50., 80 LHILI) 8050H l ood data.from mcmmy Joe Ii.o n 8050H d 80 · 1
to Ht ngista-pair
&UH 29 DAD H Shift 16-b it numb a- by OO£ b it
8104 "J, 80 SHLD go · H ton: re-suit in 80 "JH nd 80 " H memory
Joe ions
810 76 HlT
rDoJa - --- ---- --r- ---- ---- ---- ---- --- - --l-----Re.WIii - ---- ---- ---- ---- --- - --- - --- ---- __]
I Memory location I Data : Mcmmy Joe ion i D I
Ll!O O ________ __ [_ ___ 52H _____________ _ _l _____ 80 J _________________ [ _ A4H LSBs ofn:-sult _j
IL---------------L-----------------------~---------------------------L
00 · 1 I "H I so· 4 I _________________
OAH MSBs ofn:-sult I
J
AlgorJthm
I. Llad Ole fi~t n\.lrnbe:r in aet.'l\J.mullator frurn the mem.or loc,a:tioa 8050H.
Compare ~eoond n'umber with fin.1 number.
3. If ~ nd number i-.~ "rea:lie:r than firs t number, OOifl: · Second number in the arou.mul:a:tor from memo
Store Ole re,i;ull in 80.52 . l.ocatiun.
I!)
START"
Al90rithm
I. Load oounl var-u.e of numbe:r.s 05H in Re ,i:_~tc:r immedi.atei '·
2. Load the fi rst number in aroumul:atar from the memor lllGil:tioa 9 I H.
3. Move the fir.st number in the · oum.ul:a:ior.
Decrement the oounl ·,'il.h.ie by one.
5. 'Move to ithe ne::d memo · kK.-;a:tiun far next da:t:a.
6. Compare the content ofmemory w itb oontent of a ,wnulliitor.
7. 1f c.a.rr ' i · .,en.er.ired, ooP'. uontent ofm.em.or ' in a ~umulla:tor.
8. Deaem.ent the oount · 'il.loe I> , one.
9. If oount \'alue doe.~ not equal to zero, repeat •.tep, 5 to 8.
I 0. :o re the re.s1Jlt in !XI06H lllGil:tion .
En:!
I Dllla , Rl!.'11111 :
~ Mcmmy
1
-------------,------------------------t-----------------------~---------------------i
loc ioo , llita I Memory location I llita. 1
I I I I I
['l.liDlll __________ J_-:DH" ___________________ J_ gllOi) _________________ ~ ______ Fm ____________ ]
l 9002 l FFH : i l
1
9003 --- ---- __J_ 4 7H --- ---- ---- ----
t 9004 , ~2H
----l---------_---_--- ----_I__-------------------
, I
li 1
Algorithm
I. Addre.~s of the fiI's-t n1.1.mber i.Gin HL ~ ,j-st~ pil'ii:.
2. Mcwe lin:t number into a · · umulator.
3. lnerement HL re •·i!.te:r pair for addr.sl-.inr• !leCOnd number.
Compare ~roond number with first number.
5. \Vhen the fir.st m.mber i.GI .Gs l:han seoond n'umbei: the oontent of ' :OL,1.LmuJ1.itor i.Gthe smaDle.,;t n'LDILber.
1f seoond n'LDILber i.G ~,GR iha.n fi n;t n'LDILber, OOiJ.l: , seoo.nd number in a umu.l.ia:lor from memory.
6. lore the ~~utl in 9052H location ..
IEnd
9103 7E M OV A,M
9104 INX H Addr o:f2!oo 11wnbc.r in HI.. pa:ir
910 - BE G l"P M c~p 2nd 11wnbcr d l nwnber
9106 IDA-- JC l.EVEI.. lfbmr • ( C3IIJ)' is gmcmtal,j um,p LEVEi..
9109 7E M OV A,M Mll.'C 2nd number in .c aunul to r
910A 32, - ,90 l.E\'"EI.. S'fA 9052'.H S to~ smsllc nwnbcr in 9052'.H
9101D 6 HI..T Halt
ID4"1-----------------------------------i-Ri.wii______ ---------------,
~---------------------------------------+-----------------------~---------------------~
: Mcmmy loc ion : IDat:a : Mcroo:ry loc ion : ID3ta :
too-o----------~--1sH-------------------t--oos1------------------i--flfH----------------1
t 90 _l ____ ---- ---t- - FFH --- ---- ---- ---- ---f--- ---- ---- - --- - --- - ---f---- ---- ---- ---- ---- --~
t ______________ J________________________ l _______________________ ~ _____________________ J
START
Algor.ithm
I. n re oou.nt ofnumben. OS i:n Re -·:.-ter immedi..ire~ .
2. Load the fin.t num.be:r in aocu.muliator from memor ' I " tion 8001H.
3. Decrement the oou.nt '\'il.lue b • one.
Move to next memor ' l'o<:ation for next da:ta.
5. Compare the oontent ofmemor •w ith oontent of ' :,e;umuJ1.itor.
6. Tf carry i:s not generated, oop: , the oonten.t of memor · in arou.mulator.
7. Decrement the oou.nt '\'il.lue b • one.
8. Tf oount value doei, not ~ ua.l to zero, re,pt".tl step, 4 to 8.
9•. n re rei.u lt in 8006 location.
End
START
E n:!
8. This procoe:ss will con'tinue n1 oompi,ri!:iOn of an ntm1bers ha,.,e been oumpk:ted After completion of
oo:i:ipariisll[l of aH n:wnbeis 1lh.e :sma]la'lt nwnber in a-oou.mula:lor and store ii in memol}'- In thi.~ 'way
th.e fl-rst l_ll"(!Ce.•,s will be oompl1eted.
9 At the :sti.rtin •· of second !Pruoe.~s- Reg.ii,t er i.Gdecremented and store ntJmber of oompari:.~n'.~ in
1•
Re ,·ic!iter D Then repeal i.1:e,p; 2 to 8. A 'er completion ofth i:.G proce.Gs the :smallest n'wnber i:.G in 9005H
and the second !.'IIIAilfe.s l ntJmber i.~ in 9 H.
I 0. Re •i~ter icS decremented and Hie ne.'d prore!L~!.tiilrts if 'Lh.e content of Re •ic!iter i.~ not zero .
Algorithm
I. ·ore the number in the a -umu.tator from the memor , location
9000H.
2. Mo,.,e ihe c ontent of a umu.tator in Re • isier L and ..tore 85R in
Re •i:.~terH .
3. \\/hen ihe number i.~ 16, the content ofH and L re• ·ster.s are 85H
and 16H re.~pecfoe ly. Then the HL re •i:.~ter · ir rtpre,,;ent~ ihe
85 16H memory ! · tion .
Cop the .square root of the mon.ber in the a mutator from the
memory location which i.~ represented b JU. re .i,t er pair.
5. ore the resu.tt in I .
M enu1ry Ma dilne
ail.tr ,Code., u beh i'dnemanic:., ,Operand ,<J>mmm l.
9100 21, 00,M LX I H,&OOOH Address ofmult i;pl.icr in HIL pa.ir
9103 4E MO\' C,M Sto:rc mu]t i;pl icr in Rcgi u C from mcioory
r------------T---------------r---------------.--------------,
J AdJu.u I Data I AdJu.u I Re.w:11 J
t------------1---------------r---------------r-------------1
1 8000 H , 45H Multiplicand 1 9000 H 1 05H 1
~------------~---------------L---------------~-------------~
J 800 I H : UH Mu ltiplier I 9001 H : FFH J
L------------~---------------L------------ ----1--------------J
START
Algorithm
I. Lood the multipllicand and mulliplliser.
2. lnili.afue produ 'v a"lue = 0 .
3. Loo:d ni.Jmber of b it.~ of multiplier in Re• · ster C.
Sh if-I multiplier r i , hi by one b it.
.5. If t."'.illl" Illa ,. i.~set mu[tipllicand add.~ 1,.,-ilh irutial \•alue O H + mull ( i:c-,and Th.en p:odoot is e ua.l
to O H+ mU:ltipfa:i md. Thi!!i re1,1.1.[t i!!i also called as parti,al product. Then partia.l podl..ll>i i..~ "rafted
l!efit , on e b it.
6. OCR counts v.ilue,
1. If lhe oontenl of Re ·st-er i,· not zeru modifred multiplier a n·· in sh ifted me b it rhghi . Product =
Prodoo:+ M ,ilicafld
8. If can- Illa , i,s s . sh ifted rnultipl icand add~ w ilh pa.rtia I product. Th.en oaoe a , ·· in s hi, s 1he modi li'ed
mutt iplicand le .
9'. Rt,pe.at step.~6 1 a.nd 8 till the ooatent of Re •i~ter beoome.s zero.. IDeaement
IO. Store l:be result iTI 9000H and 9001H.
Algo.rithm
I. ore ilie dir,•i:dend in ilie memory l'oc:at iun 80 and ilie
diii•i:sor in the memory ki<-.a:ti.on 8001H .
2. Clear Re Ti:.'iler i.-t orin ,. · H w ilh in it
3. Mt·we d i1tidend in a tJmulialor and oop it in Re ·,i~te:r D.
Su.bt.ract diivi.Gor from d i\•itlend.
S. If carry iG not LJenerated i:no:ement Regi:.te:r C. Re,peat
,1iiep.~3 to S.
6. \Vhen l.l.rr)' i.~ .,ener.i.ted, quotient, content of Regi.~ter
and rem.fl inder oontent of Re ,-ii_~er D are stored in mem.-
or location.
7. If zero a -, i: set. Re ·, i.~ter i:.~ incremented by one. Then
quotien oontent of Register and rem.ai:nder, oontent of
Reni:.~ter D are :StiOred in memo. location.
End
i.5 placed in the memory l!ocati:on 8002H. The resutt5 will I be stored i:n the m ernor loca:tion.5 800'.m and
SO H.
PROGR. M 4.27
M emary M adlilll!
'ifdr Coh.~ Labl!l!; i\fnt!ltlonic.'I ,(J:perand>i •C ommenlS
9 100 2A, OO, &O LHLD &OOOH Store d ividcnd ·in HI.. pa iT
9 103 3A, 02,&0 IL.DA 8002H tore d ivisorin .a :umul .b rr from mcmmy
h,c ion 3002 H
9 106 47 MOV H,A C-0,py 1!hc mn11?nt of .a :umulator in l«gis tuB
9 10 OE, 01! M \11 C, 08 l..oad O!!H in l«gi i?rC
9 109 2!I LO) P DAD H Shift dividend nd qootim t right by ont b it
9 10A 7C MOV A,H Mow MSBs of dividend in .a :umulabrr
9 10B 90 SUB B ubtract d ivi:mr from dj,,, idmd
9 10C
9 10F
DA, ll, 9 1 JC
MOV
LEVEi..
- If ml is cany, jwnp to LEVEL_ l
Afrersubtra.c tion ore dj,,,idcnd in ·R£gista-H
67 H,A
fimn cumul or
9 11 0 2C liNR L lncnmcnt L n?gistcr
9 11 l OD LEVEi.._ l OCR C Da:remmt C rrcgi c:r
9 11 2 CT, 12, 9 1 mz LOOP If ml is oo zero, jump to I..OOP
9 ll - 2, OJ, 80 SHLD &OOJH Store usul In 8003 d 8004 H
9 11 & 'G HLT Stop
.,..... ...... ... ......... ... ....... ........
.......................... ... .
r-----------r-----------------------------T----------------------T--------------------,
I Addus. : DaJa : Addus.~ I Resull I
1
t-----------~-----------------------------+----------------------+--------------------i
l!OOO H ' 9A H LS Bs of di,·idmd ' 9003 H ' F2 Quotient 1
t-----------~-----------------------------1----------------------t--------------------1
I 800 I H I 48 H MS Bs ofdr.·idcnd I 9004 H I 00 Remainder I
l 8002 H _____ [ ___ IA H D r.·isor _______________ J_ _____________________ l_ ___________________ ]
Ir---------T---------------------------------------------------------------------------,
& Bit DATA I Binary 111111tlur in Me1t1ory LoalllOII I
r---------1 ,01,n _r_ , 011n r , 011n -r s o54n-T , 011n T , 016H-r 805 H-r 8058H --------1
!End ~---------f-------+---------~--------~--------+-------+-------~-------f---------------~
12 10 I o 1 1 10 10 1 1 1 1 1 1 :
1 1l t O i ________
•---------~-------~---------J
9F O tl i l il t l i l 1
L _______ ..J... ______ ..J... _______ L _______ ~---------------~
lna ement H L by 1
Increment DE 1
Doorement 1B r~ister·by
No
Em
............. ...........................
[ ________________ lnplll ________________ [ ______________ Re!mll ________________________ ___ ]
I
j_ _______ 115 H _______ [ ______ 9 100 ____ __1______ 115 H __________________ J
I ADDRE•.._.. ' DATA ADDRESS ' DATA I
[_ ______ 005n _____
1 90 I : 48 H i 9LO I ' 4g H
•-----------------,-------------------~----------------....1...-----------------------------~
I
1 90"2
1----------,
1 IA H ' 9llt2 I LAH
------~-------------------~-----------------,...-----------------------------~
1
I~-----------------~-------------------~----------------+-----------------------------~
90 - 1 33H , 9LO 1 33H I
L-----------------~-------------------L-----------------'------------------------------J
h fl w hart in Fi ure 8.2 how a tim -de]" y loop. A count is loaded in a register, and
th lo p i xecuted until the ount r ach zero. The s t of in tructions n c ssary to set
u the loop is also shown in i ur 8. 2.
Load
Delay
Register Label Opcode Operand Comments T•states
MV C,FFH ;Load register C 7
Decrement
Register
LOOP: DCR C ;Decrement C 4
In Figur 8.2 register C is loaded with the count FFH (255 10) by the ins ·uct' on
MVI, which is executed once and takes seven T-states. The next two instructions. DCR
and JNZ, fonn a loop w Hh a total of 14 (4 + 10) T-states . The loop is repeated 255 tirnes
mtH register C = 0.
The Lime delay in the loop TL with 2 MHz clock frequency is calcufated as
T = (0.5 X 24 X 9092io
= 109 ms (without adju m for he last cycle)
Tota Delay T 0 = 109 m + T 0
= 109 ms (The instru tion LXI adds only 5 µ s.)
A time d lay imilar to that of a register pair can al o be achieved by u ing two loops·
one loop in id the oth r loop as shown in igure 8. (a . or exan1ple regi ter i u ed
in th inner loop LOOPI) and r ist r B is us d for the outer l op 00P2). he fo] -
lowin in tructions can b u. d lo implement the flowchart hown in igur 8.3 a).
MVI ,- 8H 7T
L00P2: MVl •➔ H 7
00 1: DR 4
NZ 00 1 10/7T
DR B
JNZ L00P2 10/7T
. L,
lay in
OOPl
DR
JNZ OP2
'Ille m•cH{8t ~ U3ol to copy or traDtfer data fa:m a WJl'ec nro a ddmattcn., nc ~ 11118)" be a re,-
ktert •nci~ aa input~ or an. I-bit ■1•1lbcr ~R to W~ In. tile ..-c ftYt die dd:inatiotl nAtY Ibo be
• rea;ili« ~ or aa ourp, port 'Ille ~ Ill(( dd:lnatloal r1 data are lmowa. • ~ Tbcre are
varicNs foarietsto ,pocify o,ci:eads f o r ~ ' I l l e ~ ~oflpcdfyia& dltaare callcd tile
~ modes. ~ die folbrri• lddrculaa moda • U3ol :in die 808.5 ~ :
l Imm.edWe addrc:N,:ia.g
1Rcpter~
l. Directadtklll•
4. lm.4lrcet .......
Ir--------------1----------------------------------------------------------------------,
J,rslrMd-. I Tavl I
I INO I lmnl'u- OO H I
f--------------~----------------------------------------------------------------------,1
I UUTO lH I . nli!! 111 Port Ol H
1 11
t--------------,----------------------------------------------------------------------•,
I L D .I! Ii : Lmtl. th! cmlli!!n \ t1f 191<!! ay I( i m .I! H iin 19ie mu bta- I
,--------------;----------------------------------------------------------------------,,
l---~~~-------J------~~-~!~-~~!~~~~~--~i~~~~-~~--~~--------------------------~
In. Ith.· iti"Stroot i:ort 1N O liI Ith.. addr ~·s of .ii.ti. I . port is O Ii ./here tl-ie da1ta is ar ,aillabL F rom 11:hi.,;
-• hen data fr to be read a:nd :stored irt the • - -urru.ill • r. ·. ia:tillarly tlie m nie:nt of the · :umullal'or can. · ·
·eat 1tu the out · ut · rt ·rldre..,;s OlliI u.~iti ·,·O . T OlliI mc,;trU(,-hua .
liI i i; fue memor --· tion. from 'here datii! ·i:s to be oo -- d. Th.e refoie
fu - insrtruc1ti:on it•,d f · - · fteS 1:he :so ure - of da:ta . After r ' din 1 diiitai from SO Ii it . -m'lfll Ile · ;t .oo in 1th
a ,umul<ittu r.
Ia Ile reptor addrcMlag ~ oac ti lie rea1-.A. ~ ~ D1 ~ D at L can be uad • scurcc of opci:-
...., C081equea.dy1 dara it proride(l duw&h lie ~ la dlJt ~ Ile l!l)(!Wnlllafor it iaq,Hed U a
~ operand, Pot" e'1'8'9\; Ile :laO.lctlca. ADD C a,- diet die conten• ~ lie Creal_. will be added
will. Ile ccatcat, of the eccumqiatOt". Moltofllc ~ - . q_,--addrctq mode haw:: 8-bitdatet
•ou•t 10me ~ deal 'tridl 16--blt reptor P11•1 for exempk; PCIIL ~ Hxampes ofrep-
terl!d.dtclda& are~ ill Tattc 3.2.
~---------~---------------------------------------------------------------------------,
: ~~ : ~ :
: LDAX B I L<Dli ll1'! ac,rurmd 'rromad.d.n!I:! i,, ~;i,.,,.panr B-C :
~---------~-------------------------------------- ----------------- .------------------lI
I MOV A,M , l,l'ic,....,lh.,a1JJ1m.<1 fll., men:aylocst,m whu,.,ad.m.s,"' gwenm Ii '""'1 L ~""""" ete~UDU btc"
~---------~--------------------- ·-----------------------------------------------------1
~ MOV 1,_11,B -~- l,f,o....,lheaml<!III o f lhe kCUIDUI _ ,111 d>e1D<!IDlt1J)' k..,..,;.m mi _ adili= ,, ~""'1111 Ii "'1d L ~_,...,. ______ )
I A DD M I A ddll11111 oflh.,cvnl_enl <1flhe memmy I, llH1 whu ad.on,.., u !!,'M!ll '11 Ii '""'1 L reg,.i.,,, an d U... aa,lm o l'd><! i
I I ~..... I
L---------~---------------------------------------------------------------------------J
In. il:h ~. imm.edii · . · dd _. ·in ~-mode. the t:ip,erand or tla: · ll'!i pre:· nt _ri.thit1. the iru·tr --· n . Lo.ad th ~.·imrru:.•d:i.c-
il:h ~'it'in · ti:ott . ·h · ·h ii; , · ' et!. i n. th it1_,;rtrl.Jl."o't ·i:on. E.xamp,'11e..:; of direct · dch- -!i. -il'I "' · ,re ~ -re,d il'I.
---------------r-------------------------------------------------------------------·
lnxlr ,m I Tad,
H 1 li fo ~i:1 D
---------------r-------------------------------------------------------------------·
L X r Ii, 5 L
I
Ii d L regi:oq1:m wiltJI050 Ii
1
---------------~-------------------------------------------------------------------
0[ H El witJi rti
1 ~I cu11U!lll l ! J i e ~ .(•
---------------r-------------------------------------------------------------------·
er r B
I
I C e lie oonlll!!rl f"llni!! rul Willi lie oml!!!!II. ( Reg:,
(I B
---------------~ ~-- ------------ ~-- --------
Th imm.ed·i.ate im lb:w im'S U'ie 'th • -:umullii.tm •sS an ·im: ·]ied operand. The f.M (m.o , ·i.mm.edi.iire ·
it1~'ittwho rt Cii.tl. mm it:s imrri.edii •·re da:tii! to an.· ofrthe ,.1 ,10.mm -,.
re •i'iter~'i. For exampl!e 'th itl'stru - .- n MVI D
Fm I1iM s 1:he h •d -ima] dii.tii! FFH to 1th D re ri:!irer. 0
Th.- LXJ ·in~fb:·uction. Oood re •i'i krr p.ai.r imm.ed.i.iite ll..~ _'i 16-bit imm.edi.iit - dii.tii!. Thi.'i i:rt.,t ru.rti:on. i.s.'i ,,enc-
1
t'rr:" Em ru.'lBd to l'o.ad • ddte,·s - in.to ii! r ri:...-ter -·· ir. T:n. LXJ H 8030H ·n · d H and L re · !.!:er pa.i.r ._ith. I -it
immedi.iit dii.tii! S030H .
WR
RD
cs
cs ms WR
11 R3
A1 10 R2
Address
Lines
Ao 01 R1
00 Ro
It in lud nl four r gist ·., and ach r ister can t re 8 bil . This hip can b r f rr d to
as a 4-b l r 32 (4 X 8 bit m 111ory chip. Tt ha tw ad Ir s lines, 0 an I 1, t identi fy
f ur r gi t r ·, 8 data lin . t . t r 8 bits, and thr timing or control signal.: R ad (RD).
Writ W , n I hiJ S lect - . )· all conlr 1 i(Tnals ,u- design d to b acti lo , indi at d
by bars over th mb I . Th· proc . . r an · l t this ch ip and identif it ~register, and st r
(Writ ) r ac . (R a I 8 bits at a time. Figur 2.2 ~ho\ sonly f ur r i l r~ lo simplify th
------A,,
Address
R/WM
Line
------tAo
Data
(a) Lines
----,A,,
Addre
Lines ROM
- - - - , Ao
Data
( ) in s
0000
ROM
Of ~
1000
Re rv d
F r
Expansi'->11
1 ~rr
2000 R/W
27 F
800
Jdtack
21- i: M roory
JOOO
FF
A1:'i - - - - - t
A1~ _ __.---...
D---
A1~--L-- MSB
A,:!:----1
3-to-8
Decoder
"" ----r--.....,
11,,
A 11 I>--- - -- I
A11
Ar~ -'I>-- , -
",--,.., I
¼~-- I
11,.-----· I
---,J l.16 11 i ,.
A, - - - -- I
1
. - . . - - - -- - - I
... ,
....
"·
.... I ,_,~ paid.A
"' 1
.
... ,
...,
....
1\ 1•• -et>-
A a - - -- - - cs RD WR
A, - - - - ----1
A r - - - -- -1
A•
A,
1
~
C
1 \ , - - --
A, - - - - -_J
A, _ _ _ ___ 1
A
A,,-- - - - - l -...J
5V
10/M
A,
RD
MSB A 11
A 14 3-to-8
Decoder 2732
A:J PROM
74LS138
A12 4096 X 8
Oo A1 ~ A1 1 A-i ~ A12 A11 A1t1 A"~ A1 A;, A~ A~ A~Ai A, A,1
I.I O l 0 0 0 0 0 0 0 0 0 0 0 0 0 = OOOOH
.J, !
Ao 0 I I I I I I I I I I I
0 0 0 I - 0 , -l-I
Oo I
.J..
7
Output
Lines
Doata___
Bus ___ ____,
°"'"
Lhc,
l} u,.
line are active. In thi circuit the Enable lines E I and E2 ar enabled by grounding, and
A 15 must be at lo ic l to enabl _. Wi will use this address decoding scheme to inter-
face a K EPROM and a 2K R/W 1ne1nory as illustrat d in th next two examples.
Au
() MSB
A14O 3-10-8
Au O Decoder
A11
On
Memory
Address
I · oFF H
A11
I
Au1 ~
I
~
As
1 It'
Cl./
A, I I 4096
I
I I 8-Bit
A6
A~
I ...u Memo y
I -,::,
Registers
A4 0
V
J
Ai
I Q
----r- 2732
Az
A1
Ao
I
caC:
...
4)
.§
EPROM
j
O(KK11-1
10/M
output Buffer
RD
Oulput
AD1 Lines
01
t Data Bus Oo
ADu
MSB
J-Lo•8
Decoder 6116
R/W Memory
74J.Sl38 MSEl.1
o, Ao 2048 X S
I Data
I .i11es
input/ utput d i ar th mean througl which the MP communicate with 'th out-
.de world.' Th MP ace pts bi nary data a input from d vices ucl a 1eyb t rd and
AID conv rt r and n<l: data to 1tp 1t devi u h as L D. or printer . Th r ar Lwo
differ nt m th d b hich I/0 d j e. can b id ntifi d: on uses an 8-bit addre and th
other us s a l 6-bit addr ·. hes m lhods ar des ribed bri fly in th followin ection .
In thi. Lype f 1/0 tl MPU uses i ht addre lines t id ntify an inr 1t or an output de-
ic · thi. i kn n p riph ral-mapped J/O ( ls lmo, n as I/0-1napped 1/0). Thi is an
8-bit nun1bering y t m for I/Os used in c nj rnction \J ith Input and Ou put in ru ti n .
hi. is al o kn wn a I/O spac . s parate fr n mem ry space which j a 16-bil nu,nb r-
ing sy t 111. The i ht address lin can have 256 (2 8 ombination addresses; thu the
P can i l ntify 256 i1 put devices and 256 output d vie s with addre e ranging fro1n
OOH t FFH. The input and output d i · s are differentiated by the ·ontrol si nal · he
MP u es th /0 Rea I onlr 1 ignal for input device nd tl I/O Writ control ign 1
f r output d vi s. h ntir ran f I/O addre es from 00 l FF is nown as an 1/0
n ap and inc.Ji i<lual addr . ·e are r f rr 'd to as /0 d vie addr s es or I/O port num er .
In this typ of 1/0. he MP use 6 add· lines to identify an T/O d vi ; an I/O i on-
n ct d a if it is a me1n ry regi ter. " hi i known as m mory-mapp d 1/0. The MP
th am control i nal (Metnory Read or Memory Writ and instruction c lho
m m ry. In me m1croproce or uch a the Motorola 6800, all 1/0 hav 16-bit ad-
t
o.
Bu
ta I ~l ·h
to .•
tc:h E11 ab l
0
L
1 1M iow
nal lJ e ·ic S le l uJs
In Figure 5.4, all eight address line,; are decoded to ~n'rnt · >11 • uniqu out ul pu lse ; th
device will be se le ted only wi1h ch• addr's ·. 0 I H. hi is t:alled absolute decoding and
j:,, ,1 oml d ·sign p1m.: tic •. Hm ·rr. to minimize Lhe co. t. 1he output I II c.1 11 b sclcl'l ·d
by <l • · ding some uJ the a<ldtess ti n s. as shown in ri )u ,c 1.5: tlii . 1s ulllc<l partial de-
coding. A. a re!iult, the de i1.:e IHI'. 111ulli t I· address ·s ( ·imtlar to fo ldba1.:k memory ml-
d11.!s:,,cs).
//
Q7 1<1.../\/v\r
--
IJ7 lJ7
D1
A2
I
A11
lJ IOSEL
Devi e Selecl rul~e
IOR
sv
~
A1
Dali.I T ._ tote
Bu~ Bulfc1
IOR
E1 E2 E,
EN
B J-10-8
A, - -
-=-
A; FJ\11
Ao F8H
//
l<l-¥1\r
D111n L:uch I.ED~
Bus + V
//
IOSEL
10\
15 V
s,
A1 D7 7-4LS244
A6
Oclal s6
As Bulfi:r Ss
°E 1 li2
s..
Data
MSB I S1
A2 A2 Bu.s
IOADR 0 S2
A,
Ao
A,
Ao
-10--8
oder
o,.
u Do
OE
0
0
s,
s
74LSI B
10/M
RD--Q._____J !OR
In Figure 5. 11 . t l1 l! ad<lrcss lin~s A~ anti A are 1101 us ·<l by lhe <lec.;ouing circuit: th lugk
levels on the e lin scan be O or I. Therefor . Lhi,; input port an a ce. sed by four dif-
ferent addresses, as shown he lm: .
A1 A6 5 A-1 A- A2 A, Ao
I 0 0 0 0 0 0 = 8411
l 8 H
0 =94H
= 9 II
ontr I Word
Po11 A
BSR Mode l/O Mode
( Bil SeUR sci)
!1255A
Cu
CL
Por1
For Pon +
Mode 0
i
Model
l
Mod 2
111 8 55A is a wide ly u · ·d. programmabl •. parallel 1/0 devi "'. 1L can be pr ,·, mm d to
tn. nsrer data und r va riou-. condi rions, from sim ple 1/0 to interrupt 1/0. It ic: n xi bl , ver-
sat ile. and ·onomical (v hen mll ltiple 1/0 ports m • ·4uired), hut . om what complex. Tt i,
an imponanl ge neral-rmrp sc l/ d vi chat an b used with almost any mi r pro· ·ssor.
The 8255A has 4 l/O pi n. that an be grouped primari ly in two 8-bit pm11U J po11 :
A a nd R, wi 1h th r mainin ·i ht bits as port . h e1gbt bi ts of p rt ·an u. eel as
individua l bit or t re 11 p <l in two ~-bit ports: C, IPPER u and CLOWER ( 1_), a · in
·igure 15.1 a . Th fu nction. ol the. r rl ar de fin ed by wri ting a control wo rd in th
conLrol n:gi$l •r,
· igur 15. 1(h) sh0\:.., a ll the funct io n:,; of lh 8255A, l, - ified a 01d ing tu two
mod s: the Bi t S •t/R 'set BSR m d rm I th 1/0 111 c. h • BSR m de is u ·d t ·et r
reset the bi ts ill purl . Th 1/0 mo e is fo rt h r divid d into three m d • ' : Mod 0, I
I anti .t,. ode ... In Mod 0. all ports functio,, as simple 1/0 p rt . Mode I i. a ha ud hak
mode hereby put ls A un<l/or B us bit from port C a ha nd ·hake sign I. . In the ha nd-
hake m tk, lwo types f 1/ data tra nsfer con I i1upl 'm nt d: statu heck and in ter-
rnp l. l1 Mode 2, 011 A can be sel up r I hiclil" ·1ional data tran . f r u-.ing hand. hake 1g-
11al-. from p It C a11d port B can I ' ~ct up eit her in orl 0 r d I.
PA.. l'o.,er { - .. sv
1,0
PA, s~ppltts - GND PA,-J>
PA. 1w
PA1 Wi!
Wft
RESET
Pon
Du A
D, 1,0
OJ E1'
D PC PC.
D,
o. >.,..Do
o,
o.
D, Bas
LO
1~
~
u~
. Purt
-c
.PC,-PCo
Vee Ill E1'
pa.,
PB 1m
iro
P81 WR-
WR
P8 4
A, A
PB l•'O A, C
An PBrPB 0
~a A., 8
Pi11N~
... 00
A 01
D RD /RcJtri): this ,·011trol signal e11:1hle, l!Je Ri:.it.l uperntmn, When tht:l ~iJ!nitl i~ low,
the_ MP re,1ds <l.it1l fro111 a ,dec1cd 1/0 p1 rt of the 8255A.
□ ,\'R t WrltcJ; 1lus control !'-ignal cm1blc,- the Wri1 0JJ1:fi1Uou. When th· signnl g1~~
lmv, lhc Ml'l r wl'ite~ into u 'iCIC'C'lNI 1/tl pt1r1 or the control , gh,1<-t
RF.SET Reset) : Thi s b un n'liv high si •nal; ii ch::ai-i. tlie cu11L1 o l 1e-gi&1c1 :mcl ,ec~ nll
~1~ i11the inpul mork,
D CS, Ao, and A 1: Thc1,e arc device !.elt!Cl i,ig11a l.s. CS i, cnn m,ic- 1.-1110 n decoded addres-..
and Ao ond A 1 :m: •enerally c~noecied lo Ml>U nddress Imel> A<J aml A,, rt:..,pec1ively
'Tbc CS :.i~1K1l is 1J1e rna:.ter ·11111 S .lccl, 1111d A0 ,rnd A I spi:cify one of th UO pom
or the cm1tml r1:g1ste1 a., g1vrn hclow:
(<ll (I>)
com 0LWORD
Figu re 15.2(b) llowi.. rrgi .. rrr called the coutml rc1-: ste1~ Tle c nlent;s ol this register,
call d the contn1I word, specify ll11 1/0 fom;1iou fOJ · ch p;xt Thi ~ reg,. lc:r can be m:-
ccs.<.erl lo writ e a cu111rul wo,\J wh II Au ancl A 1 arc 11 logic I, as mcnticmeu pn:viou~Jy.
The regi.-;lcr is 11ol aci.:ci-<.tblc I r il en I opcratmn.
Bit D 1 1 f th · ntrol rcgi .. tcr "pecifics eithe, thc l/0 rmctmn or lhe lllt Set/Rc:-;cl
funclion. :is. l:is.">tfied in Fi pun: 15. 1(bl. [f l>it D,. = I l>it D,,-0 11 cktcrminc 1/0 fll11c1i,J11s
in \'llnOU!i moues. as i.hu11,,u in figu, 15.. rr bi l IJ 7 - . port C opcr.ites in ,he Bil
Sc:1/Rei;et {BSR) utu<le Th BSR con lm l word oe!I. not affc:I lit • fm1c1i ri-. of por1~ A
,,nu B tJ1e BSR mode wi ll be described luter).
·1o com municate w1lh penpherah th1ougJ1 ti ~ S- 55A, 11·1= slc-ps are ncce,;sary:
1. Del ,mine 1hc .iciclrc.~~ of p,>rt" A, B. 1111tl llBU of lh n n1 ml rcg1sIer ncC(lrdm!l, to
the Chip Select lo•ic 1111d oodres:,. line:,. 1\4, and A 1•
2. Wri te a cont,•ol wmd in th cotttrol reg 1<:1cr.
J. W, ite 1/0 inslnt ·tion, o com11111nrc □te with pcriµ ht!rnls 1J11uugll µ , ts A. R. :ind .
In llJL mode. p<Jrts. A llnd B 1trc used a,; two irnple 1:1 bit 1/0 ports 11nd port f' us lwu 4-
bil [)111"I. . Elllch port (or lta lf-pu11, in C:il:le or ) c:m be programmed lo fu11c tio11 rn, :..imply
an input port or an o ulput po11. The input/output fealure~ 111 Mud!! 0 .J.1'e il~ fo llows:
[!, I n. n, I D, I Di ] D, I 0 , ! 0o I
'-
/ Gn,,1p til
'\
I l'ort <: (Lot,-.,r
O
t ~ I l
= Outpu,
PC",l'C(>J
PPJ1 13
I - lf1pm
0 - Uui,>llt
Mooe Seleclion
0 - Mu<le 0
I = Modt I
/ Clrour A
\
,~,
l'l'lrt C' Wrp«-f'Cr J'C◄ l
I
D = O\Jtput
rnstA
I - l11pul
Cl - Oldpuc
"1~Seltt1W11
00 • Mod<: 0
01 - Mode I
IX - Mrnle l
I :: IIO ode
0 - SSR Moote
The BSR 111odc i:,; c:c,nc:csncd o nly with lhc ei3h1 hi!~ of port C. whid, c.ambe ~cl or re.sel
by writ ing ,m apprnpnale c:rnHm l wot'd in Iht: rnnlml rcgi1>1er. A conL1'0J wurcl with Ml D 7
= 0 is rccog11 izetl as a BSR ct1n11ro l word, and it does .nol altc.- any pr viously i.1•a n~milt~cl
rn11 lrnl word wuh bit D 1 = I; thus 1he J/0 c,pcrnHons o r port~ A :;incl 11 81-C not atl'ectetl l.ty
a BSR l"01LL1\J I wcml. Tn lhe BSR mode. i11di 11idL111l bils ot' po11 C o;; ,111 b~ used fo r ~Pl)lica-
1irn,s :1,1.1.ch as a n unlufl' ~w i1ch.
o, o. [l, o. u, o, o, 0.,
0 .x )i X llit Srlr
llSR Mndc
Nni I l<cd ,
C.cnrmll)' r l = 0
000 - lli1 n
001 - llil I
1110 011 2
llll - !Iii I
100 = Di,
IOI = 811 ~
I 111 !111 6
111 - 11,11
This mod i~ u~rf primari ly iu ap1>lica1ion~ ~uch as data trnn~f'c r hccwcen 1\\10 co111pul 'r.,;
m nOJ)l>Y rli<;k controller inuufacc . In ch,~ mode:, J)Olt A an be conligureu a 1hr. birfircc-
tiorml ()Or1 111i<l p n B eilh r in ode Om Mocf I . Port A U!,CS live ign.11~ from port C
,~ hantbhak~ sign.iii- rQf' dat 1 tram.rei. Th rcmmnmg thrc . ignnl~ from port C con be
w,ed either n,; implc 1/0 0 1 haod~hakc lcr port B FiguJ'c I 'i. 14 shows tw conti g11ro-
lion~ of Morlc 2. Titil> mode is illustrnted III Section I 'i .3
1. nrnnage i l int rrupt rding L the instructions writt n into its con trol re i ter .
hi j equivalent to providin i ht int rrupt pin on the processor in pla of ne
INTR (8085 pin.
2. ve t ran int rrupt reque t anywh r in th mem ry map. IIowev r all eight int rrupt
arc spaced al the int rval of ith r four or ei ht location . t j eliminat ll nrnjor
dr, wbac of th 8085 int rrupt in which all interrupt r v ctored l m 1n ry lo a-
ti ns on pa c OOH.
3. r ol eight I ,Js of int rru t prioriti in a vari ty f n de u h s fully n t d
1 o , aut mati · rotation mod . and pecific rota ion 1110d (to e xpl ir d lat r .
4. 1 a ·k ·ach int rrupt rcqu st individually.
5. r ad th tatu · of pcn<lin interrupts in- en i interrupt an I ma eel int rntpt .
6. b set up t ace pl ith r th I vel- rig re I r th edge-trigg red it t n'ltpl r ue t.
7. b expand <l lo 6 priority levels by ca cadin ad itional 8259A .
8. be et u1 work with either ti 8085 1 icr pr 'cs · r mod or h 8086/8088 micro-
proce ·m d .
CONTROL LOGIC
This bl · has two pins: INT Tnl rrupl) nn outpllt, and TNT A (In t rnipl Acknowlcd :.c
.i:
as an input. The INT is onnected to lhe interru t pin of the MP . Whenever a valid in-
terrupt i. sse,·1ed, this si 11 1 ooes hi h. The 1NT A is the Tnte1n1pt Acknowledge signal
fr )111 th MPU.
CASCADE BUFFER/COMPARATOR
·1his blo ·k is used Lo expand the m11n r uf interrupt level · by t;a~ ·ading l w or m01
8_59A1,. To .simp lify the discuss ion, thi s block will not be me ntioned again.
Ma11 1 lYJ s of pri rily mod s a1• a 1aila le uncJ r so ftwtu- control in the 8259A. and 1hey
can ·hang ti tlynamically during the progra 1 hy writin appmprial c mmnnd word ..
Commonly used priority mode ore dis u., cd bel w.
1. FuJJ. Nested Mod 1l1is i. a general-purpos · morJ · in which all lRs lnl rrupl Re-
ue. I a, a1 n°ed fr m hi 0 h · ·L to lowest, with ll~ as the highest and 1R 7 as lhe low-
t.
In addition. any JR an be as. i nec:1 1he hi ,..h t priorit in Lhi mod ; th priorily
<;equence ill the, h ,in al that TR Ju th · c-xampl hel w, IR 4 ha 1he hi h . ·t priority, and
TR I ha · th low 'SI prio1i Ly:
+
Low •sL Jigh st
pnorily priori Ly
2. uto1 at'c Rot:ltio l Mo e ln thi s mode. a devi e, al ter bei ng servi ed, receives lh
lm: e Lprioril ,. suming that the IR::i has just hee11 scr ic.:ed, it wil l r ·cciv1,; th
pn rit '. as shown low:
IRu IR 1 I lR lR,, 1
I 6 0 I 1 4
3. Spedfic Rotation Mode Thi 11ode · imilar to the autornahc rotation mode, except
that the ruser can seJect any IR for lhc [ west priority, thu xi 1g aU othe r p1fo1·ities.
Ay.--------
A.-----
At-----
B, lia B,
A, MIB !-to-I
A.1 - - Dlaader
A, ·o.-------.....el.
74LSIJI ---At
The 8254 progra1n1nable jnt rval timer/counter is functionally similar to the software-
design d counters and tim rs described in Chapt 8. It generates accurate time delays
and can be used for applications u h as a ·eal-time clock ar even coun er a digital ne-
shot a squa · -wave generator, and a complex waveform enerator.
Th 8254 in ludes tlu- id ntical 16-bit counte ·s that can ope ·ate independently in
any one of the ix 111odes to be described later). It is packaged in a 24-pin DIP and re-
quires a single +5 V power supply. To operate a counter, a 16-bit count is loaded in its
regi t r and, on o n and, begin to de rement the count until it reaches 0. At the end of
the count it generates a puls that can b used to intenupt th MPU. The counter can
cou1 t eitl r in binary o · BCD. In addition, a count can be read by the MPU while the
ounl r i. · d crementing.
Th 8 54 is an up raded version of the 8253 , and they are pin-compatib e. The fea-
tures of thes two d vi are aln1osl identical excep ha
D1
Oa111 -----CLK 0
Dt1 oun1er ____ GATE 0
Ds Bus
Buffer
=O
04 --► OUT 0
D,
D2
D,
Do iffi
CLK 0 Readf
LK I
OUT0
WR Counter
Writ GATE I
GATE0 = I
~ Logic
GND OUT I
A,
Pin Names
CONTROL LOG C
The control. ect1011 hn. fiv signals: till (Read), WR (Write) CS (Chip Select), and the acl-
d re s li n ·s Ao, ud A 1• In th periphel'al TIO mod , the RD and WR signa ls are conn ctcd
to IOR and 10 . re. pectively. rn m moiy-mapped 1/0, these ar connecl cl to ME R
(Me mory Read and M MW Memory Write). Address lin 'S A11 and A 1 of the MPV are
usually co,mected lo lines A0 and A 1 of the 8254, and S is Lied to a decoded addre .
he c;ontrol word registe, a,1d counters are selected according to lh ,.. signal on lines
A 11 and A 1, as sho\ 11 be l w:
A1 ~I Selection
0 0 Cou 11 tcr 0
0 l ountcr 1
I 0 Co unter 2
I Control Re isle
Note: Don'1 re Bia (X) Shou ld I3e Oto Ensu Compatability with uture Intel Products.
ca n be u. ed as ar1 int n 1pt. h O U f remains hi h until a new coun1 0 1 a com mand, 'Ord
i · load d. igur 15.27 al h ws thaLthe c un li1 (1 1 =. ) is temporarily stoppe when
Lh a te is disa I d (G = 0 , and con tnnt d • fiai when the Oat is at logic I.
MODE 1: HARDWARE-RETRlG
In Lhi. mode. th • OUT is in itially hi 1:ll i tri g r , th goe · low,
and at the e nd of the count, the OU , · high a •ain, th us •enerating a on -shot pul.
(Figure I - .27, M cl~ I).
[ow fol' one clock period. The count is r ]oadcd au tom lica]Jy. aind the lu l~e .is genernted
,co t.ir1u ously. Tihe cou nt = I. is i!. legal in this mode.
C luckI !
WR n ~ WltJl-i___.r-
lock Clock
Wttn Output n - 4}
Output
Output 11 = 5) --
Ou1p11t (n 3)
RESET - i..._ __,
Clock
n =4
WR:~ ate
Out1ut~ 0\llput (n 4)
Load 11 n = 4 _r-u
~ Gate:
G,11e Output (11 = 4) 4 3 4 3 2
Output 2 I 0
MO E 4: SOITWARE-TRIGGERED STROB
In lhis mode. the OUT is initially high· it lo\! for ne c.:Jock period at the end of the
unl. The count musl e rel adc<l for sub~ quent out:>uts.
READ-BACK COMMAND
The Read-Back Command in rhe 8 4 llow · th user tor ad the count and the status of
the cou nt ; thi corrunand is not available in the 8253. he fol'mat f the corn, 1 nd i,
shown in igure 15.28(a).
The comm and is wrinen in th control I' gist r, and th count of the specifi d
ounter s) an h latched if COUNT (bit D5) is 0. A counter or a combination of ounters
i p cified by k eping the respective CNT bit'> (0 1 D 2 , and D3) I i b. or amp! , lhc
control word 1 l O I 0 1 I O D6H wdtten in the c ntrol r ·gist r will latch the cou nts of
Coun tel' 0 and Count r l, and th · counts ·an be obtained by reading respective counter
WR
RD
cs
cs ms WR
11 R3
A1 10 R2
Address
Lines
Ao 01 R1
00 Ro
It in lud nl four r gist ·., and ach r ister can t re 8 bil . This hip can b r f rr d to
as a 4-b l r 32 (4 X 8 bit m 111ory chip. Tt ha tw ad Ir s lines, 0 an I 1, t identi fy
f ur r gi t r ·, 8 data lin . t . t r 8 bits, and thr timing or control signal.: R ad (RD).
Writ W , n I hiJ S lect - . )· all conlr 1 i(Tnals ,u- design d to b acti lo , indi at d
by bars over th mb I . Th· proc . . r an · l t this ch ip and identif it ~register, and st r
(Writ ) r ac . (R a I 8 bits at a time. Figur 2.2 ~ho\ sonly f ur r i l r~ lo simplify th
------A,,
Address
R/WM
Line
------tAo
Data
(a) Lines
----,A,,
Addre
Lines ROM
- - - - , Ao
Data
( ) in s
0000
ROM
Of ~
1000
Re rv d
F r
Expansi'->11
1 ~rr
2000 R/W
27 F
800
Jdtack
21- i: M roory
JOOO
FF
A1:'i - - - - - t
A1~ _ __.---...
D---
A1~--L-- MSB
A,:!:----1
3-to-8
Decoder
"" ----r--.....,
11,,
A 11 I>--- - -- I
A11
Ar~ -'I>-- , -
",--,.., I
¼~-- I
11,.-----· I
---,J l.16 11 i ,.
A, - - - -- I
1
. - . . - - - -- - - I
... ,
....
"·
.... I ,_,~ paid.A
"' 1
.
... ,
...,
....
1\ 1•• -et>-
A a - - -- - - cs RD WR
A, - - - - ----1
A r - - - -- -1
A•
A,
1
~
C
1 \ , - - --
A, - - - - -_J
A, _ _ _ ___ 1
A
A,,-- - - - - l -...J
5V
10/M
A,
RD
MSB A 11
A 14 3-to-8
Decoder 2732
A:J PROM
74LS138
A12 4096 X 8
Oo A1 ~ A1 1 A-i ~ A12 A11 A1t1 A"~ A1 A;, A~ A~ A~Ai A, A,1
I.I O l 0 0 0 0 0 0 0 0 0 0 0 0 0 = OOOOH
.J, !
Ao 0 I I I I I I I I I I I
0 0 0 I - 0 , -l-I
Oo I
.J..
7
Output
Lines
Doata___
Bus ___ ____,
°"'"
Lhc,
l} u,.
line are active. In thi circuit the Enable lines E I and E2 ar enabled by grounding, and
A 15 must be at lo ic l to enabl _. Wi will use this address decoding scheme to inter-
face a K EPROM and a 2K R/W 1ne1nory as illustrat d in th next two examples.
Au
() MSB
A14O 3-10-8
Au O Decoder
A11
On
Memory
Address
I · oFF H
A11
I
Au1 ~
I
~
As
1 It'
Cl./
A, I I 4096
I
I I 8-Bit
A6
A~
I ...u Memo y
I -,::,
Registers
A4 0
V
J
Ai
I Q
----r- 2732
Az
A1
Ao
I
caC:
...
4)
.§
EPROM
j
O(KK11-1
10/M
output Buffer
RD
Oulput
AD1 Lines
01
t Data Bus Oo
ADu
MSB
J-Lo•8
Decoder 6116
R/W Memory
74J.Sl38 MSEl.1
o, Ao 2048 X S
I Data
I .i11es
input/ utput d i ar th mean througl which the MP communicate with 'th out-
.de world.' Th MP ace pts bi nary data a input from d vices ucl a 1eyb t rd and
AID conv rt r and n<l: data to 1tp 1t devi u h as L D. or printer . Th r ar Lwo
differ nt m th d b hich I/0 d j e. can b id ntifi d: on uses an 8-bit addre and th
other us s a l 6-bit addr ·. hes m lhods ar des ribed bri fly in th followin ection .
In thi. Lype f 1/0 tl MPU uses i ht addre lines t id ntify an inr 1t or an output de-
ic · thi. i kn n p riph ral-mapped J/O ( ls lmo, n as I/0-1napped 1/0). Thi is an
8-bit nun1bering y t m for I/Os used in c nj rnction \J ith Input and Ou put in ru ti n .
hi. is al o kn wn a I/O spac . s parate fr n mem ry space which j a 16-bil nu,nb r-
ing sy t 111. The i ht address lin can have 256 (2 8 ombination addresses; thu the
P can i l ntify 256 i1 put devices and 256 output d vie s with addre e ranging fro1n
OOH t FFH. The input and output d i · s are differentiated by the ·ontrol si nal · he
MP u es th /0 Rea I onlr 1 ignal for input device nd tl I/O Writ control ign 1
f r output d vi s. h ntir ran f I/O addre es from 00 l FF is nown as an 1/0
n ap and inc.Ji i<lual addr . ·e are r f rr 'd to as /0 d vie addr s es or I/O port num er .
In this typ of 1/0. he MP use 6 add· lines to identify an T/O d vi ; an I/O i on-
n ct d a if it is a me1n ry regi ter. " hi i known as m mory-mapp d 1/0. The MP
th am control i nal (Metnory Read or Memory Writ and instruction c lho
m m ry. In me m1croproce or uch a the Motorola 6800, all 1/0 hav 16-bit ad-
t
o.
Bu
ta I ~l ·h
to .•
tc:h E11 ab l
0
L
1 1M iow
nal lJ e ·ic S le l uJs
In Figure 5.4, all eight address line,; are decoded to ~n'rnt · >11 • uniqu out ul pu lse ; th
device will be se le ted only wi1h ch• addr's ·. 0 I H. hi is t:alled absolute decoding and
j:,, ,1 oml d ·sign p1m.: tic •. Hm ·rr. to minimize Lhe co. t. 1he output I II c.1 11 b sclcl'l ·d
by <l • · ding some uJ the a<ldtess ti n s. as shown in ri )u ,c 1.5: tlii . 1s ulllc<l partial de-
coding. A. a re!iult, the de i1.:e IHI'. 111ulli t I· address ·s ( ·imtlar to fo ldba1.:k memory ml-
d11.!s:,,cs).
//
Q7 1<1.../\/v\r
--
IJ7 lJ7
D1
A2
I
A11
lJ IOSEL
Devi e Selecl rul~e
IOR
sv
~
A1
Dali.I T ._ tote
Bu~ Bulfc1
IOR
E1 E2 E,
EN
B J-10-8
A, - -
-=-
A; FJ\11
Ao F8H
//
l<l-¥1\r
D111n L:uch I.ED~
Bus + V
//
IOSEL
10\
15 V
s,
A1 D7 7-4LS244
A6
Oclal s6
As Bulfi:r Ss
°E 1 li2
s..
Data
MSB I S1
A2 A2 Bu.s
IOADR 0 S2
A,
Ao
A,
Ao
-10--8
oder
o,.
u Do
OE
0
0
s,
s
74LSI B
10/M
RD--Q._____J !OR
In Figure 5. 11 . t l1 l! ad<lrcss lin~s A~ anti A are 1101 us ·<l by lhe <lec.;ouing circuit: th lugk
levels on the e lin scan be O or I. Therefor . Lhi,; input port an a ce. sed by four dif-
ferent addresses, as shown he lm: .
A1 A6 5 A-1 A- A2 A, Ao
I 0 0 0 0 0 0 = 8411
l 8 H
0 =94H
= 9 II
1. nrnnage i l int rrupt rding L the instructions writt n into its con trol re i ter .
hi j equivalent to providin i ht int rrupt pin on the processor in pla of ne
INTR (8085 pin.
2. ve t ran int rrupt reque t anywh r in th mem ry map. IIowev r all eight int rrupt
arc spaced al the int rval of ith r four or ei ht location . t j eliminat ll nrnjor
dr, wbac of th 8085 int rrupt in which all interrupt r v ctored l m 1n ry lo a-
ti ns on pa c OOH.
3. r ol eight I ,Js of int rru t prioriti in a vari ty f n de u h s fully n t d
1 o , aut mati · rotation mod . and pecific rota ion 1110d (to e xpl ir d lat r .
4. 1 a ·k ·ach int rrupt rcqu st individually.
5. r ad th tatu · of pcn<lin interrupts in- en i interrupt an I ma eel int rntpt .
6. b set up t ace pl ith r th I vel- rig re I r th edge-trigg red it t n'ltpl r ue t.
7. b expand <l lo 6 priority levels by ca cadin ad itional 8259A .
8. be et u1 work with either ti 8085 1 icr pr 'cs · r mod or h 8086/8088 micro-
proce ·m d .
CONTROL LOGIC
This bl · has two pins: INT Tnl rrupl) nn outpllt, and TNT A (In t rnipl Acknowlcd :.c
.i:
as an input. The INT is onnected to lhe interru t pin of the MP . Whenever a valid in-
terrupt i. sse,·1ed, this si 11 1 ooes hi h. The 1NT A is the Tnte1n1pt Acknowledge signal
fr )111 th MPU.
CASCADE BUFFER/COMPARATOR
·1his blo ·k is used Lo expand the m11n r uf interrupt level · by t;a~ ·ading l w or m01
8_59A1,. To .simp lify the discuss ion, thi s block will not be me ntioned again.
Ma11 1 lYJ s of pri rily mod s a1• a 1aila le uncJ r so ftwtu- control in the 8259A. and 1hey
can ·hang ti tlynamically during the progra 1 hy writin appmprial c mmnnd word ..
Commonly used priority mode ore dis u., cd bel w.
1. FuJJ. Nested Mod 1l1is i. a general-purpos · morJ · in which all lRs lnl rrupl Re-
ue. I a, a1 n°ed fr m hi 0 h · ·L to lowest, with ll~ as the highest and 1R 7 as lhe low-
t.
In addition. any JR an be as. i nec:1 1he hi ,..h t priorit in Lhi mod ; th priorily
<;equence ill the, h ,in al that TR Ju th · c-xampl hel w, IR 4 ha 1he hi h . ·t priority, and
TR I ha · th low 'SI prio1i Ly:
+
Low •sL Jigh st
pnorily priori Ly
2. uto1 at'c Rot:ltio l Mo e ln thi s mode. a devi e, al ter bei ng servi ed, receives lh
lm: e Lprioril ,. suming that the IR::i has just hee11 scr ic.:ed, it wil l r ·cciv1,; th
pn rit '. as shown low:
IRu IR 1 I lR lR,, 1
I 6 0 I 1 4
3. Spedfic Rotation Mode Thi 11ode · imilar to the autornahc rotation mode, except
that the ruser can seJect any IR for lhc [ west priority, thu xi 1g aU othe r p1fo1·ities.
Ay.--------
A.-----
At-----
B, lia B,
A, MIB !-to-I
A.1 - - Dlaader
A, ·o.-------.....el.
74LSIJI ---At
The 8254 progra1n1nable jnt rval timer/counter is functionally similar to the software-
design d counters and tim rs described in Chapt 8. It generates accurate time delays
and can be used for applications u h as a ·eal-time clock ar even coun er a digital ne-
shot a squa · -wave generator, and a complex waveform enerator.
Th 8254 in ludes tlu- id ntical 16-bit counte ·s that can ope ·ate independently in
any one of the ix 111odes to be described later). It is packaged in a 24-pin DIP and re-
quires a single +5 V power supply. To operate a counter, a 16-bit count is loaded in its
regi t r and, on o n and, begin to de rement the count until it reaches 0. At the end of
the count it generates a puls that can b used to intenupt th MPU. The counter can
cou1 t eitl r in binary o · BCD. In addition, a count can be read by the MPU while the
ounl r i. · d crementing.
Th 8 54 is an up raded version of the 8253 , and they are pin-compatib e. The fea-
tures of thes two d vi are aln1osl identical excep ha
D1
Oa111 -----CLK 0
Dt1 oun1er ____ GATE 0
Ds Bus
Buffer
=O
04 --► OUT 0
D,
D2
D,
Do iffi
CLK 0 Readf
LK I
OUT0
WR Counter
Writ GATE I
GATE0 = I
~ Logic
GND OUT I
A,
Pin Names
CONTROL LOG C
The control. ect1011 hn. fiv signals: till (Read), WR (Write) CS (Chip Select), and the acl-
d re s li n ·s Ao, ud A 1• In th periphel'al TIO mod , the RD and WR signa ls are conn ctcd
to IOR and 10 . re. pectively. rn m moiy-mapped 1/0, these ar connecl cl to ME R
(Me mory Read and M MW Memory Write). Address lin 'S A11 and A 1 of the MPV are
usually co,mected lo lines A0 and A 1 of the 8254, and S is Lied to a decoded addre .
he c;ontrol word registe, a,1d counters are selected according to lh ,.. signal on lines
A 11 and A 1, as sho\ 11 be l w:
A1 ~I Selection
0 0 Cou 11 tcr 0
0 l ountcr 1
I 0 Co unter 2
I Control Re isle
Note: Don'1 re Bia (X) Shou ld I3e Oto Ensu Compatability with uture Intel Products.
ca n be u. ed as ar1 int n 1pt. h O U f remains hi h until a new coun1 0 1 a com mand, 'Ord
i · load d. igur 15.27 al h ws thaLthe c un li1 (1 1 =. ) is temporarily stoppe when
Lh a te is disa I d (G = 0 , and con tnnt d • fiai when the Oat is at logic I.
MODE 1: HARDWARE-RETRlG
In Lhi. mode. th • OUT is in itially hi 1:ll i tri g r , th goe · low,
and at the e nd of the count, the OU , · high a •ain, th us •enerating a on -shot pul.
(Figure I - .27, M cl~ I).
[ow fol' one clock period. The count is r ]oadcd au tom lica]Jy. aind the lu l~e .is genernted
,co t.ir1u ously. Tihe cou nt = I. is i!. legal in this mode.
C luckI !
WR n ~ WltJl-i___.r-
lock Clock
Wttn Output n - 4}
Output
Output 11 = 5) --
Ou1p11t (n 3)
RESET - i..._ __,
Clock
n =4
WR:~ ate
Out1ut~ 0\llput (n 4)
Load 11 n = 4 _r-u
~ Gate:
G,11e Output (11 = 4) 4 3 4 3 2
Output 2 I 0
MO E 4: SOITWARE-TRIGGERED STROB
In lhis mode. the OUT is initially high· it lo\! for ne c.:Jock period at the end of the
unl. The count musl e rel adc<l for sub~ quent out:>uts.
READ-BACK COMMAND
The Read-Back Command in rhe 8 4 llow · th user tor ad the count and the status of
the cou nt ; thi corrunand is not available in the 8253. he fol'mat f the corn, 1 nd i,
shown in igure 15.28(a).
The comm and is wrinen in th control I' gist r, and th count of the specifi d
ounter s) an h latched if COUNT (bit D5) is 0. A counter or a combination of ounters
i p cified by k eping the respective CNT bit'> (0 1 D 2 , and D3) I i b. or amp! , lhc
control word 1 l O I 0 1 I O D6H wdtten in the c ntrol r ·gist r will latch the cou nts of
Coun tel' 0 and Count r l, and th · counts ·an be obtained by reading respective counter
•
I
I, I, ■ ■ .... .I lo
lliill'!li.iil!'w.
I, ■ ■ .I .I .. I,
I N
I, ■ ■ ■ .I .I I
l tq
~ ~'=
I
L ___________ JI
The Bus Interface Unit (BIU) consists of bus interface logic, general-purpose registers, segment
registers, stack pointer, base pointer and index registers, memory addressing logic and a 6-byte
instruction queue. The BIU carries out all bus operations for the Execution Unit, and it is
responsible for executing all external bus cycles.
The BIU performs data and addresses transfer between the processor and memory or I/O devices.
This section computes and sends addresses, fetches instruction codes, stores fetched instruction
codes in a First- In-First-Out (FIFO) register which is called a queue. The BIU is also used to read
data from memory and I/O devices, and write data to memory and I/O devices. While the EU is
busy in instruction execution, the BIU continues to fetch instructions from memory and stores
them in the instruction queue. This unit relocates addresses of operands while it gets unrelocated
operand addresses from EU. The execution unit tells BIU from where to fetch instructions as well
as from where to read data.When the EU executes an instruction the BIU resets the queue, fetches
the next instruction from the new memory location, and passes the instructions to the EU. In this
way, the 8086 BIU fills the queue when the queue becomes empty spaces of two bytes. This
process is known as pipeline flush.
The Execution Unit (EU) consists of Arithmetic Logic Unit (ALU), general-purpose registers, flag
register (FLAGS), instruction decoder, pointers and index registers, and the control unit which are
required to execute an instruction. The EU gets the opcode of an instruction from the instruction
queue. Then the EU decodes and executes it. The BIU and EU operate independently. When the
EU is decoding or executing an instruction, the BIU fetches instruction codes from the memory
and stores them in the queue. This type of overlapped operation of the BIU and EU functional
units of a microprocessor is called pipelining. This process becomes faster except for Jump and
Call instructions as the queue must be dumped and then reloaded from a new address. Hence,
the function of the EU is to execute all instructions, provide address to the BIU for fetching
opcodes and operands and perform ALU operations after using various registers as well as the flag
register.
During fetch and execute of instructions in the 8085 microprocessor, the nonpipeline concept
follows so that instructions are fetched and execute sequentially as shown in Fig. 5.2(a). In the
8086 processor, the BIU and EU perform the fetch and execute operations with overlap.
The 8086 CPU has fourteen 16-bit registers as depicted in Fig. 5.4. All these registers are
subdivided into different groups, namely, Data Register Group (four registers), Segment Register
Group (four registers), Pointer and Index Register Group (four registers), Instruction Register
(Program Counter) and Flag Register. In this section all registers are discussed.
~------------cx---------------t-----------C-H------------1------------CL--------------~
~-----------------------------►--------------------------T----------------------------~
I DX DH
I DL I I
·-----------------------------~--------------------------·----------------------------·
Th fimctions of ·ach data r ·gist ·r ar · discuss d as foJlm s:
AX Registe·r Th·
gist 'lf s r s as an a· ·umula or. H p rforms irrpu output p n: .t i ns i: nd
lf
pro ~ ss s d,ita through r · H or L. During x "cution of a 16-bit multipl and di id" ins1tn1 ·hon,
·ontains h on -\ ord p rand and th r suit is s or d in th · a· ·umula .,r. In , '-bit multipl "nd di id
instru ·tions is us d o hold h lo\ r -ord .•r \ ord op ·rand. filnstru ·tions in ol ing or · H or L ·an
l ad dah imm ·di~d 1 and h n · " data usuall r quir I ss pr gmrn m nmry.
CX Reg1ster r gist ·r ·an b · us d as c: . ount f gist ~r for string op ·rati ns and holds ;; · unt
alu " during hug · numb r it rations. n LOO . instru ·tions holds th· d "sir d numb r of r p itions
rnd is • u -mati ·all d "cr "n nt ·d b on " a tt "r ·rch it ·ration. Whil" b ·om "s z ro th· " · ·ution of
instru ·tions sh uld b t rmimt d. fu th · sam ay th -bit L r gist ·r is us d as t ·ount r gist r in bi -
shifting and ro a · instn1 ·ti - ns.
15 0
15 87 0 SP Stack Po inter
AX AH AL Aocumu ator BP Base Po"nter
BX BH BL Base SI Sou roe Index
ex CH CL Gaunter DI Desf nation I ndlex
DX DH DL Data IP Instruction Pointer
(a) (b)
15 0
ES Extra Segment
-----1
cs Code Segment
-----;
(c) (d)
Segment Memory
Segme,nt Register
BIFIFFFIH
64 KB 8000H
80000H Code Segment
6F FFFIH
64 KB 6000H
60000H Data Segment
3F IFFFIH
64 KB 3000H
30000H Stack Segment
1IFIFIFFIH
64 KB 1000H
10000H L---___..L..__-------l- Extra Segment
00000H ·1 j
Dr. Anwar Sadat, Electronics Engineering
5
Department, A M U Aligarh.
Seg1
ment IRe·gist ers
Sour,ce Index (St) and Destination Index (DI} These re · ters are u...ed in mem ry , r
tack-addre . c, mputation r eneral data . t rage_ The main purpo . ,e the ere i ter i t t re .. ,et r
di.placement ]n mem ry addres. computation, tire o ntent o. data se. ment and index re L ter dependin
up n addres. in mode . _
1
metime is used a . . urce index and rn ru destinati , n index_ ] tire o ntent
1
] i added with the
1
c ntent , D t, detem1ine tire phy . ical addre .. , it will be used as .· urce addres. data_ Whi l,e the c, ntent
f D] i added with the c ntent t . md tire destinati n add:re s . the data, these reg isters can a l e
u, eda. eneral purp . ere i. ter _
Instruction Pointer (IP) Oerrerally, the instruction p inter re. Lter i. ruedm a pmgram counter_
mem ry add11 . ses , instructi, 11. ,vhkh wi II be execute,d_ Thi. re ister
st res the .. set ., r the imtructi n_ Thee ntent , IP i aut matically incremented while the executi n . an
in. truction i. oin n_ The addre. s , the next in . tructi n i. computed a . er addi n. ]P ntent t the code
. •e ment re ·ster o ntents a. ,er 4-bit left-. hift_
G ND vcc
A D,4 2 A D,5
A D,a 3 A ,i Sa
A D 12 4 A.,.,JS4
A D,, 5 A.,J Ss
A D,0 i6 A ,J S6
A Dg 7 34 BHEJ~
A D8 8 33 M /MX
A D1 9 32 RD
A D0 10 31 RQ/GT O HOlD
8'08'6
A D5 11 30 RQ/GT 1 H l DA
A D4 1.2 29 l ook WR
A D3 13 28 &i MAO
Minimum
A D2 14 27 s, Max imum
moo,e DTIR mode
A D,
15 26 so DEN
A DO
rn 25 QSO
AL E
NMI
17 24 Qs,
18 23 INTA
INTR TEST
Cl K 19 22 READY
G ND 20 21 RESET
A19- A16 (Output) These are hi h~ rder addre line and they are time-multiplexed line .. During
T1, these Iines can be ru ,ed a. hi. her rder bit. ·. memory addres. . But in 1/0 perati n, these line. are I, ,v.
Durin T2, T3 , and T4 , they carry ..tatus .. i nals.
A,JS3, A,.,,ts,, (Output) . 16 and naretime multiple. ed with se ment identi. 1er si nal J and L
' 4.Dorin . T1 dock cycle, 16 and n are used a . addres. bit . ~n T2 t T4 clock cycles, these Ii nes carry . tatus
. ignaL. Ta l,e -_ · h ~ mem ry se0 ment identi11cati, 11.
-
r---------,-----------r--------------------------------~
~
1 L\'4 1 S3
~---- 0 ---1----() -----r---- .
1 F1m tim,
·xt.ra sq~ncnt mc mO!)' a 'l't.'SS - - - - -i
~---------,-----------r--------------------------------~
1
A1/S6 (Output) 19 i. multiplexed ,vith the . tatus . i nal ' 6 _ Dunno T 1 cl ck cycle . 9 i.
tran.mitted t an addre . . bu... Ourin T, t T4 the talus si nal 6 is availabl ,e n this line. :It i. lmv durin
L
f2 t 14-
BHEIS7 (Output:) Bus High Enoble/St,atus Dorin T• the bus hi,gh enable . i naJ BHE can
be used t enable data nt the mo ..t . i ni11ca.11t ha.I the data bu.. D 1r '8 . n , -bit de,~c.e c nnected t
the upper hal the data bus u. es a BHE . ignal t conditi n chip .ele<:t functi ns. BHE L I w durin T1 r
re.ad write and interrupt ackn wle,d e cycle. when a byte i. t tran . erred , n the hi h p rtion I the bus_
Thi . pin i. muhip le . ed with the . tatus . i nal 7 . The 7 status . i nal is avai la.bl e durin f 2 t T4 . The . i nal
L
i. active I w, and fl aL t 3- tate OFF in h l,d U i. I w during T1 . r the first interrupt ackn wled e cycle_
Table .6 . h w. the function BHE and 0
l•--
__
IJ.HE
--r----------,----------------------------------•
l A'-1 : Frm lim1 l
~---- 0 ----+-___ 0 __ --~---- \Vhol · word __________________ --~
•---------·----------,----------------------------------~
1 0 • l l Uppi:r byt · from/ Lo odd adc.lri:ss 1
•---------~----------,----------------------------------~
~---- l ----t-___ 0 __ --~---- Lo\\' ·r byt · fmm /to :'\'en address ___ --~
I l I l 1 011 • I
~---------L----------J----------------------------------~
READ Y (Input)
1
The addressed J/O r memory devic.e . send acknowledgment thmugh thi. pin and
it indicate that the data trans. er is o mpleted. The RE D . i nal r m mem ry r 1/ 0 i. synchr niz.ed by
the 284 d ck . enerat rt pr vide R D input t ~O 6. Thi ignal i acti,re HmGH. The 086 - D
input isn t synchr ni .zed. Correct operati, n i. not guaranteed i the set -up and h Id time. are n t met \l\1hen
R D i. · I G H , it indicates that the peripheral i. ready to trans. er data.
INTR (Interrupt Request) h L a level-tri ered input which is sampled durin the lmt d ck
c de each in tructi n t determine i1 the proce s, r sh uld enter int an interrupt vect r-1 k up table
located in the . ystem mem ry. ]t can be internally masked by s, ftware resettin. the interrupt enable bit.
I TR i.. inte mal ly . ynchroni .:red. " hi.. .. i nal i. active H JGH.
HMI (Input) Honmask,ab-le Interrupt ThL Lan ed e-tri."' ered input which causes a type 2
interrupt. ub:r, utine L vec:t red 1 ,faan interrupt vect :r I k-up table I ated in. ystem mem ry. i.
not ma. kahle i ntemall by software. trans1t1 n m LO\ T , HJOH initiates the interrupt at the end o the
current in. tmcti n. This input i. internally sync hr, nized
MN/MX i(lnput) The minimum/ma: immn . i nal indicate. tire , peratin m de , , . When it is
hi h the O 6 pr ce sor , perate . in minimum m de. I this pin i . 1 w, the proces .. r perates in ma. imum
m de.
~
/JWX. When
. .· 8086 w rk in
minimum mode which mean . that operate. in a .in le proces.- r em~ronment. I
I IMX = 0 D, it
w :rks in maximum m de and the pr ces .. r can be per.ated in multip:roces.- :r envir nment. T di .. e:rentiate
RESET (Input) The re.et signal i active 'U,GH. The pr, c.e •. . r immediately tern1inate. it pre. ent
activity and . y. tem i. re. et. The .i nal mmt e active rUGfJJ rat le.a. t . urdock cycle . . lit re. tart executi, n,
a described in the instmcti n set when · T return I w. T is. internall y ynchr nis.ed.
CLK (Input) The , ' L . ignal pr vide. the ha ic ti min . , r the pr, ce . .· r and bu . c ntr, lier. ]t i.
asymmetric with a 33% duty cycle to pr vide , ptimi.red internal timin . It i. an nma. kable interrupt request.
Power supply, de
GND O:round
15 Flags11 8 7 F lags._ 0
X X X X I OF I DF I IF I TF I SF I ZF I X I AF I X I PF I X I CF I
CF - Carry flag SF - Sign f lag
P F - Pa ri1
t y flag TF - Trap f lag
A F - Auxil ary cary flag IF - Interrupt flag
Z F - Zero f lag DF - Dire,c tio11a l f lag
X - U11de rfi11ed OF - Overflow flag
Parity Flag (PF} l the re ult • -hit • perati n r I wer te thew rd • perati no ntain an
even number L parity fla i. .•et.
Z,e ro flag (ZF) The zero · a ,. i,s ~ to I if I.he re,<:Utt of an , arilbrtlrlic or log.ii - 1operation i:.~ zero.
\Vhife the re.'itlfl i..~ zero ii i:s re.'d: .
Sig,n1IFlag (SF) The . · gn n:a ,. i. :set to I 1fthe M B ofthe re:sutt i.· I after the arilbmet' or lot•i
operation-~. Thi'ii n:a • rq>n.-Jient~ a :sign number. 1..og-· 0 irrlicate_~ a po.~iti, , n.1.1.ntber and b .•-ic I ·i:.~ u~ed to
repre.~t ne ,, fo · ntl.rrlber.
Ov;erf,fow Flog ,(OF} Thi:.~ ' ' r, i..~ set i.O I if the i.i.gned re,i,u !I c annot be expre.,;.~ed w-ithin. the
n:umber of b it~ in. the de-,~ ina tion operand. Th.i. G · ·, · s 1u~ed to &c,tec,t magn.itude O\'e:r o,,,,, in.s i,\p]ed arith.metiJ
oper··'Irons. Du.rin" addition operation. th.e a ,. i · set ·1,,:ben th.ere i:.~ a carry into 1the MSB and the ··. ,. ·ias reset
if there i:.~ no carry out of the MSB . For subtraction operation. the rra • i:.~ :set wn.en.the MSB de.~ire.~ a borrow
and the an ·i. G re,..et if l:here i.Gno b>rra....· from M SB .
.Oirect.ion Flag ,(O.F) Th.e d iTeL,"tl'On fla ·• i. G u.~ed in. strin r• operatian.G. \Vhen ii i..G set i.l'.) I sitrinr,
by-tees am be acre_,;.,;ed from a memory addre, " in dec...Tem.ent order i.e. h i •h memory add.re~. to] · memor
add.re_,;.~ . Tf il i..~ zero i.'lrin r, b)sle!a-;;Jn beaooe:!iliCd from memor , a-dd.re.,;.~ in in.crea.~in • onler i.e. lo,,,,, memo..··
· ddre_,;.~ to hi ••hmemo.· , a-dd.re_~.s. Fore.-.:.ampl'e: in. Mov · imtructi:on ifDF i..~ :set1to I l:h.e oontent~of the index
ren-i:.~1~ I and D I are auJ:a:n.aticaMDy@remented lo acoe:ss the ~trin lT b Ii-Ji. TfDF = 0 ·inrex re ,·i.'iirer& SJ and
D I are automatiw"t.11' •incremented to ' _., l:h.e strin ,
1 • te-~.
ln•terru,pt Enable F,log (IF) Tb i:.~ 1.- , . c.an be u~ed as an interrupt enabl'e or dis.~bl'e , , . \Vhea
1h i..~ a ·, i:s set. l:h.e ma:.~k;J.bl'e interrupt i..~ enabl'ed and 8086 reco. irze_~ l:h.e ate:rn.al interrupt reg_ uest:s and
the CPU tran.!.l'e:r control to an inter:rupl ,,ecto.r specified kication. When IF i:.G (l .aUI ma:.Gkablle in·terrupts are
diisa ed and there wll be no effect on. nonma:.~kable interrupts iii.~ ·weJI ili.'i in.ternallly generated interrupt~. If
8086 i. G n.-,Gel. IF is automaf caUly ere.ired.
Tr,a p Flag (TFJ TF is a :sin •le-!.'lep, Ila , When TF i:s set to I ai s-inr•l'e .ilep, interrupt OOl.-'1.1.r.!i after
the Ill'.',.: d inGtru(-1ton t:'XCoui:e,Gand the pro, am c-.a n be e.-.:ttiuted in. s in.r•l'e-ste,p mode. The TF ·wiiU be cleared
b the s in , Ee~i.'lep interrµpt.
The n the addre. s bust dete,ct a memory locati n or mem ry read r write
p erat i, 11. . ddresse. with in the se ment can be varied fr m O· .I t ·➔ .I 4 . :r. detect a mem ry
I ati, n the .egment regj . ter . upplies the hi her- rder 1 bits o the 2 -bit memory addres . . The I wer-order
1
1the 2! -bit mem ry addres. are .. t red in any the p inters and inde. regj. ter. , r BX re. i. ter.
There re, mem ry addr-es e o. the 86 are c mputed by smnmin the c ntent. the segment re. i. ter
which L shifted le ft by 4 bit and the o ntent o I set addre.. s. The 2! -bit addre . s . ,ent by the ,
The ntent . the de ,e ment i. le shi1ted by 4 bit and the base address bee, mes 3 t ~ detem1ine
the physical address, the c ntent 1 wil I be added with bac;,e addre . Bence phy ical addre = I
= 32
1 H.
The startin de ,.egment mem ry = 320 H.
s - ment mem ry K mem ry lo cati m , the end addres will be c, mputed after
additi n ith the . tartin . ,- 1ent mem ry.
= 631 F t
The content . the segment regi . ter I i. 6 - nL \ hen it is le. t . hi . ed h~ir 4 hits , r multiplied y 1 D , r
IO H, the base addre .. s i equal t , H x 10 i:-i = 6 H.
Phy . ical addres. = 1
' ntent . segment re. i. ter x I Oi . et addre ss
= ..·x 1 H 1 4 6 H =
1 :1= 69 -
Examp,le 5.3 hat is the c, ntent data . ,egment t locate the physical add:re . . 436 - T.
•s•••••••• .. •••••••••• .. •••••••••• .. ••••••••• ·
s wne the c ntent IP = U · ~I.
Solutiion
The phy. ical addres i. 436 - 'I when the c ntent IP i. 2 1 - H
Phy. icaJ addres.. = C ntent o. data se ment re ·. ter x I H t ] P addres
There. re,
43 H = , 'ontent o data . e ment rec,ister x I
Then the ntent . data . eg,nent re 43 · =4 160 M
The c ntent data . egment re i. te _
••••••••••••••••••••••••••••
lmmediat,e Addressing.
Wn thi. m de o addre . in , the 8- bit r I -bit perand i. a part o the instruction. For example, OV .X
4, H. ]n thi . instructi n, the data 4 I can be I, aded t the .X re ister immediately: "ome , there. am-
ple .. are iven el, w:
0 · BX, 0 :1; load I H in BX re. i.ter
O · CX 4 , :i:-:1 ; t re 4 -0 H in , 'X fi . i. ter
Register Addr,essing
]n the 86 mic:r pr ces . r, me instruction. are perated n the eneral-purpose re · sters. ~ he data is in
the regj , ter ped fi ed ythe in. tructi n . The ., m1at r regj ter addressin. . 1s
urc:e
In thi . instructi n, the data I mm the sour-c:e re. i. ter can be ,c pied int thede. tination regj , ter. The 8-bit
re Lter. , H, , :1, ' ' L, C :1 DL, ,f and l -bit re isters X, BX, , 'X, ·.X )may be
used ., r thi. instructi n. ~ he nly re tricti n i. that both perand.J must be . the same len .th. r examp le,
0 L , BL; ' pie the value , BL int, AL
OV .X, BX; C pie. the content. BX int X
.em ry addre in re.quire detem1inati, n , physical addre. s. The phy ical addre can he mputed fr, m
the c ntent o. se ment addres. and an e e.ctive addre. s. The . egment addre . • identi. 1,es the start in I cation
o the . ,egment in the mem ry ande ective addres. re'presents the , . ,et , . the , perand from the be ·,min
I 1
, · this e ment , mem ry. The 2 -bite .. ective addres can be made up
1
base, index and di placement.
The hru ic . , mmla or the 16..:bit effective addre. - ) and the 2 -bit ph sical addr s P ) i. iven bel ~v:
1 • -bit = Bas,e :Index
t t , isplac.ement
2:0-bit IP = Segment :x 10 I Base I !Index I Dii. placement
The ha. ic types branch addre in a.re . h wn in Fi. _ .8. The imra. e'i!lnem mode i. used t trans.er the
o ntr I t a de. tinati n that lies in the rune segment where the c ntr I tran. er instructi n itsel1 re ide. _ ]n
the inte1. egmel1t m de, addres i .. used t tram er the c ntr I t a dest inat i, n that Iie s in a di e rent ..e ment.
I , r the ranch-co ntr I tran er in ..tructi ns the add.res. in mode. depend upon whether the de tinati n
location i. within the same . e_ ment, r in a different ne. U depenru up n the method o . pm . i no the destina-
ti n addre st the proce .. - r. ·n1ere are tw type. , branch control instructi, ns: inters,egment and intra.se -
ment addres in mode. _
Durin_.executi n pro ram in. truction, when the I cation t which the contr It be tran . erred Iie. in a
di .. erent ..,e ment ther than the current ne, them de is called inter. egment mode. ] the destinati n I cati n
lie in the rune se ment the mode i called i11tra. egment mode .
Load 16-bit data '04,.. . . in th .. r gist ·r and anoth r 16 -bit drt':I 6,.. 4 1n
th · B . r gist r.
: \>D BUG
10.00
l 7D : l 000 tIO , '04,....; L ,a d 16-bit data '04,...H in th r gist r
l D : l 00"" MOV B ,6 4 ; Load 16-bit data 6 4 in B . r g1s ·r
17D . : l 006 LT
17D : 1007
P'r,ogr,a1
m1for Addition o,f 'Two 8-Bit, Numbe1rs with a 16-Bi't Sum
Alg,orithm
START
1. tor · first dat· in RJ gist r L.
tore s " ·ond dat· in R "gis r BL.
dd th ·ont nts of · L and BL. Load first 8-bit data
in Reg ister AL
4. -" flrg \ _ill b s t, if r suit is mor than ' bits
Alg,orithm
1 . L ad first num b r in R gist r START
- l 000
17D : l OOOMO .. FF · 16 bit data in Load seoond 16-bit
in Regist er BX
17D 66 6 · 16 bit d· ta in B
'
170 : 1006 B .,B . .; ont nts of B i: subtr.-, ·t d fr m Subt ract BX fro m A)(
170 : 100'
170 : 1009 T he result is present in AX
-U 1000 100'
170 : 1000 B'
End
170 : 1003 BB6666
170 : 1006 '9 '
170 : 100 4 I_
Algorithm
1. ,t or th ~ 16-bit numb r in R gist r
START
' D ·t rmin ·
,...
, tor h o's ·ompl m n of in B
Load first 16-bit data
in Register AX
- 1000
17D : l000MO .. ' 44 .; 16-bi data in Find 2's complement of AX
17D : 100,... G .; · 's · .mp,l ·m nt of 16-bit data sing NEG AX instruction
17D : 100'" MOV B .; R sult is st r- d in B
11
Algorithm START
1 . Load first numb r in R .,;ist r
· s · nd data in R gist r B
Load multiplicand, i .e., first 16-bit
·ont nts o · b B . number in Regist er AX
Algorithm
1 . Load first numb,•r in R gist r START
' t . r · th s · nd data in R ·gist r
3 . Di id ·ont ·nt of b and r suit in R ·gist rs andD . Load dividend, i.e., first 16~bit.
number in Register AX