Microprocessors and Interfacing 8086 805
Microprocessors and Interfacing 8086 805
and Interfacing
8086, 8051, 8096, and advanced processors
N. Senthil Kumar
Professor
s
Department of Electrical and Electronics Engineering
es
Mepco Schlenk Engineering College
Sivakasi, Tamil Nadu
Pr
M. Saravanan
it y
Professor
rs
Department of Electrical and Electronics Engineering
Thiagarajar College of Engineering
ve
S. Jeevananthan
U
Professor
Department of Electrical and Electronics Engineering
d
Puducherry
xf
S.K. Shah
O
© Oxford University Press. All rights reserved.
3
Oxford University Press is a department of the University of Oxford.
It furthers the University’s objective of excellence in research, scholarship,
and education by publishing worldwide. Oxford is a registered trade mark of
Oxford University Press in the UK and in certain other countries.
Published in India by
Oxford University Press
YMCA Library Building, 1 Jai Singh Road, New Delhi 110001, India
s
by law, by licence, or under terms agreed with the appropriate reprographics
es
rights organization. Enquiries concerning reproduction outside the scope of the
above should be sent to the Rights Department, Oxford University Press, at the
Pr
address above.
Brief Contents
Features of the Book iv
Preface vii
1. Microprocessors—Evolution and Introduction to 8085 1
2. Methods of Data Transfer and Serial Transfer Protocols 47
s
es
5. 8086 Interrupts 175
Pr
6. Memory and I/O Interfacing 210
7. Features and Interfacing of Programmable Devices for
it y
8086-based Systems 240
rs
s
es
Pr
it y
rs
ve
ni
U
d
or
xf
O
Detailed Contents
Features of the Book iv
Preface vii
Brief Contents xi
1. Microprocessors—Evolution and Introduction to 8085 1
1.1 Introduction 1
1.2 Explanation of Basic Terms 2
1.3 Microprocessors and Microcontrollers 5
1.4 Microprocessor-based System 6
1.5 Origin of Microprocessors 7
1.5.1 First generation (1971–1973) 8
s
1.5.2 Second generation (1974–1978) 8
es
1.5.3 Third generation (1978–1980) 8
1.5.4 Fourth generation (1981–1995) 8
Pr
1.5.5 Fifth generation (1995–till date)
it y 9
1.5.6 Timeline of microprocessor evolution 9
&ODVVL¿FDWLRQRI0LFURSURFHVVRUV
rs
1.7 Types of Memory 11
ve
Computers 14
U
s
es
PART I: INTEL 8086—16-BIT MICROPROCESSORS
Pr
3. Intel 8086 Microprocessor Architecture, Features, and Signals
it y 63
3.1 Introduction 63
3.2 Architecture of 8086 63
rs
s
4.7.1 CALL instruction 165
es
4.7.2 RET instruction 166
Pr
4.7.3 Macro 167
4.7.4 Illustrative example it y 168
5. 8086 Interrupts 175
rs
5.1 Introduction 175
5.2 Interrupt Types in 8086 175
ve
s
6.6.2 Assigning 8-bit address to 8-bit input device using
es
address decoder IC 74LS138 222
6.6.3 Assigning 16-bit address to 8-bit DIP switch using
Pr
address decoder having only logic gates 224
6.7 Interfacing 8-bit Output Device with 8086 224
it y
6.8 Interfacing Printer with 8086 225
rs
6.9 Interfacing 8-bit and 16-bit I/O Devices or Ports with 8086 229
ve
s
7.12.3 Initialization of 8259 320
es
7.12.4 Operation of 8259 324
Pr
7.12.5 Interfacing of 8259 to 8086 325
7.13 8237 DMA Controller it y 326
7.13.1 Features, pin details, and architecture of 8237 327
7.13.2 DMA initialization and operation 333
rs
7.13.3 Operation of 8237 with 8086 335
ve
'LIIHUHQW&RQ¿JXUDWLRQVRI0XOWLSURFHVVRU6\VWHP
&RSURFHVVRUDQGFORVHO\FRXSOHGFRQ¿JXUDWLRQV
d
or
/RRVHO\FRXSOHGFRQ¿JXUDWLRQ
8.4 Bus Arbitration in Loosely-coupled Multiprocessor System 346
xf
s
9.4 8086 System Bus Timings 378
es
9.4.1 Timing diagrams for general bus operation in minimum mode 378
9.4.2 Timing diagrams for general bus operation in maximum mode 382
Pr
9.4.3 Interrupt acknowledgement (INTA) timing 383
9.4.4 Bus request and bus grant timing 384
it y
9.5 Design of Minimum Mode 8086-based System 385
rs
s
12.4 8051 Timers 437
es
12.4.1 Timer SFRs 437
12.4.2 Timer operating modes 439
Pr
12.4.3 Timer control and operation 442
12.4.4 Using timers as counters 443
it y
12.4.5 Programming examples 443
rs
12.5 8051 Interrupts 445
12.5.1 Interrupt sources and interrupt vector addresses 445
ve
s
14.3.4 Temporary register 521
es
5HJLVWHU¿OH
Pr
14.3.6 Program status word 523
14.3.7 Memory controller it y 523
14.3.8 Internal timing 523
14.3.9 I/O section 524
rs
s
16.4.7 Global disable 561
es
16.4.8 Program status word 561
Pr
16.5 Serial Ports 562
16.5.1 Operating modes of serial port
it y 563
16.5.2 Serial port control/status registers 564
16.5.3 Determining baud rate 564
rs
16.5.4 Program for serial port data reception 565
ve
s
18.4.1 Architecture of 80386 618
es
18.4.2 Register organization in 80386 620
Pr
18.4.3 Instruction set of 80386 623
18.4.4 Addressing memory in protected mode
it y 624
18.4.5 Physical memory organization in 80386 625
18.4.6 Paging mechanism in 80386 626
rs
s
19.4.6 Instruction set in SPARC microprocessor 714
es
19.4.7 Load and store instructions 715
Pr
19.4.8 Arithmetic and logical instructions 716
19.4.9 Branch instructions it y 717
19.4.10 Special instructions 718
19.5 Software Embedded into System 721
rs
19.5.1 Codesign 722
ve
s
es
Pr
it y
rs
ve
ni
U
d
or
xf
O
s
&RPPRQLQSXWDQGRXWSXWGHYLFHVIRUFRPSXWHUV
es
%XVVWUXFWXUHVXVHGLQFRPSXWHUVDQGWHFKQRORJ\LPSURYHPHQWV
Pr
PLFURSURFHVVRUDUFKLWHFWXUHDQGLQVWUXFWLRQVHW
it y
1.1 INTRODUCTION
rs
unit (CPU) of a computer. In other words, the microprocessor is the heart of any
computer system. Microprocessor-based systems with limited resources are called
ni
mobile phones, fax machines, and photocopiers and in advanced applications such
or
DV UDGDUV VDWHOOLWHV DQG ÀLJKWV$Q\ PLGGOHFODVV KRXVHKROG ZLOO KDYH DERXW D
xf
have led to rapid cost reduction and increased application of microprocessors and
their derivatives.
Typically, basic microprocessor chips have arithmetic and logic functional units
DORQJZLWKWKHDVVRFLDWHGFRQWUROORJLFWRSURFHVVWKHLQVWUXFWLRQH[HFXWLRQ$OPRVW
all microprocessors use the basic concept of stored-program execution. Programs
or instructions to be executed by the microprocessor are stored sequentially in
memory locations. The microprocessor, or the processor in general, fetches the
instructions one after another and executes them in its arithmetic and logic unit. So
all microprocessors have a built-in memory access and management part as well
as some amount of memory.
$PLFURSURFHVVRUFDQEHSURJUDPPHGWRSHUIRUPDQ\WDVNWKDWFDQEHZULWWHQ
and programmed by the user. Without a program, the microprocessor unit is a
SLHFH RI XVHOHVV HOHFWURQLF FLUFXLW 7KH SURJUDPPHU PXVW WDNH FDUH RI DOO WKH
UHVRXUFHV RI WKH PLFURSURFHVVRU DQG XVH WKHP HI¿FLHQWO\ IRU LPSOHPHQWLQJ WKH
UHTXLUHGIXQFWLRQDOLW\6RWRZRUNZLWKWKHPLFURSURFHVVRULWLVQHFHVVDU\IRUWKH
SURJUDPPHUWRNQRZDERXWLWVLQWHUQDOUHVRXUFHVDQGIHDWXUHV7KHSURJUDPPHU
s
will need a set of memory units and interfacing circuits for inputs and outputs.
es
7KHFLUFXLWVWRJHWKHUZLWKWKHPLFURSURFHVVRUPDNHWKHmicrocomputer system.
Pr
The physical components of the microcomputer system are called hardware. The
SURJUDPWKDWPDNHVWKLVKDUGZDUHXVHIXOLVFDOOHGsoftware.
it y
The semiconductor manufacturing technology for chips has developed from
rs
transistor–transistor logic (TTL) to complementary metal-oxide-semiconductor
(CMOS). Microprocessor manufacturing also has gone through these technological
ve
coupled logic (ECL). TTL technology is most commonly used for basic digital
U
integrated circuits; CMOS is favoured for portable computers and other battery-
powered devices because of its low power consumption.
d
or
The terms relevant to the use of microprocessors are explained in this section. These
O
s
means that the contents of the memory are erased when the power to the chip is
es
disrupted. The access of the individual memory location can be done randomly. In
PLFURSURFHVVRUVWKH5$0LVXVHGWRVWRUHGDWD
Pr
DRAM Dynamic random access memory is a semiconductor memory in which
it y
the stored contents need to be refreshed repeatedly at about thousands of times per
rs
second. Without refreshing, the stored data will be lost. These memory chips are
ve
SRZHULVDYDLODEOH7KHUHLVQRQHHGIRUUHIUHVKLQJ,QWHUPVRIVSHHG65$0LV
U
faster.
d
ROM Read only memory devices are memory devices whose contents are
or
to perform arithmetic and logic operations on digital data. The typical operations
SHUIRUPHGE\ WKH$/8 DUHDGGLWLRQVXEWUDFWLRQORJLFDO$1' ORJLFDO25 DQG
FRPSDULVRQRIELQDU\GDWD*HQHUDOO\WKHIXQFWLRQVRIWKH$/8RIDPLFURSURFHVVRU
will decide the processor’s functionality.
Microcontroller $ PLFURFRQWUROOHU LV D FKLS WKDW LQFOXGHV PLFURSURFHVVRU
memory, and input/output signal ports. Microcontrollers can be called single-chip
microcomputers.
Microcomputer The system formed by interfacing the microprocessor
with the memory and I/O devices to execute the required programs is called
microcomputer.
Bus $EXVLV a group of wires/lines that carry similar information.
System bus The system bus is a group of wires/lines used for communication
between the microprocessor and peripherals.
s
Computer architecture 7KH GHVLJQ LQWHUQDO FRQ¿JXUDWLRQ DQG DFFHVVHV LQ D
es
digital computer are together called computer architecture.
Pr
Von–Neumann architecture The architecture in which the same memory is
it y
used for storing programs as well as data.
Harvard architecture The architecture in which programs and data are stored
rs
that supports limited machine language instructions. RISC processors are expected
or
DUH ZULWWHQ ZLWKRXW WKH NQRZOHGJH RI WKH SURFHVVRU LQ ZKLFK WKH SURJUDP ZLOO
O
EH H[HFXWHG %$6,& )RUWUDQ & 3DVFDO DQG -DYD DUH H[DPSOHV RI KLJKOHYHO
languages.
Assembly language $ SURJUDPPLQJ ODQJXDJH ZULWWHQ XVLQJ WKH PQHPRQLFV
or the instruction set of a particular microprocessor is called assembly language.
$VVHPEO\ ODQJXDJH SURJUDPPLQJ LV PLFURSURFHVVRUVSHFL¿F ,W LV QRW DV HDVLO\
understood as a high-level language program, but is easier than a machine language
program.
Machine language Machine language refers to binary code programs that are
VSHFL¿FWRWKHSURFHVVRUDQGFDQEHGLUHFWO\H[HFXWHGE\WKHSURFHVVRU0DFKLQH
language is the lowest level language and cannot be easily understood.
Assembler $FRPSXWHUDSSOLFDWLRQSURJUDPWKDWFRQYHUWVWKHDVVHPEO\ODQJXDJH
program into machine-level language program.
Compiler $FRPSXWHUSURJUDPWKDWFRQYHUWVWKHKLJKOHYHOODQJXDJHSURJUDP
into machine-level language program.
s
es
is in the range of megahertz (MHz) or gigahertz (GHz).
Pr
MIPS Million instructions per second is a measure of the speed at which the
instructions are executed in a processor.it y
Tri-state logic It is the logic used by digital circuits. The three logic levels used
rs
are high (1), low (0), and high impedance state (Z). The logic high state of a digital
FLUFXLWFDQVRXUFHFXUUHQWDQGWKHORJLFORZFDQVLQNFXUUHQWLQDFRPSXWHUV\VWHP
ve
EXWWKHKLJKLPSHGDQFHVWDWHQHLWKHUVRXUFHVQRUVLQNVFXUUHQWDQGVRWKHRWKHU
ni
Operating system The program that controls the entire computer and its
d
resources and enables users to access the computer and its resources is called
or
operating system. It is required for any computer system to become operational and
xf
user friendly. Under the control of the operating system, the computer recognizes
and obeys commands typed by the user. In addition, the operating system provides
O
built-in routines that allow the user’s program to perform input/output operations
ZLWKRXWVSHFLI\LQJWKHH[DFWKDUGZDUHFRQ¿JXUDWLRQRIWKHFRPSXWHU,QORZOHYHO
microprocessor-based systems, the program that controls the hardware is called
monitor routine or monitor software.
s
<RX ZLOO EH DPD]HG WR NQRZ WKDW RXW RI SURFHVVRU FKLSV PDQXIDFWXUHG
es
DUHHPEHGGHGSURFHVVRUVRQO\RQHJRHVLQWRDJHQHUDOFRPSXWHU$SOHWKRUDRI
Pr
VHPLFRQGXFWRUFRPSDQLHVDUHLQWKHPLFURFRQWUROOHUPDUNHWDQGDQ\DSSOLFDWLRQ
GHYHORSPHQW HQJLQHHU LV ÀRRGHG ZLWK D YDULHW\ RI PLFURFRQWUROOHUV WR FKRRVH
it y
IURP7KLVERRNGLVFXVVHV,QWHO¶VELWVHULHVDQGELWVHULHVDVDOVR
rs
other advanced microcontrollers.
ve
called a microcomputer system. The system consists of CPU, memory, and I/O
SRUWVDVVKRZQLQ)LJ
d
or
xf
Data bus
Control bus
$GGUHVVEXV
)LJXUHVKRZVDW\SLFDOSHUVRQDOFRPSXWHUV\VWHP7KHLQWHUIDFLQJRIWKH
processor with the other parts of the microcomputer system needs a three-bus
architecture. The three buses are data bus, address bus, and control bus.
(DFKPHPRU\ORFDWLRQRU,2SRUWLVLGHQWL¿HGE\DVSHFL¿FDGGUHVVVLPLODU
to a postal address. In microprocessor systems, the addresses are all in binary,
and in general, represented in hexadecimal number format. The address is a
s
es
$IWHUVHOHFWLQJWKHORFDWLRQWKHGDWDWUDQVIHUEHWZHHQWKHPHPRU\DQGSURFHVVRU
or between the I/O device and the processor is done through the data bus. The
Pr
ZLGWKRIWKHGDWDEXVGHWHUPLQHVWKHGDWDVL]HWKDWFDQEHWUDQVIHUUHG$QELW
SURFHVVRUZLOOJHQHUDOO\KDYHDQELWGDWDEXVDQGDELWSURFHVVRUZLOOKDYH
it y
D ELW GDWD EXV 7KH PHPRU\ ORFDWLRQV LQ PLFURSURFHVVRUV DUH DFFHVVHG DV
rs
ELWRURQHE\WHXQLWVRQO\6RWKHWUDQVIHURIDELWGDWDIURPPHPRU\QHHGVWZR
ve
PHPRU\DGGUHVVHV$.%PHPRU\FKLSZLOOKDYHE\WHVRIPHPRU\ORFDWLRQV
$ FRQWURO EXVLV QHHGHG IRU SURSHU GDWD WUDQVIHU EHWZHHQ WKH SURFHVVRU DQG
ni
the peripherals. The control bus basically consists of signals for selection of the
U
correct memory or I/O device from the address, indication of the direction of data
d
transfer, and synchronization of data transfer between slow devices. Many of the
or
control signals are given by the processor itself because the processor is the master
of the computer system. Some control signals such as selection of the correct
xf
memory chip can be generated externally by the logic circuits. The timing of the
O
control signal is very important; the entire timing of the operation is controlled by
WKHPLFURSURFHVVRULQV\QFKURQL]DWLRQZLWKWKHFORFNVLJQDOLQSXW
s
es
$VWKHWHFKQRORJ\HYROYHGWKHQXPEHURIFLUFXLWVWKDWFRXOGEHIDEULFDWHGRQD
chip grew. Very large-scale integration (VLSI) led to chips that had speeds up to
Pr
KXQGUHGVRIPLOOLRQVRIVZLWFKLQJVSHUVHFRQG7KHVHFRQGJHQHUDWLRQPDUNHGWKH
EHJLQQLQJRIYHU\HI¿FLHQWELWPLFURSURFHVVRUV6RPHRIWKHSRSXODUSURFHVVRUV
it y
ZHUH 0RWRUROD¶V DQG ,QWHO¶V DQG =LORJ¶V = 7KH VHFRQG
rs
JHQHUDWLRQGHYLFHVPDUNHGDVKDUSFRQWUDVWZLWKWKHXVHRIQHZHUVHPLFRQGXFWRU
ve
DQG KLJKHU GHQVLW\ WKDQ 3026 ,W UHVXOWHG LQ D ¿YHIROG LQFUHDVH LQ LQVWUXFWLRQ
U
7KH WKLUG JHQHUDWLRQ LQWURGXFHG LQ ZDV GRPLQDWHG E\ ,QWHO¶V DQG
xf
=LORJ¶V=ZKLFKZHUHELWSURFHVVRUVZLWKPLQLFRPSXWHUOLNHSHUIRUPDQFH
O
7KHVHSURFHVVRUVKDGWKHWHFKQRORJ\RIELWDULWKPHWLFDQGSLSHOLQHGLQVWUXFWLRQ
SURFHVVLQJ7KHWKLUGJHQHUDWLRQFDPHZLWK,&WUDQVLVWRUFRXQWVRIDERXW
,Q0RWRUROD¶V0&IRUH[DPSOHDQRQFKLSFDFKHZDVLQFRUSRUDWHGIRUWKH
¿UVW WLPH DQG WKH GHSWK RI WKH SLSHOLQH ZDV LQFUHDVHG WR ¿YH RU PRUH VWDJHV ,W
was designed using high density metal-oxide-semiconductor (HMOS) technology.
+026SURYLGHVVRPHDGYDQWDJHVRYHU1026,WVVSHHG±SRZHUSURGXFWLVIRXU
WLPHVEHWWHUWKDQWKDWRI1026LWFDQDFFRPPRGDWHWZLFHWKHFLUFXLWGHQVLW\RI
1026
s
0+]
es
0+]
0+]
Pr
0+]
0+]
it y
0+]
rs
0+]
$WKDORQ;3 *+]
ve
s
PHWKRG NQRZQ DV VXSHUVFDODU DUFKLWHFWXUH DQG FXUUHQWO\ RSHUDWHV ZLWK
es
IUHTXHQFLHV XS WR *+] VWDJH SLSHOLQH DQG WKUHHOHYHO FDFKH
Pr
memory architectures.
[ ²,QWHO3HQWLXP,,SURFHVVRUZDVGHVLJQHGVSHFL¿FDOO\WRSURFHVVYLGHR
it y
00;DXGLRDQGJUDSKLFVGDWDHI¿FLHQWO\ZLWKVSHHGVRI0+]0+]
rs
0+]DQG0+]
ve
[LL ²,QWHO3HQWLXPSURFHVVRU
U
companies have their own chips and architectures in addition to the regular Intel-
based architectures.
xf
O
s
processors. Very long instruction word (VLIW) processors have instructions
es
composed of many machine operations. These instructions can be executed in
parallel. This parallel execution is called instruction-level parallelism. VLIW
Pr
processors also have a large number of registers. Superscalar processors use
it y
complex hardware to achieve parallelism. It is possible to have overlapping of
instruction execution to increase the speed of execution.
rs
ve
Memory unit is an integral part of any microcomputer system. Its primary purpose is
to hold program and data. The main objective of the memory unit design is to enable
U
LWWRRSHUDWHDWDVSHHGFORVHWRWKDWRIWKHSURFHVVRU$OWKRXJKWHFKQRORJ\LVDYDLODEOH
d
WRGHVLJQVXFKDKLJKVSHHGPHPRU\FRVWLVWKHPDMRUOLPLWLQJIDFWRU7RVWULNHD
or
balance between cost and operating speed, a memory system is usually designed
xf
using different materials such as solid state, magnetic, and optical materials.
$PLFURFRPSXWHUPHPRU\FDQEHORJLFDOO\GLYLGHGLQWRIRXUJURXSV
O
s
es
Pr
Primary memory
it y
rs
ve
6HPLFRQGXFWRU5$0 ROM
ni
U
5$0GHYLFHVDOORZERWKUHDGLQJDQGZULWLQJWRWKHLUPHPRU\FHOOV,QVWDWLF
5$0GHYLFHVELWVDUHVWRUHGDVWKHVWDWXVRIRQRIIVZLWFKHV7KHUHDUHQRFKDUJHV
LQYROYHGDQGKHQFHQRFKDUJHVWROHDN+RZHYHUVWDWLF5$0GHYLFHVKDYHFRPSOH[
construction and hence larger size per unit storage. So they are more expensive.
6WDWLF5$0VDUHFRPSDUDWLYHO\IDVWHUDQGDUHXVHGLQFDFKHPHPRULHV
,QG\QDPLF5$0GHYLFHVWKHGDWDELWVDUHVWRUHGDVFKDUJHLQFDSDFLWRUV6LQFH
FDSDFLWRUFKDUJHKDVDWHQGHQF\WROHDNWKHVHGHYLFHVQHHGUHIUHVKLQJHYHQZKHQ
they are powered. However, they have simpler construction and smaller size per
unit storage. These devices are less expensive and comparatively slower.
$VWKHQDPHLPSOLHVD520SHUPLWVRQO\UHDGDFFHVV7KHUHDUHPDQ\NLQGV
RI520V
L 0DVNSURJUDPPDEOH520V 03520V DUHFXVWRPPDGHIRUWKHFXVWRPHU
their contents are programmed by the manufacturer. Since they are mass
produced, they are inexpensive. The customer cannot erase or program it
afterwards.
s
UHTXLUHVEXONHUDVXUHRIDODUJHSRUWLRQRIWKHPHPRU\DUUD\
es
Pr
1.8 INPUT AND OUTPUT DEVICES
,QSXWDQGRXWSXW GHYLFHVSHUPLWWKHXVHUWRIHHGGDWDWRWKHFRPSXWHUDQGUHWULHYH
it y
WKH FRPSXWHG UHVXOW IURP LW 6RPHWLPHV WKH LQSXW DQG RXWSXW GHYLFHV FDQ
rs
FRPPXQLFDWH DPRQJ WKHPVHOYHV ,Q JHQHUDO FRPSXWHU V\VWHPV KDYH ,2 SRUWV
ve
,2GHYLFHVDUHFRQQHFWHGWRWKHVHSRUWVIRUGDWDWUDQVIHU%DVLFDOO\WKHSRUWVDUH
GLJLWDOUHJLVWHUVWKDWDOORZWKHFRPSXWHUWRWUDQVIHUGDWDEHWZHHQWKH,2GHYLFHV
ni
XVLQJDGGLWLRQDOFRQWUROVLJQDOV7KHVHFRQWUROVLJQDOVDOORZHUURUIUHHWUDQVIHURI
U
GDWD
7KH FRPPRQ LQSXW GHYLFH XVHG LQ DOPRVW DOO V\VWHPV LV WKH NH\SDG
d
0LFURSURFHVVRUEDVHGEDVLFPLFURFRPSXWHUV\VWHPVXVHVLPSOHQXPHULFNH\SDGV
or
+RZHYHUDGYDQFHGFRPSXWHUV\VWHPVXVHNH\ERDUGVZLWKDODUJHQXPEHURINH\V
xf
RSWLFDOGHYLFHVDQGVFDQQHUVVXFKDVPRXVHMR\VWLFNDQGEDUFRGHVFDQQHUVDUH
DOVREHLQJXVHGDVLQSXWGHYLFHV0LFURFRPSXWHUV\VWHPVDOVRXVHGLIIHUHQWW\SHV
RIVHQVRUVIRUGDWDLQSXW7KHVHVHQVRUVQHHGGDWDFRQYHUWHUVVXFKDVDQDORJWR
GLJLWDOFRQYHUWHUV$Q\LQWURGXFWRU\FRXUVHRQPLFURSURFHVVRUVVKRXOGFRYHUWKH
LQWHUIDFLQJRIGDWDFRQYHUWHUVNH\SDGVDQGVZLWFKHV
$QRXWSXWGHYLFHLVDGHYLFHWKURXJKZKLFKWKHXVHUFDQUHFHLYHWKHUHVXOWVIURP
WKHFRPSXWHU7KHRXWSXWFDQEHDUDSLGO\FKDQJLQJGLVSOD\RUSULQWHGPDWHULDO
2WKHUIRUPVRIRXWSXWDUHVRXQGVDQGDODUPV7KHVLPSOHVWRXWSXWGHYLFHVXVHGLQ
DOPRVWDOOPLFURSURFHVVRUEDVHGV\VWHPVDQGFRPSXWHUV\VWHPVDUH/('VVHYHQ
VHJPHQW/('GLVSOD\VDQG/&'GLVSOD\V7KHDGYDQFHGYLGHRGLVSOD\WHUPLQDOV
HLWKHUFDWKRGHUD\WXEHVRU/&'V DQGLQNMHWDQGODVHUSULQWHUVDUHWKHFRPPRQ
RXWSXW GHYLFHV QRZDGD\V 6RPH RXWSXW GHYLFHV FDQ EH XVHG WR GLUHFWO\ FRQWURO
PDFKLQHULHV 6RPH GHYLFHV VXFK DV GLVSOD\ WHUPLQDOV ZLWK WRXFK VFUHHQ PD\
SURYLGH ERWK LQSXW DQG RXWSXW 0RGHPV DQG RWKHU QHWZRUN LQWHUIDFH FDUGV FDQ
DOVREHFDOOHGRXWSXWGHYLFHVDVWKH\HQDEOHWKHWUDQVPLVVLRQDQGUHFHSWLRQRIGDWD
EHWZHHQFRPSXWHUV
s
es
,2 SRUWV ZLWKLQ D VLQJOH FKLS 0LFURFRQWUROOHUV DUH PDQXIDFWXUHG LQ WKLV
IDVKLRQ,QDGGLWLRQGHYHORSPHQWVLQODUJHVFDOHLQWHJUDWLRQKDYHOHGWRWKH
Pr
PDQXIDFWXUHRIVPDOOPLFURSURFHVVRUFKLSVZLWKODUJHEXLOWLQSHULSKHUDOV
3URFHVVRUVZLWKDODUJHDPRXQWRIÀDVKPHPRU\DUHQRZDYDLODEOHLQWKH
it y
PDUNHW
rs
LY 'HYHORSPHQWRIH[WHUQDOSHULSKHUDOV7KHXVHRIFRPSXWHUVLQDOO¿HOGVKDYH
ve
UHVXOWHGLQWKHGHYHORSPHQWRIPDQ\IDVWDQGDGYDQFHGSHULSKHUDOGHYLFHV
)RUH[DPSOHWKHDSSOLFDWLRQRIPLFURSURFHVVRUVLQPHGLFLQHKDVUHVXOWHG
ni
LQWKHGHYHORSPHQWRIPDQ\KDQGKHOGHOHFWURQLFGHYLFHVZLWKVSHFLDOL]HG
U
LQSXWVHQVRUVRXWSXWSULQWHUVHWF)DVWHUSHULSKHUDOVFDQLQFUHDVHWKHVSHHG
RISURFHVVRUH[HFXWLRQDQGSURYLGHDJRRGXVHULQWHUIDFH
d
Y ,QFUHDVHLQPHPRU\XQLWVL]HDQGVSHHG7KHGHYHORSPHQWVLQ,&WHFKQRORJ\
or
KDYHOHGWRDUHGXFWLRQLQWKHVL]HRIWKHPHPRU\XQLWVDQGDQLQFUHDVHLQ
xf
PHPRU\VSHHG7KLVUHGXFHVWKHPHPRU\DFFHVVWLPHRIWKHSURFHVVRUDQG
O
UHVXOWVLQKLJKHUVSHHGRIH[HFXWLRQ0RUHDPRXQWRIPHPRU\SHUXQLWDUHD
LVSRVVLEOH
YL 0LFURSURFHVVRUV DUH ODUJHO\ XVHG LQ KDQGKHOG GHYLFHV RSHUDWHG IURP D
EDWWHU\ VRXUFH 7KLV KDV UHVXOWHG LQ UHVHDUFK RQ WKH UHGXFWLRQ RI SRZHU
FRQVXPSWLRQLQPLFURSURFHVVRUFKLSV$VSRZHUFRQVXPSWLRQLVUHGXFHG
WKHVHGHYLFHVZRUNIRUPRUHWLPHRQFHWKHEDWWHULHVDUHIXOO\FKDUJHG7KHUH
DUHPDQ\GHYLFHVRSHUDWLQJDW9RUHYHQORZHUYROWDJHVDQGKDYHORZ
SRZHUFRQVXPSWLRQ
s
LVXVXDOO\FDOOHGDJHQHUDOSXUSRVHELWSURFHVVRU,WLVXSZDUGFRPSDWLEOHZLWK
es
PLFURSURFHVVRU ZKLFK ZDV ,QWHO¶V HDUOLHU SURGXFW7KHUH DUH VHYHUDO IDVWHU
Pr
YHUVLRQVRIWKHPLFURSURFHVVRUVXFKDV$+$+DQG$+
$ PLFURSURFHVVRU V\VWHP FRQVLVWV RI WKUHH IXQFWLRQDO EORFNV²FHQWUDO
it y
processing unit (CPU), input and output units, and memory units, as shown in
)LJ7KH&38FRQWDLQVVHYHUDOUHJLVWHUVDQDULWKPHWLFDQGORJLFXQLW $/8
rs
ve
Memory
ni
U
(ROM)
Read only memory
d
or
xf
5$0
O
Processor
Control unit
Input Output
unit unit
$/8
s
(iii) Special-purpose registers (iv) Instruction register and decoder
es
(v) Timing and control unit
Pr
1.11.1 Arithmetic and Logic Unit
$/8 LV WKH FLUFXLWU\ WKDW SHUIRUPV WKH DFWXDO QXPHULFDO DQG ORJLFDO RSHUDWLRQV
it y
$GGLWLRQ $'' VXEWUDFWLRQ 68% LQFUHPHQW ,15 GHFUHPHQW '&5
rs
DQG FRPSDULVRQ &03 DUH WKH DULWKPHWLF RSHUDWLRQV SRVVLEOH LQ WKH
ve
data bus
xf
O
}
)ODJÀLS Temp reg. Temp reg.
ÀRSV % &
Reg. select
s
from it. These general-purpose registers are user accessible through programs.
es
5HJLVWHUV%&'(+DQG/DUHWKHJHQHUDOSXUSRVHUHJLVWHUVLQWKH
DVVKRZQLQ)LJ7KH\FDQDOVREHFDOOHGVFUDWFKSDGUHJLVWHUV,QDOPRVWDOO
Pr
arithmetic and logical it y
operations, these registers $FFXPXODWRU$ )ODJUHJLVWHU
are used as the second
rs
% &
RSHUDQGVWKH¿UVWRSHUDQG
ve
' (
being the accumulator
$ 7KH JHQHUDOSXUSRVH + /
ni
6WDFNSRLQWHU 63
registers but they can be
3URJUDPFRXQWHU 3&
d
KDQGOHGDVELWUHJLVWHUV
or
s
es
' ' DQG ' RI WKH ÀDJ
register remain unassigned; S Z ; $& ; P ; CY
Pr
WKH\DUHPDUNHGZLWKDQ;WR D7 '
it y ' ' D3 ' D1 D0
show that they are not used
and are don’t cares. Fig. 1.7 Flag register
rs
$Q\ÀDJUHJLVWHUELWLVVDLGWREHµVHW¶ZKHQLWVYDOXHLVDQGµFOHDUHG¶ZKHQLWV
ve
YDOXHLV7KHPRVWFRPPRQO\XVHGÀDJVDUH]HURFDUU\DQGVLJQ$&ÀDJFDQQRW
be accessed externally.
ni
06% RI WKH DFFXPXODWRU $ QHJDWLYH QXPEHU KDV D LQ ELW DQG D SRVLWLYH
d
QXPEHUKDVDLQ¶VFRPSOHPHQWUHSUHVHQWDWLRQ7KLVÀDJLQGLFDWHVWKHVLJQRI
or
the number. (It may be recalled that signed magnitude numbers use 1 to indicate
xf
DQHJDWLYHQXPEHUDQGWRLQGLFDWHDSRVLWLYHQXPEHU 7KLVÀDJFDQEHXVHGLQ
O
s
VWDFNSRLQWHU 63 ZKLFKKROGVWKHDGGUHVVRIWKHPHPRU\ORFDWLRQRIWKHWRSRI
es
WKH VWDFN7KH SURJUDPPHU FDQ UHVHUYH DQG DOORFDWH D VHULHV RI 5$0 ORFDWLRQV
Pr
WR EH XVHG DV D VWDFN DQG DFFRUGLQJO\ LQLWLDOL]H WKH VWDFN SRLQWHU7KH UDQJH RI
VWDFN PHPRU\ ORFDWLRQV PXVW EH FKRVHQ FDUHIXOO\ VR WKDW LW GRHV QRW DIIHFW WKH
it y
SURJUDPVSDFH,QDOOPLFURSURFHVVRUEDVHGV\VWHPVWKHVWDFNLVPDLQO\XVHGWR
rs
store the return address of the main program when a subroutine is called. While
WKHSURJUDPPHUXVHVWKHVWDFNIRUVWRUDJHDQGUHWULHYDORIGDWDWKHPLFURSURFHVVRU
ve
XVHVWKHVWDFNGXULQJVXEURXWLQHFDOOV&DUHPXVWEHWDNHQE\WKHSURJUDPPHUWR
ni
HQVXUHWKDWWKHGDWDVWRUHGLQWKHVWDFNLVUHWULHYHGSURSHUO\VRWKDWWKHGDWDVWRUHG
LQWKHVWDFNE\WKHSURFHVVRULVQRWDIIHFWHG
U
d
,WLVDQELWUHJLVWHUWKDWWHPSRUDULO\VWRUHVWKHLQVWUXFWLRQVGUDZQIURPPHPRU\
xf
locations, before their actual execution. The content of the register is decoded by
the decoder circuitry, where the nature of the operation to be performed is decided
O
(interpreted). In addition, there are two temporary registers W and Z, which are
controlled internally and not available for user access.
s
memory location.
es
7KHDGGUHVVEXVOLQHVDUHJHQHUDOO\LGHQWL¿HGDV$±$7KHDGGUHVVEXVKDV
HLJKWKLJKHURUGHUDGGUHVVOLQHV $±$ ZKLFKDUHXQLGLUHFWLRQDO7KHORZHU
Pr
RUGHUHLJKWOLQHV $±$ DUHPXOWLSOH[HG WLPHVKDUHG ZLWKWKHHLJKWGDWDELWV
it y
(D0–D7) and hence, they are bidirectional. When the instruction is executed, these
lines carry the address bits during the early part, and the eight data bits during the
rs
later part. To separate the address from the data, a latch is used externally to save
ve
The control bus carries control signals that are partly unidirectional and partly
ELGLUHFWLRQDO)RUDPLFURSURFHVVRUWRIXQFWLRQFRUUHFWO\WKHVHFRQWUROVLJQDOVDUH
d
vital. The control bus typically consists of a number of single lines that coordinate
or
DQGFRQWUROPLFURSURFHVVRURSHUDWLRQV)RUH[DPSOHDUHDGZULWHFRQWUROVLJQDO
xf
will indicate whether memory is being written into or read from. Thus, they are
O
individual lines that provide a pulse to indicate the operation of the microprocessor.
,QIDFWWKHPLFURSURFHVVRUJHQHUDWHVVSHFL¿FFRQWUROVLJQDOVIRUHYHU\RSHUDWLRQ
which in turn are used to identify the type of device the processor intends to
communicate with. The following points describe the control and status signals
RIWKHSURFHVVRU
L $/( RXWSXW $GGUHVV /DWFK (QDEOH LV D SXOVH WKDW LV SURYLGHG ZKHQ DQ
DGGUHVV DSSHDUV RQ WKH $'±$' OLQHV DIWHU ZKLFK LW EHFRPHV 7KLV
VLJQDOFDQEHXVHGWRHQDEOHDODWFKWRVDYHWKHDGGUHVVELWVIURPWKH$'
from the selected I/O or memory device and that they are available on the
DQG DQ ,2 RSHUDWLRQ$Q DFWLYH ORZ RQ WKLV VLJQDO VKRZV LW LV D PHPRU\
s
how the movement of data within the computer is accomplished by a series of
es
EXVHV$GGUHVVLQIRUPDWLRQGDWDDQGFRQWUROVLJQDOVKDYHWREHFDUULHGDURXQG
inside the microprocessor as well as in the external system. Hence, the buses are
Pr
present both internally and externally.
YL ,QWHUUXSWV7KHVHVLJQDOVDUHXVHGWRPDNHWKHPLFURSURFHVVRUUHVSRQGWRKLJK
it y
priority externally initiated signals. When an interrupt signal is detected by the
rs
processor, it suspends the execution of the current program and executes the
ve
SURJUDPFRUUHVSRQGLQJWRWKHLQWHUUXSWVLJQDOLQVWHDG)LYHLQWHUUXSWVLJQDOV
,175567567567DQG7UDS DUHDYDLODEOHWRIDFLOLWDWHWKH
ni
SURFHVVRUWRUHFHLYHDQGDFNQRZOHGJHWKHLQWHUUXSWFDOORISHULSKHUDOV7KH
U
SURFHVVRUDFFHSWVWKUHHPRUHH[WHUQDOO\LQLWLDWHGVLJQDOV²5(6(7,1,
d
Hold, and Ready as inputs. The following points explain these signals in
EULHI
or
D ,175 LQSXW ,W LV D JHQHUDOSXUSRVH LQWHUUXSW UHTXHVW VLJQDO ,W LV DQ
xf
$ $GGUHVVEXV
$
Memory Input
Real
Output
MPU world
data
D7 Data bus
D0
Control bus
s
get control over the data and address buses for data transfer to and from
es
PHPRU\7KLVRSHUDWLRQLVFDOOHGGLUHFWPHPRU\DFFHVV '0$ '0$
Pr
is useful when high-speed peripherals want to transfer data to and from
memory. The processor does not intervene during this period.
it y
L 5HDG\ LQSXW ,W LV D VLJQDO WKDW VHUYHV WR GHOD\ WKH PLFURSURFHVVRU
rs
read/write signals until a slow-responding peripheral is ready to send or
accept data. If this signal goes low, then the processor is allowed to wait
ve
IRUDQLQWHJUDOQXPEHURIFORFNF\FOHVXQWLO5HDG\EHFRPHVKLJK7KH
5HDG\VLJQDOPXVWEHV\QFKURQL]HGZLWKWKHSURFHVVRUFORFN
ni
U
; 1 VCC
d
; 39 HOLD
or
'0$
RESET OUT 3 +/'$
Serial V *1'
xf
Higher-order
75$3 5($'< ;; VCCVSS address bus
567 7 IO/M $
567 33 S1 $
567 9 RD SID Multiplexed
lower-order
,175 10 31 WR SOD
75$3 address/data
,17$ 11 30 $/( 567 bus
$'
$' S0 567
$' 13 $ 567
,175
$'
$/(
$' $ ,17$ S1
$' $ 5($'< S0
HOLD IO/M
$' $ +/'$
$' 17 $ RESET RD
$' $ ,1 WR
$' 19 $
VSS $ RESET OUT CLK (OUT)
(a) (b)
s
es
1.11.5.5 Power Supply and System Clock
7KH IROORZLQJ SLQV DUH DYDLODEOH LQ WKH FKLS WR SURYLGH SRZHU DQG FORFN
Pr
VLJQDOWRWKHSURFHVVRU
(i) ; ; LQSXW $ PLFURSURFHVVRU QHHGV D VTXDUH ZDYH FORFN VLJQDO WR
it y
HQVXUHWKDWDOOLQWHUQDORSHUDWLRQVDUHV\QFKURQL]HG$FU\VWDORU5±&RU/±&
rs
QHWZRUNLVFRQQHFWHGWRWKHVHWZRSLQV7KHFU\VWDOIUHTXHQF\LVLQWHUQDOO\
ve
divided by two to give the operating system frequency. There are three
advantages in increasing the frequency of a crystal—as frequency increases,
ni
the crystal size becomes smaller, and the crystal becomes lighter and cheaper.
U
7KHUHIRUHFORFNFLUFXLWVLQFOXGHDGLYLGHE\WZRFLUFXLWVRWKDWDGRXEOH
d
SUHIHUUHG DV D FORFN VRXUFH EHFDXVH RI LWV KLJK VWDELOLW\ ODUJH 4 TXDOLW\
xf
IDFWRU DQGDEVHQFHRIIUHTXHQF\GULIWLQJZLWKDJLQJ:LWKRXWDFORFNVLJQDO
O
s
ELW ELWGDWDRUWZRKH[GLJLWV
es
ELW ELWGDWDDGGUHVVRUIRXUKH[GLJLWV
Pr
( ) = Contents of
it y
1.13 CLASSIFICATION OF INSTRUCTIONS
rs
0LFURSURFHVVRU LQVWUXFWLRQV FDQ EH FODVVL¿HG EDVHG RQ SDUDPHWHUV VXFK DV
ve
%DVHGRQWKHIXQFWLRQDOLW\WKHLQVWUXFWLRQVDUHFODVVL¿HGLQWRWKHIROORZLQJ¿YH
FDWHJRULHV
d
or
s
es
LV VWRUHG LQ WKH DFFXPXODWRU 7KH ,QWHO LQVWUXFWLRQ VHW VXSSRUWV WZR W\SHV
RI DGGLWLRQ LQVWUXFWLRQV²ZLWK DQG ZLWKRXW DGGLWLRQ RI WKH FDUU\ ÀDJ FRQWHQW WR
Pr
WKH OHDVW VLJQL¿FDQW ELW RI WKH QXPEHUV7KH LQVWUXFWLRQ VHW DOVR VXSSRUWV ELW
it y
addition, i.e., the content of the HL register pair can be added to that of another
register pair and the result stored in the HL register pair.
rs
6XEWUDFWLRQ 68% 7KH LQVWUXFWLRQ VHW RI WKH VXSSRUWV WZR W\SHV RI
ve
operation also uses the accumulator as reference, i.e., it subtracts the content of a
register or memory location from that of the accumulator and stores the result in
U
the accumulator.
d
WKHFRQWHQWVRIDQ\UHJLVWHUUHJLVWHUSDLURUPHPRU\ORFDWLRQ8QOLNHWKHDULWKPHWLF
xf
and logical operations, the increment and decrement operations need not be based
O
(ii) Execution control can return to the point of branching, which is stored by the
instructions
([DPSOH6XEURXWLQHFDOOLQVWUXFWLRQV
1.13.1.5 Machine Control Operations
These instructions can be used to control the execution of other instructions. They
include halting the operation of the microprocessor, interrupting program execution,
HWF'HWDLOHGH[SODQDWLRQVIRULQVWUXFWLRQVDUHJLYHQLQ6HFWLRQ
s
es
(i) One-byte instructions (ii) Two-byte instructions
(iii) Three-byte instructions
Pr
$VVHPEO\ ODQJXDJH LQVWUXFWLRQV VKRXOG EH FRQYHUWHG LQWR PDFKLQH FRGH IRU
it y
storage and execution by the processor. So the length of the machine language
code instructions determines the length of the program. This in turn determines the
rs
Instructions that require only one byte in machine language are called one-byte
U
instructions. These instructions just have the machine code or opcode alone to
represent the operation to be performed. The common examples are the instructions
d
or
that have their operands within the processor itself. Some examples of one-byte
LQVWUXFWLRQVDUHJLYHQLQ7DEOH(YHQWKRXJKWKHLQVWUXFWLRQ$''0DGGVWKH
xf
content of a memory location to that of the accumulator, its machine code requires
O
s
MVI R, data—(R data)
es
Example:
Pr
MVI A, 32H (coded as 3E 32 in two contiguous bytes)
This is an example of immediate addressing.it y
7KHIROORZLQJWZRLQVWUXFWLRQVDUHDOVRH[DPSOHVRIWZRE\WHLQVWUXFWLRQV
rs
L $',GDWD $ $GDWD
LL 287SRUW ZKHUHSRUWLVDQELWGHYLFHDGGUHVV 3RUW $ 6LQFHWKHE\WH
ve
is not the data itself, but points directly to where it is located, this is called
ni
GLUHFWDGGUHVVLQJ)RUDGHWDLOHGDFFRXQWRIDGGUHVVLQJPRGHVVHH6HFWLRQ
U
1.13.3.
d
Instructions that require three bytes in machine code are called three-byte
LQVWUXFWLRQV,QPDFKLQHODQJXDJHWKH¿UVWE\WHRIWKHWKUHHE\WHLQVWUXFWLRQV
xf
LVWKHRSFRGHZKLFKVSHFL¿HVWKHRSHUDWLRQWREHSHUIRUPHG7KHQH[WWZRE\WHV
O
UHIHUWRWKHELWRSHUDQGZKLFKLVHLWKHUDELWQXPEHURUWKHDGGUHVVRID
memory location. Some common examples of three-byte instructions are listed in
7DEOH
Table 1.6 7KUHHE\WHLQVWUXFWLRQV
Opcode Operand Machine code/Opcode/Hex code Byte description
7KHLQVWUXFWLRQ/;,5SELWGDWDFDQEHH[SODLQHGDVIROORZV
5SLVRQHRIWKHSDLUVRIUHJLVWHUV%&'(RU+/ZKLFKDUHXVHGDVELW
UHJLVWHUV7KHWZRGDWDE\WHVDUHWREHVWRUHGDVDELWQXPEHULQ/DQG+LQ
VHTXHQFH /;, + + LV FRGHG DV + + + LQ WKUHH E\WHV 7KLV LV DQ
example of immediate addressing.)
,QH[HFXWLQJWKHLQVWUXFWLRQ/'$DGGUWKHDFFXPXODWRULVORDGHGZLWKWKHPHPRU\
FRQWHQWRIWKHDGGUHVVJLYHQLQWKHLQVWUXFWLRQ$GGULVDELWDGGUHVV/'$+
LVFRGHGDV$+++ 7KLVLVDQH[DPSOHRIGLUHFWDGGUHVVLQJ
s
,QWKHVHLQVWUXFWLRQVWKHVRXUFHFDQEHDUHJLVWHURUDQELWQXPEHU +WR))+
es
the destination is a register. The source and destination are operands. The various
Pr
formats for specifying operands are called addressing modes7KHKDVWKH
IROORZLQJ¿YHW\SHVRIDGGUHVVLQJ it y
(i) Immediate addressing (ii) Memory direct addressing
(iii) Register direct addressing (iv) Indirect addressing
rs
DGGUHVVLQJLVJLYHQLQ)LJ addressing
O
Example:
MVI A, 9AH
(a) The operand is part of the instruction.
(b) The operand is stored in the register mentioned in the instruction.
Example:
ADI 05H
D $GG+WRWKHFRQWHQWVRIWKHDFFXPXODWRU
E +LVWKHRSHUDQG
Immediate addressing has no memory reference to fetch data. It executes faster,
but has limited data range.
1.13.3.2 Memory Direct Addressing
Memory direct addressing moves a byte or word between a memory location and
register. The memory location address is given in the instruction. The instruction
set does not support memory-to-memory transfer. Memory direct addressing is
LOOXVWUDWHGLQ)LJ
© Oxford University Press. All rights reserved.
Microprocessors—Evolution and Introduction to 8085 29
Instruction
2SFRGH0HPRU\DGGUHVV$ Memory
$
Operand
Example:
LDA 850FH
7KLVLQVWUXFWLRQLVXVHGWRORDGWKHFRQWHQWVRIWKHPHPRU\ORFDWLRQ)+LQWKH
s
accumulator.
es
Example:
Pr
STA 9001H
This instruction is used to store the contents of the accumulator in the memory
it y
address 9001H.
rs
In these instructions, the memory address of the operand is given in the instruction.
ve
Direct addressing is also used for data transfer between the processor and
LQSXWRXWSXWGHYLFHV)RUH[DPSOHWKH,1LQVWUXFWLRQLVXVHGWRUHFHLYHGDWDIURP
ni
the input port and store it in the accumulator; the OUT instruction is used to send
U
Example:
or
Register direct addressing transfers a copy of a byte or word from the source
register to the destination register. The operand is in the register named in the
instruction. It executes very fast, has very limited register space, and requires
good assembly programming. The operand is within in the processor itself; so the
H[HFXWLRQLVIDVWHU5HJLVWHUGLUHFWDGGUHVVLQJLVLOOXVWUDWHGLQ)LJ
Instruction
Opcode Register R Registers
R
Operand
Fi
Fig. 1 12 ))RUPDWRIUHJLVWHUGLUHFWDGGUHVVLQJ
1.12 I L GL GG L
s
access (or accesses) to retrieve the data which is to be loaded in the register.
es
Example:
Pr
MOV A, M it y
Here, the data is in the memory location pointed to by the contents of the HL pair.
The data is moved to the accumulator.
rs
ve
Instruction
Opcode Register address R
ni
Memory
U
Registers
d
or
Memory address
to operand Operand
R
xf
O
In general, the assembly language mnemonics with their operands are written
¿UVW7KHDGGUHVVZKHUHWKHLQVWUXFWLRQVDUHVWRUHGLVJLYHQDGXPP\QDPHFDOOHG
label. The purpose of labels is to give the correct branch addresses in instructions.
s
es
Labels are separated from mnemonics with a colon.
The comments column is essential for any program as it helps the programmer
Pr
understand the logic of the program at any point in time. Without comments, it is
GLI¿FXOWWRXQGHUVWDQGDQDVVHPEO\ODQJXDJHSURJUDP&RPPHQWVDUHVHSDUDWHG
it y
from the mnemonics with a semicolon.
7KH ¿UVW WZR FROXPQV FRUUHVSRQG WR WKH SK\VLFDO PHPRU\ DGGUHVV DQG WKH
rs
DFWXDOPDFKLQHFRGH7KHVHWZRFROXPQVDUH¿OOHGLQDIWHUFRPSOHWLQJWKHDVVHPEO\
ve
language programming. These columns must contain only binary numbers, but for
ni
HDV\XQGHUVWDQGLQJKH[DGHFLPDOQXPEHUVDUHXVHG)RUPDQXDODVVHPEOLQJWKHVH
WZR FROXPQV DUH ¿OOHG LQ E\ WKH SURJUDPPHU $Q DVVHPEOHU FDQ JHQHUDWH WKHVH
U
columns automatically.
d
$QH[DPSOHRIWKHDVVHPEO\ODQJXDJHSURJUDPIRUPDWLVJLYHQLQ7DEOH
or
7KHLQVWUXFWLRQLQ7DEOHPRYHVWKHGDWD)+WRWKHDFFXPXODWRU
1.14.2 Data Transfer Instructions
Data transfer instructions are used to transfer data between two registers in the
microprocessor or between a peripheral device and the microprocessor. Some
instructions and their features are given in the following points. The complete list
ZLWKH[SODQDWLRQVLVJLYHQLQ7DEOH
L 09,LQVWUXFWLRQLVXVHGIRUVWRULQJELWGDWDLQDPLFURSURFHVVRUUHJLVWHU
LL /;,LQVWUXFWLRQLVXVHGIRUVWRULQJELWGDWDLQDUHJLVWHUSDLU
s
/'$ELW /RDGVWKHDFFXPXODWRU 0HPRU\ 7KUHHE\WHV /'$)+
es
with the data from the direct
Pr
memory location
indicated by the
ELWDGGUHVV
it y
/+/'ELW /RDGVWKH+DQG/ 0HPRU\ 7KUHHE\WHV /+/'$+
rs
registers directly from direct
ve
indicated by the
ELWDGGUHVV
U
memory location
indicated by the
xf
ELWDGGUHVV
O
s
WKH+/UHJLVWHUSDLU
es
/'$;5S /RDGVDFFXPXODWRUZLWK ,QGLUHFW 2QHE\WH /'$;%
WKHFRQWHQWVRIWKH
Pr
PHPRU\ORFDWLRQSRLQWHG
WRE\WKHUHJLVWHUSDLU
it y
67$;5S 6WRUHVWKHFRQWHQWVRIWKH ,QGLUHFW 2QHE\WH 67$;'
rs
DFFXPXODWRULQWKH
PHPRU\ORFDWLRQSRLQWHG
ve
WRE\WKHUHJLVWHUSDLU
ni
ZLWKWKDWRIWKH'DQG(
d
UHJLVWHUSDLU
or
WKHVWDFNSRLQWHU
O
LY /'$DQG67$XVHPHPRU\GLUHFWDGGUHVVLQJPRGHDQGDELWPHPRU\
DGGUHVVDVRSHUDQG
Y /'$; DQG 67$; XVH LQGLUHFW DGGUHVVLQJ PRGH IRU GDWD WUDQVIHU 7KH
RSHUDQG JLYHQ LQ WKH LQVWUXFWLRQ LV RQH RI WKH UHJLVWHU SDLUV %& RU '(
5HJLVWHU SDLU +/ LV QRW XVHG ZLWK /'$; GXH WR WKH DYDLODELOLW\ RI WKH
DOWHUQDWLYHLQVWUXFWLRQ029$0
YL /+/'DQG6+/'DUHWKHLQVWUXFWLRQVXVHGWRWUDQVIHUELWGDWDEHWZHHQ
WKH+/UHJLVWHUSDLUDQGWZRFRQVHFXWLYHPHPRU\ORFDWLRQV)RUH[DPSOH
H[HFXWLQJ6+/'+LQVWUXFWLRQZLOOVWRUHWKHFRQWHQWVRI/UHJLVWHULQ
+DQGWKHFRQWHQWVRI+UHJLVWHULQ+
YLL 386+ DQG 323 LQVWUXFWLRQV DUH XVHG IRU GDWD WUDQVIHU EHWZHHQ D UHJLVWHU
s
DQRXWSXWSRUW
es
[ ;&+* LQVWUXFWLRQ LV XVHG WR H[FKDQJH WKH FRQWHQWV RI WKH +/ DQG '(
Pr
UHJLVWHUSDLUV
it y
1.14.3 Arithmetic Instructions
rs
7KHDULWKPHWLFLQVWUXFWLRQVVXSSRUWHGE\WKHDUHDGGLWLRQVXEWUDFWLRQDQG
WKHLUYDULDQWV7KHDULWKPHWLFLQVWUXFWLRQVDUHOLVWHGLQ7DEOH
ve
ni
DFFXPXODWRU
O
s
es
register pair to that of the direct
H and L registers
Pr
,155 ,QFUHPHQWVWKHUHJLVWHU Register 2QHE\WH ,15%
by 1 it y direct
,1;5S ,QFUHPHQWVWKHUHJLVWHU Register 2QHE\WH ,1;%
pair by 1 direct
rs
by 1 direct
'&;5S 'HFUHPHQWVWKHUHJLVWHU 2QHE\WH '&;'
ni
Register
pair by 1 direct
U
7KHIROORZLQJSRLQWVOLVWVRPHNH\IHDWXUHVRIDULWKPHWLFRSHUDWLRQV
s
L )RUDULWKPHWLFRSHUDWLRQVRQHRIWKHGDWDPXVWEHVWRUHGLQWKHDFFXPXODWRU
es
and the other given or addressed in the instruction.
Pr
LL $GGZLWKFDUU\ LQVWUXFWLRQV DUH XVHG IRU PXOWLE\WH DQG KLJKHURUGHU E\WH
addition. it y
(iii) Similarly, subtract-with-borrow instructions are used in multi-byte and
rs
higher-order byte subtraction.
(iv) Increment and decrement instructions can be operated not only on the
ve
DQG'&;LQVWUXFWLRQV
U
YL '$$ LV WKH LQVWUXFWLRQ WKDW VXSSRUWV %&' DGGLWLRQ7KH DGGLWLRQ RI
d
%&'GDWDLVGRQHOLNHELQDU\DGGLWLRQXVLQJWKH$''LQVWUXFWLRQ'$$LV
or
used to convert the result of the binary addition of BCD numbers into a BCD
xf
s
es
with the contents of the accumulator.
;5$0 7KHFRQWHQWVRIWKHPHPRU\ ,QGLUHFW 2QHE\WH ;5$0
Pr
location pointed to by the HL
UHJLVWHUSDLULVORJLFDOO\(;25HG
it y
with the contents of the accumulator.
rs
25$0 7KHFRQWHQWVRIWKHPHPRU\ ,QGLUHFW 2QHE\WH 25$0
location pointed to by the HL
ve
RLC Rotates the bits of the accumulator Implicit One byte RLC
left by one position
d
RRC Rotates the bits of the accumulator Implicit One byte RRC
or
s
7KHLQVWUXFWLRQVHWRIWKHVXSSRUWVDFRPSDUHLQVWUXFWLRQIRUFRPSDULQJ
es
the magnitude of two binary numbers. The compare instructions are used to
Pr
FRPSDUH WKH DFFXPXODWRU FRQWHQW ZLWK WKH RSHUDQG VSHFL¿HG LQ WKH LQVWUXFWLRQ
CPI instruction uses immediate addressing and CMP uses registers or indirectly
it y
addressed memory location for comparing with the accumulator. The result of the
FRPSDUHLQVWUXFWLRQLVLQGLFDWHGLQWKHÀDJUHJLVWHUDVIROORZV
rs
subroutine instructions. The jump instructions merely transfer the execution from
O
one location in the program to another, whereas the subroutine instructions in the
main program transfer execution to a new location and also return to the main
SURJUDP 5HWXUQ LQVWUXFWLRQV DUH XVHG IRU WKLV SXUSRVH7KH EUDQFKLQJ FDQ WDNH
SODFH XQFRQGLWLRQDOO\ RU FRQGLWLRQDOO\ EDVHG RQ WKH ÀDJ FRQGLWLRQV VKRZQ LQ
Table 1.11. PCHL instruction is a special instruction used to branch to the address
stored in the HL register pair.
RST nLVWKHUHVWDUWLQVWUXFWLRQVXSSRUWHGE\WKH8SRQH[HFXWLRQRIWKH
RST n instruction, the program execution will be transferred to the address given
by n î)RUH[DPSOH567LQVWUXFWLRQZLOOWUDQVIHUWKHH[HFXWLRQWRWKHDGGUHVV
+ZKLFKLVWKHKH[DGHFLPDOHTXLYDOHQWRI LQGHFLPDOIRUP
,QPDFKLQHFRGHRURSFRGHWKHELWRUKH[GLJLWDGGUHVVHVLQWKHEUDQFKLQJ
instructions are given such that the lower-order byte of the address follows the
KLJKHURUGHUE\WH)RUH[DPSOH-03+LVFRGHGDV&7KHRSFRGHIRU
-03&LVVWRUHG¿UVWIROORZHGE\DQGWKHQE\
s
&3ELW &DOORQSRVLWLYH 7KUHHE\WHV &3
es
&0ELW &DOORQPLQXV 7KUHHE\WHV &0
&=ELW &DOORQ]HUR 7KUHHE\WHV &=
Pr
&1=ELW &DOORQQR]HUR
it y 7KUHHE\WHV &1=
&3(ELW &DOORQSDULW\HYHQ 7KUHHE\WHV &3(
&32ELW &DOORQSDULW\RGG 7KUHHE\WHV &32
rs
RET Return unconditionally One byte RET
ve
s
es
DI Disables interrupts Implicit One byte
EI Enables interrupts Implicit One byte
Pr
5,0 5HDGVLQWHUUXSWPDVN ,PSOLFLW 2QHE\WH
6,0 6HWVLQWHUUXSWPDVN it y ,PSOLFLW 2QHE\WH
The program given in Table 1.13 uses immediate addressing for the two data to be
DGGHG7KHGDWDWREHDGGHGDUHVWRUHGLQPHPRU\ORFDWLRQV+DQG+
U
7KHVXPLVVWRUHGLQWKHPHPRU\ORFDWLRQ+7KLVSURJUDPDVVXPHVWKDWQR
d
:ULWHDQDVVHPEO\ODQJXDJHSURJUDPWRDGGWZRQXPEHUVRIELWVHDFK
This program also uses immediate addressing for loading the data in the processor
UHJLVWHUV7KHVXPLVVWRUHGLQWKHPHPRU\ORFDWLRQV+DQG+DVVKRZQ
LQ7DEOH
s
$ +/7 7HUPLQDWHSURJUDPH[HFXWLRQ
es
Pr
3. Write an assembly language program to add the two numbers stored in the
PHPRU\ORFDWLRQV+DQG+DQGVWRUHWKHUHVXOWLQ+
it y
This program uses indirect addressing instructions to load the numbers to be
rs
added in the processor registers. The carry, if generated, is ignored. The program
LVVKRZQLQ7DEOH
ve
Opcode
or
s
es
operand fetch, and memory read/write or I/O read/write. The microprocessor’s
H[WHUQDOFRPPXQLFDWLRQIXQFWLRQFDQEHGLYLGHGLQWRWKUHHFDWHJRULHV
Pr
(i) Memory read/write (ii) I/O read/write
LLL ,QWHUUXSWUHTXHVWDFNQRZOHGJH
it y
rs
POINTS TO REMEMBER
ve
RSHUDWLRQVDQGPDNHVVLPSOHGHFLVLRQV
x The basic operation of the microprocessor is to fetch instructions stored in the
or
xf
x $ PLFURFRPSXWHU V\VWHP LV PDGH E\ LQWHUIDFLQJ PHPRU\ DQG ,2 GHYLFHV WR D
present within the chip.
x 0LFURSURFHVVRUHYROXWLRQLVFODVVL¿HGLQWR¿YHJHQHUDWLRQV7KHSURFHVVRUVWKDWDUH
microprocessor.
FXUUHQWO\LQXVHEHORQJWRWKH¿IWKJHQHUDWLRQ
x The microprocessor is a semiconductor device consisting of electronic logic
circuits manufactured using either large-scale integration (LSI) or very large-scale
LQWHJUDWLRQ 9/6, WHFKQLTXH,WZRUNVDWD¿[HGFORFNIUHTXHQF\
x $EXV is a collection of wires connecting two or more chips.
x $ W\SLFDO PLFURSURFHVVRU FRPPXQLFDWHV ZLWK PHPRU\ DQG RWKHU LQSXWRXWSXW
x 6DOLHQWIHDWXUHVRIWKHPLFURSURFHVVRUPDQXIDFWXUHGE\,QWHO
devices using three buses—address bus, data bus, and control bus.
,WLVDQELWPLFURSURFHVVRU
,WKDVDELWDGGUHVVEXV $±$ DQGKHQFHFDQDGGUHVVXSWR
E\WHV .%
s
x
(iv) Testing for a given condition and altering the program sequence
es
7KHLQVWUXFWLRQVDUHFODVVL¿HGLQWRWKUHHJURXSVDFFRUGLQJWRZRUGVL]HRQHWZR
x
Pr
and three-byte instructions.
$Q LQVWUXFWLRQ KDV WZR SDUWV²RSFRGH RSHUDWLRQ WR EH SHUIRUPHG DQG RSHUDQG
GDWD WR EH RSHUDWHG RQ 7KH RSHUDQG FDQ EH GDWD ELW RU ELW DGGUHVVHV
it y
registers, or implicit in the opcode. The method of specifying an operand (directly,
rs
x
indirectly, etc.) is called addressing mode.
ve
The instructions are executed in steps of machine cycles and each machine cycle
requires many T-states.
ni
U
KEY TERMS
d
Accumulator ,WLVDQELWUHJLVWHULWLVDSDUWRIWKH$/8DQGLVWKHPRVWLPSRUWDQW
or
UHJLVWHU,WLVXVHGWRVWRUHELWGDWDDQGWRSHUIRUPDULWKPHWLFDQGORJLFDORSHUDWLRQV
xf
Address bus This bus carries the binary number (i.e., the address) used to access
a memory location. Binary data can then be written into or read from the addressed
PHPRU\ORFDWLRQ7KHDGGUHVVEXVFRQVLVWVRIZLUHVDQGFDQWKHUHIRUHKDQGOH
bits.
Addressing mode It is the method of specifying the data to be operated on by the
instruction.
Bus It is a group of conducting lines that carry data, address, and control signals
Clock speed This determines how many instructions per second the processor can
H[HFXWH,WLVVSHFL¿HGLQPHJDKHUW] 0+]
Control bus This bus has various lines for coordinating and controlling
PLFURSURFHVVRURSHUDWLRQV)RUH[DPSOHRD and WR lines.
Data bus This bus carries data in binary form between the microprocessor and
H[WHUQDOXQLWVVXFKDVPHPRU\7\SLFDOVL]HLVHLJKWRUELWV
DMA controller ,WLVXVHGWRWDNHFRQWURORIWKHV\VWHPEXVE\SODFLQJDKLJKVLJQDO
on the Hold pin.
Flag ,WLVDÀLSÀRSXVHGWRVWRUHLQIRUPDWLRQDERXWWKHVWDWXVRIWKHSURFHVVRUDQG
the status of the instruction executed most recently.
s
sequence can be resumed.
es
Machine cycle It is the time required to access the memory or input/output devices.
Pr
Memory direct addressing It moves a byte or word between a memory location
and a register.
Opcode ,WLVWKHSDUWRIWKHLQVWUXFWLRQWKDWVSHFL¿HVWKHRSHUDWLRQWREHSHUIRUPHG
it y
Operand It is the data on which the operation is performed.
rs
287 This instruction is used to move data from the accumulator to an I/O port.
ve
Ready It is an input signal to the processor. It is used by the memory or I/O devices
to get extra time for data transfer or to introduce wait states in the bus cycles.
ni
Trap ,WLVDQRQPDVNDEOHLQWHUUXSWRIWKHDQGLVQRWGLVDEOHGE\SURFHVVRUUHVHW
or after reorganization of interrupt.
xf
T-state ,WLVWKHEDVLFXQLWXVHGWRFDOFXODWHWKHWLPHWDNHQIRUH[HFXWLRQRILQVWUXFWLRQV
O
DQGSURJUDPVLQDSURFHVVRU,WLVWKHWLPHFRUUHVSRQGLQJWRRQHFORFNSHULRG
REVIEW QUESTIONS
1. What is the main function of a computer?
1DPHDQ\WKUHHLQSXWGHYLFHVRIDFRPSXWHU
1DPHDQ\WZRRXWSXWGHYLFHVRIDFRPSXWHU
1DPHDQ\WKUHHVWRUDJHGHYLFHVRIDFRPSXWHU
1DPHDQ\WKUHHSODFHVZKHUHFRPSXWHUVFDQEHXVHG
'UDZDEORFNGLDJUDPRIDFRPSXWHUDQGODEHOLWVFRPSRQHQWV
:KRGHYHORSHGWKHZRUOG¶V¿UVWPLFURSURFHVVRU"
:KDWLVWKHGDWDEXVZLGWKRIWKHPLFURSURFHVVRU"
:KHQGLG,QWHOLQWURGXFHWKH3HQWLXPPLFURSURFHVVRU"
:KDWLVWKHDPRXQWRIPHPRU\WKDWWKH3HQWLXPSURFHVVRUFDQDGGUHVV"
11. What are the basic units of a microprocessor?
:KDWLVWKHIXQFWLRQRIPLFURSURFHVVRULQDV\VWHP"
s
:K\LVWKHGDWDEXVELGLUHFWLRQDO"
es
+RZDUHWKHVLJQDOVRIWKHFODVVL¿HG"
+RZDUHFORFNVLJQDOVJHQHUDWHGLQWKH":KDWLVWKHIUHTXHQF\RIWKHLQWHUQDO
Pr
FORFN"
+RZGRHVWKHSURFHVVRUGLIIHUHQWLDWHDPHPRU\DFFHVV UHDGZULWH VLJQDO
it y
from an I/O access (read/write) signal?
rs
:K\LVFU\VWDODSUHIHUUHGFORFNVRXUFH"
:KLFKLQWHUUXSWKDVWKHKLJKHVWSULRULW\LQWKH":KDWLVWKHSULRULW\RIWKH
ve
other interrupts?
ni
'UDZDJHQHUDOEORFNGLDJUDPRIDPLFURSURFHVVRUEDVHGV\VWHP([SODLQEULHÀ\
d
WKHYDULRXVEORFNVRIWKHV\VWHP*LYHVRPHH[DPSOHVRIWKHW\SHVRIGHYLFHVXVHG
or
IRUHDFKEORFN
:KDWLVDPLFURSURFHVVRU"6NHWFKDQGH[SODLQWKHYDULRXVSLQVRIWKH
xf
([SODLQWKHRSHUDWLRQRIWKHVHVLJQDOV5HDG\6DQG6+ROGDQG+/'$
O
DQG$/(
([SODLQWKHDUFKLWHFWXUHRIWKHZLWKWKHKHOSRILWVLQWHUQDOEORFNVFKHPDWLF
diagram.
/LVWWKHIRXUFDWHJRULHVRILQVWUXFWLRQVWKDWDUHXVHGIRUGDWDPDQLSXODWLRQ
'H¿QHRSFRGHDQGRSHUDQG,GHQWLI\WKHRSFRGHDQGWKHRSHUDQGLQWKHLQVWUXFWLRQ
MOV H, L.
([SODLQWKHLQVWUXFWLRQ;&+*
:KDWLVDQLQVWUXFWLRQ"/LVWDQ\IRXUDULWKPHWLFLQVWUXFWLRQVDQGWKHLUXVHV
'H¿QHVWDFN([SODLQWKHLQVWUXFWLRQVUHODWHGWRVWDFNRSHUDWLRQV
:KHQLVWKHLQVWUXFWLRQ;5$$XVHG"
+RZPDQ\RSHUDWLRQVDUHWKHUHLQWKHLQVWUXFWLRQVHWRIWKHPLFURSURFHVVRU"
([SODLQZLWKH[DPSOHVWKHGLIIHUHQWLQVWUXFWLRQIRUPDWVEDVHGRQWKHOHQJWKRIWKH
instructions.
/LVW WKH IRXU LQVWUXFWLRQV ZKLFK FRQWURO WKH LQWHUUXSW VWUXFWXUH RI WKH
microprocessor.
:KDWLVWKHODVWLQVWUXFWLRQH[HFXWHGLQDSURJUDP":K\"
s
es
one return to the main program?
Pr
it y
rs
ve
ni
U
d
or
xf
O