0% found this document useful (0 votes)
23 views

Adobe Scan 01 Feb 2024

The document discusses assembly language as a way to program microprocessors. It explains that assembly language uses mnemonics like ADD and SUB instead of binary codes, making programming easier and less error-prone compared to machine language. It also discusses how an assembler is used to translate assembly language programs into machine code that can be executed by the microprocessor.

Uploaded by

Snehlata
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Adobe Scan 01 Feb 2024

The document discusses assembly language as a way to program microprocessors. It explains that assembly language uses mnemonics like ADD and SUB instead of binary codes, making programming easier and less error-prone compared to machine language. It also discusses how an assembler is used to translate assembly language programs into machine code that can be executed by the microprocessor.

Uploaded by

Snehlata
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

OMPUTERS

5
Programming of Microprocessors
61 INTRODUCTION
Acomputer can only do what the programmer asks to do. To perform a particular task the
ng the res programmerprepares a sequence of instructions, called a program. Aset of programs
D line. See
romputeris known as
particular written for a
softwvare for that computer. The program is stored in RAM.
takesoneinstruction of the program at a time from RAM and executes it. It executes all theThe CPU
instruc-
tionssof the program one by one to produce the desired result. Acomputer uses binary digits for its
oneration and understands information composed of only zeros and ones. Hence, the instructions
the restart areaodedand stored|in the memory in the form of zeros and ones. Aprogram written in the form of
Intel 8085. Nand 1s is called amachine langage program. In the machine language there is aspecific binary code
each instruction. For example, for Intel 8085 to add thecontents of register Aand register B, the
ary code is 10000000. To move the content of register Bto register Athe binary code is 01111000.
ags remain tis tery difficult for the programmer to write a program in machine codes. Moreover, it is error
ne The demerits of machine language programs are :
1. Itis very difficult to understand ordebug a program.
2 Since the each bit has to be entered individually the entry of a program is very siow.
group. 3. Programs are long.
bles for each
4. Program writing is difficult and tiresome.
5. Chances of careless errors in writing the program.
d: Aprogram written in machine codes ultimately becomes a
set of binary numbers. A machine
in memory locations 2501 and
language program is shown below for adding two numbers placed
303. The result is to be placed in memory location 2503.
Machine codes a Comnents
in H-L pair.
00100001 Get the address of the 1st number i.e. 2501
00000001 LSBs of 2501
00100101 MSBs of 2501 (i sgas 6
accumulator.
01111110 Get the 1st number in
00100011 Increment content of H-L pair.
the 1st number.
10000110 Add the 2nd number to
00110010 Store sum in 2503H.
00000011 LSBs of 2503

00100101 MSBs of 2503

01110110 Stop.
MICROPROCESSORS AND
5.2
FUNDAMENTALS OF

MICAOdatCOaMPUTERS
Now data are to be entered. For this example data are two numbers say 15 and 20, and hey ate
and 2502 respectively. The memory address and.
to be placed in memory locations
form are written as follows:
DATA
2501
inbinary
Data
Memory address
0010010100000001 00010101
0010010100000010 00100000
in hexadecimal system. The proers
To facilitate programmer machine codes can be written system. The mistake can easil.
easily be written in hexadecimal system compared to binary system is as follows.
detected. The program for the addition of two numbers in hexadecimal
Machine code Comments

21 Get the address of the 1st number, i.e. 2501H in H-L pair.
01 LSDs of 2501H
25 MSDs of 2501H
7E Get the 1st number in accumulator.
23 Increment content of H-L pai.
86 Add the 2nd number to the 1st number.
32 Store sum in 2503H.
03 LSDs of 2503H
25 MSDs of 2503H
76
Stop.
DATA
2501 OF
2502 14

As the microcomputer understands a program only in binary system, the


hexadecimal system is converted into binary system. All microprocessor kits haveprogram written n
such conversion. provisions tor
The hexadecimal system is also not convenient and hence, easily
described in the subsequent sections, have been developed. The language understandable languages,
writes programs is called sOurce language. The language in which a in which a programmer
machine language. Machine codes are also called object codes. The computer works is called object o
guage. machine language is a low-level lar
5.2 ASSEMBLY LANGUAGE
In the previous section it has been explained that the
very difficult, tiresome, boring and error writing of program in machine languag
prone. Hence, to facilitate programmers easily u can
standable languages have been developed. Assembly language is one of
them. A
easily write a program in alphanumeric symbols instead of zeros and ones. Meaningfulprogrammer
and easily
rememberable symbols are chosen for the purpose. Examples are: ADD for addition, SUB tor u
UR

MICROPROCESSORS 5.3
OF
:
PROGRAMMING

comparison etc. Such symbols are called mnemonics. A program written in


CMP for assembly language program. The writing of a program in assernbly language
traction, i s known as
mnemonics
andfaster as compared to the writing of a
program in machine language. Both as-
easier
and machine language are microprocessor-specific.
A microprocessor-specific lan-
language is that
sembly
language
knownasa low-level language. The distinguishing feature of an assembly
other hand corresponding
suage
is
,
orespondingto one
mmemonic, there is only one machine code. On the a program is
statement of,a high-level language, there is a number of machine codes. When Consequerntly,
understand it.
o one.
language other than machine language, a computer cannot machine language before it is ex
written written in other languages has to be translated
ina into
translates an assembly
a progranm
translation is done with the help of software. Aprogram which
Auted. pograminto a mnachine language program is called an
The assembler. The advantage of assermb-
self-assembler or resident assembler is an
latthe extra cost of the assembler. A A
produces object codes(machine codes).
language obtained
languageis microcomputer for which it small
aSemblerwhich
r runs onthe
peripherals, software supports for convenient assembly and has be
microcomputer lacks speed,
slow speed for the development of programs. Aprogramoncanother
size of memory
resulting in
time on alarge computer. When a program is developedcomputer
short on a
developedlconveniently in is required. Across-assembler is an assembler that runs
cross-assembler
computer,a
that for which itproduces object codes. language program to an assembly lan
other than convert a machine
in situations, when a
Disassembler. It is a software aid to assembler. It is useful
role is complementary to that of an converted to assemnbly language for better
guage program. Its language and it is to be
orogram is available in machine
assembler which goes through an assembly
understanding. ASSEMBLER. An assembler must have some
ONE-PASS AND TWO-PASS assembler. Such an
program only once is known as one-pass Assembly language programs use labels that
language references into account. forward references.
technique to take the forward program. Such labels point to two-pass as
may appear later on in the language program twice is calleda
assembler which goes through an assembly
forward references. During the first pass it
An does not face difficulty
with
for each instruction and
Smbler. Such an assembler second pass it produces the machine code their position from the
colects all lables. During the assigns addresses to lables by counting
them. It
SSigns addresses to each of is that it
starting address. program only once. Its disadvantage commonly
as it goes through a assemnblers are
One-pass assembler is faster as atwo-pass assembler carn. Two-pass
does not provide as many features placedin two
consecutive
used. two numbers location
the addition of
An assembly language progranm for given below. The sum is stored in
the memory
memory locations 2501H and 2502H is
2503H.
Example Comments
Operands number in H-L pair.
Mnemonics Get the address of
the 1st
accumulator.
LXI H, 2501H number in
Get the lst
MOV of H-L pair.
A, M Increment the content
number.
INX H 2nd
Add the lst and
ADD M sum in 2503.
Store
STA 2503H
HLT Stop.
5.4 FUNDAMENTALS OF MICROPROCESSORS AND

DATA
2501 - 49H
2502 56H
MICROCOMPUTERO,
Result:
2503 - 9F

Mnemonics, operands, data of the program and starting address for the program are
computer. The assembler converts the program into a machinelanguage program before fed to the
tion of the program. the
execu-
In an ordinary kit assembler is not available. The programmer first of all
writes program in as-
sembly language and then fills up the machine code corresponding to each mnemonic.
hand assembly. The codes are written in hexadecimal system. The hexadecimal codes .Thisis called
microcomputer using keyboards. In microprocessor kits there is an arrangemnent are fed to the
hexadecimal codes into binary codes. The program for the addition of two numbersfors
language with hexadecimal codes is given below : in
assembiy converting
Memory Machine Mnemonics Operand Comments
address Codes
2000 21, 01, 25 LXI H, 2501 H Get the address of the 1st
number in
2003 7E MOV A,M
HLpair.
The 1st
2004 23 INX
number in accumulator.
H
2005 86 ADD M
Increment content of H-L pair.
2006 23, 03, 25 Add 2nd number to the first
STA 2503 H number.
2009 76 Store result in 2503 H.
HLT
DATA Stop.
2501 -49 H
2502-56 H
Result:
2503-9F
The
easier to programmer writes a program in mnemonics
understand faster to write. Then he fills up(assembly
and
microcomputer. This is atime the machinelanguage)
codes
with comments as
hand assembly. which
consuming, tiresome and boring job. There are chances
are to be fed tro ut
The advantage of of errorsin
is that the assembly
time is language over
computation
level languages have been ess. An assemblyhigh level larnguage, such as FORTRAN, COBOLLetc.
The discussed in the language program is faster to produce result. High
subsequent
1. disadvantages
Programming
of assembly
language
is difficult and time as section.
compared to high-level languages are :
2. The consuming.
assembly language is computer
detailed oriented. The programmer is required to have the
registers knowledge
and
of the
particular
connections instructions
of ports to the the microcomput
microcomput er er he is using. He must know what
has, how affect registers;
3. Assembly y equipment to be
language program is not portablecontrolled etc. instructions
i.e. the
program written for one microcomputer
PROGRAMMING
GOF MICROPROCESSORS
5.5
used| for any other because cach
cannotbe microcomputer has itsaown
The programmer has to write his own program to perform assembly
particular language.
task. Library
facilities.for assembly language programs are not available.
4. An assembly language programis longer as cornpared to a high-level language prograrn.
Each statement in a high-level language corresponds to many assenbly language
instructions.

5.3 HIGH-LEVEL LANGUAGES


The difficulties associated with assembly languages can be overCorne using high-level lang-
uages.Instructions written in high-level languages are called statements rather than nnemonrics. In a
high-levellanguage statements more clearly resemble English and Mathermatics than mnenonics.
Examplesofhigh-level languages are: FORTRAN, COBOL, BASIC, PASCAL, ALGOL, PL/M, Cetc.
Theselanguages are procedure-oriented rather than computer-oriented. While writing aprogram in
high-levellanguagethe knowledge of computer architecture and registers organizations etc. is not
a written in these languages for one type of computer can easily be used for any
needed. Programs
other type of computer. Thus the programs written in a high-level language are portable. The pro
gram writing in these languages is easier and faster because one statement of ahigh-level language
orresponds to many instructions of assembly language. Acompiler is needed to translate high-level
languagetoomachineecodes
co for the operation of a computer.
cOMPILER. Aprogram that translates ahigh-level language program into amachine language
program is called acompiler. Acompiler is more powerful than assembler. It checks all kinds of limits,
ranges, errors etc. But it occupies more memory space and takes longer time to produce result. In
aher words its limitations arelowspeed and low efficiency of memory utilisation. Ifa compiler runs
on the computer for which it produces object codes, is called a self-compiler or resident compiler. If it
runs on acomputer other than that for which it produces object codes, is called a cross-compiler.
INTERPRETER. It is also atranslator. It translates a high-level language program into object
codes, statementwise. It does not translate the entire program at a time. It takes up one statement of
ahigh-level language program at a time, translates it and then executes it. Thereafter, it takes up the
next statement of the high-level language program and repeats the process. An interpreter occupies
less memory space, it is cheaper, and suitable for a smaller system. It is slower than a compiler.
FORTRAN is an abbreviation of Formula Translation. It was developed in the early 1950s bv
TBM. It is an ideal larnguage for scientific and engineering computation as it contains many functions
for complex mathematical operations. There are several versions of this language. Earlier,
FORTRANIVwas very popular. In 1977 the American National Standards Institute (ANS) publish
ed a standard for FORTRAN with an idea that all manufacturers should use the same form of the
language. This standard form of the language is FORTRAN 77. Now FORTRAN 90 and FORTRA:
95 versions are also available. This was the most popular and widely used language for scientific and
engineering calculation. Avast library of softwares is available in FORTRAN.
COBOL. This abbreviation stands for Common Business Oriented Language. It was introduced
in 1960 by US. industry/government committee. It was a widely used language in the past for large
business application / data processing such as handling of ledgers, accounts and payroll files. These
applications involve fairly simple numericalcomputation. COBOL supports simple and limited
numeric operations, but it can handle complex nonnumeric operations. Its English-like statements
are very easily understandable; a typical example is SUBTRACT WITHDRAWLS FROM OLD
BALANCE GIVING NEWBALANCE. Its latest version is COBOL-2002. Visual COBOL is an object
oriented version of COBOL.
MICROPROCESSORS AND

5.6
FUNDAMENTALS OF

the honour ofthe


inventor of the
MIfirstCROCOMPUTERS
PASCAL. Itis a high-level language
French
named
na
mathematician).
in
Thelanguage was
developed by
and business
mechaniWicalrth
Nicklaus
calculator, Blaise Pascal (a 1970s. It is suitable for both scientific
early As itis acompact language its
applications, and
in Switzerland in the
thenetore, it may be called a multipurpose language.
debugging is simpler. It
compiler
produces very
is quite
suitable for asmaller system. Program
design and from PASCAL runs efficient
when it is compiled. Program compiled It is more versatileseveral
th times
nes
machine-ode program from BASIC or FORTRAN.
and than
more the same program
modular compiled Besides numbers, PASCAL can also manipulate vectors,
than FORTRAN.
taster
sets, records, files and lists.
matrices,
BASIC. It isofancharacters,
strings abbreviation for Beginners All-purpose Symbolic Instruction Code. Itis suitable
scientific and engineering computation. It is not as powertulas FORTRAN. It is a simple and
tor application in microcomputere
language. It was introduced in 1965 by Dartmouth College. Its
steadily increasing.
Microsoft. It has replaced he
QBASIC. It is the recent version of BASIC. It was developed by
earlier version of BASIC (ie., GWBASIC), It is a menu oriented larnguage and uses GUI(Grapbical
User Interface). There is an intelligent editor to check syntax as the program line is entered. It uses
interpreter which translates program line by line. The object codes are generated as the statement is
entered allowing the program to run in single step. Errors are identified and reported in away that
allows the user to correct them immediately. In QBASIC each statement of the program is not num
bered as it is done in GWBASIC. In QBASIC statement can be numbered where necessary.
VISUAL BASIC. It is a scripting language used to combine small programs written in BASIC
language. It is avery powerful tool for developing Windows applications (Graphical User Interfaces,
GUIS). Earlier, Clanguage was used to develop Windows applications. The development of Win
dows applications in C language was a difficult task. VISUAL BASIC made the development of
Windows applications an easy task. It allows to create menu, text boxes, command buttons, option
buttons for making exclusive choices, check boxes for non-exclusive choices, list boxes, scroll bars
and file directory boxes. The user can use grids to handle tabular data,
Windows applications and access databases. Multiple Windows can be seen communicate with other
Basic has some features of O0P(Object Oriented on the screen. Visual
dows applications etc. Programming). It is widelyused today for Wn
CLanguage. It was developed at AT and T's Bell
Ritchie and Brain Kernighan. It is a general purpose laboratories in the year 1972, by Dernnis
sembly language programming. It allows manipulation of high-level language. It has the features of as
users can write low-level machine internal processor registers and theretore
instructions.
small so that the translator translates it into an Programs written in C language are concise and
which are equivalent to subroutines. These efficient machine codes. It supports library functions
supports modular and structured programming functions can be used by the programmers. C languas
guage, it is difficult to learn, particularly when concepts. Though it is flexible and efficient la
pointers are used
which allows programmers toextensively.
C language provides
variables are stored. C waspointers
first used to access inemory addresses wiy
compilerrand UNIX operating system toolswrite UNIX
operating
as asingle software system. AT and Thas developed C
run on PCs and larger package. Chas many versions which
ages such as operating machines. It is used to write system
software and commercial softwae p.
tem, various types ofsystem, compilerS, spreadsheet, word
specific application programs needed processing, dBASE manageme
applications etc. For complex for business and comne
understarnd and modify brief computation brief programs can be written. But it becomes
programs. difhcu
PAOGRAMMING OF MICROPROCESSORS 5.7

C++. Itis.an extension toClanguage.C++ is the superset of C(the commands of Clanguage are
C++). Astatementin Cis also a correct statement in C++, but thereverse is not true. It was
subsetof a Bell laboratoriesin the year 1980 by Bjarne Stroustrup. It is an object orientedlanguage.
developed
lat
high-levellanguages discussed earlier such as BASIC,. COBOL, FORTRAN, Cetc are not ob-
(Other
jtorientedlanguage,rather they are procedure-oriented language. In an object-oriented language,
while writing a program,the program1ner tells Only'what to do'. In a procedure-oriented language,
riting the prOgram the programmer has to tell'what to do' as wellas 'how to do'. OP'stands
ct-oriented programming. InOOP'objet' and 'class' are involved. C++ provides a collection
predefined classes. It also supports user-defined classes. Now-a-days object-oriented program-
ot swidely used.C++ is a very powerful and efficient language, but it is also difficult to learn.
is used towrite system sottware and commercial software packages such as operating ss
opilers,word processing, spreadsheet, database management, various types of specific ap
plication programsineeded for business ànd commercial applications, etc. C++ is replacing assembly
nuage in somelow-level machinecontrol software. Assembly language is also interspersed with
machine control functions efficiently.
C++to perform
C#. It is a java-like programming language developed by Microsoft recently. C# is pronounced
s 'see sharp'. Its codes are similar to Java, but it is not aJava clone. But it lacks cross-platform
capability which Javahas.Carnd C++ applications take longer time to develop. These languages are
äitficult and application programs become complex. Programmers need a language which is
powerful, efficient and quick to develop softwares. To meet these requirement C# has been
developed. It is a modern object-oriented language that enables programmers to develop new ap
features which
plication programs. C# is a hybrid of C and C++. It is closer to C++. It offers some
are available in Java but not in C or C++. It is a challenge to Java which is an established language
is to be seen
for cross-platform. Java is widely used for Internet applications.The performance ofC#
in the future.
Active XApplication Programs. They are just like Java applets. They have been developed by
can
Microsoft. They are written as components using which larger and more complex applications
be developed. They are just like building blocks of large and complex programs. They can be
downloaded from Internet. To run these application programs, a browser which supports Active X,
such as Internet Explorer, is needed.
It was
PROLOG. It stands for programming Logic. It is suitable for artificial intelligence. Using
developed in 1972 at the University of Marseillers. It is capable of handling large databases.
thas language rules-based application software suitable for expert system can be developed.
LISP. Itstands for List Processing. It was developed in early 1960s by MeCarthy. This language
for artificial
IS also suitable for artificial intelligence. Both PROLOG and LISP are excellent languages application.
htelligence applications. Their merits and demerits are examined for a specific space
TKOLOG needs less memory space than LISP and hence PROLOG is preferred where memorywhere
preferred
imited. LISP is more powerful in I/O handling and graphics and, therefore, it is
graphics and extensive use of I/O are needed.
used in com
As LISP is suitable for searching, handling and sorting long strings, it has been
Puterised translators.
mid 1960s. It
SNOBOL. It stands for String Oriented SymBOlic Language. It was develeped in
manipulate strings of characters and hence, it is used for text processing.
cOGO. It was developed at MIT in the late 1960s by Seymour Papertused and his colleagues. t has
for children as educa
bised in Universities for complex scientific problems. It has also been
al language to achieve intellectual growth and problem solving skills. Logo has graphic features.
5.8 FUNDAMENTALS OF MICROPROCESSORS AND
Children can draw, colour and animate images. It can also be used to compoSe music,
text, manage data etc. It runs on PCs.
MICAOCmaniOMPUpTulERaSt,e
APT. It stands for Automatically Programmed Tooling. It is used to control
manufacturing applications. machine tools in
JAVA. It is an object-oriented programming language derived from C**. It has been
by Sun Microsystems Inc.
on a computer
Applications written in JAVAare capable
of running on any platforro(:
system built around microprocessor of any manufacturer). It is suitable for
developed
desktop computers, servers, microcontrollers, etc. It is widely used for Internet applications.
is a JAVA program which is included in Web
document. Servlet is a program that handles.Atask
Internet,
pplet
server. Full-fledged JAVA based server is also available. JAVA
ment, JAVA Developer Kit is a tool set,and Java Script a Workshop development environ
is a
softwares based on JAVA provide developers enough resources scripting language based on JAVA.These
HotJava is a machine-independent interpreter for browsers. Java for programming at the desktop
Sors optimised to run Java based business and chips are dedicated microproces
embedded applications.
called Picojava. Pico]ava core design is the base for the Sun has developed a 'Core
Java' specification
MicroJava is microcontroller based on Picolava. This first-generation Java chips.
microcontroller has multimedia and graphics
capability.
JAVA has
Machine. It is cross-platform capability .
not a real machine. It is a How it achieved ? It is achieved using Java Virtul
is
memory. It does all major operations of a realsimulated computer which is stored in the computer's
machine codes, which are acceptable to Java machine. A Java compiler translates Java programs into
machine codes are known as virtual machine Virtual Computer (Java Virtual Machine). These
machine codes and gives an output. The output ofcodes. The Java Virtual Computer
java Virtual Computer is sent to a processes these
which gives machine codes for the Java Interpreter
computer
SQL. It stands for Structured Query which has to run Java programs.
query languages and has been adopted by Language. It is an international standard for database
INGRESS and INFORMIX. many database product supplier e.g.,
ORACLE, SYBASE,
1GL (First Generation
2GL (Second GenerationLanguage). Machine language is called 1GL.
Language). Assembly languages fall under the 2GLs. An
language is very close to hardware.
of the An assembly language assembly
microprocessor for which he is writing programs. programmer must know the architecture
3GLs (Third Generation
dure oriented languages. In theseLarnguages). High-level languages come under 3GLs. These are
how to do'. He has to write steps languages the programmer has to write 'what to do' as proce
FORTRAN,PASCAL, COBOL, C, etc. how to perform the desired task. Examples of 3GLswellareas
4GLs (Fourth Generation
oriented languages. While writing Languages). These are
the program in thesenon-procedural languages. These are object
what is to be done. Examples of 4GLS languages the programmer has to give ony
are : ORACLE, SYBASE,
higher-level than normal high-level languages. 4GLs are etc. 4GLs are considered to work at a
(Relational DataBase usually
System). Most 4GLs use SQL as a tool. C** application programs for RDBN
languages and hence, they come under 4GLs. and JAVA are also object-oriented
5.3.1 Advantages of High-Level
1. Instructions are very clear. Language
2. The writing of program in a
programs in assembly language. high-level language is easier and faster than the writing o
Acommon estimate is that the
program writing in a hug
5.9

lel la1U Is alit t n iles taster ln a hgh leel language


Wnt in oe st multipcation can be
T Ih' sme thmg n assemblv languaye program takes about 10

:haAS hih-level langlldgS are otatle te they can run on any computer or
NInuter having st.a:dand ompler tor that language
Faserdinumentation.
1e pngan is idendent ot the stnctu of a particular computer The pogram iS
nlen i n irather thancomputer onentnd
Rianisnta.

(&2 Disadvantages of High-Level Languages


he has t larn the rial ules tor writing prgrams in a particular high-ievel language
Low swi. he statement in a high-level language corresponds to manv instructions in
mhine lnguae. Hence, the high-level language takes mone time to produce result :
Mmputation time is mOre.
Low etfhcieny of memorr utilization. A pngram in high-level language occupies a larger
nrtot the memov.
4 Extensive hardware and software supports are required.
3. A
compider has to be provided to convert ahigh-level language program into a machine
language program. The compiler is costlv:
i4 AREA OF APPLICATIONS OF VARIOUS LANGUAGES
Each prvgramming language has its oWn merits and demerits. Depending on the tvye ot prob
Os and situation asuitable programming language is seleted. Though hizh-level languages
The cost of peripherals such
ve convenient and powerful, thev cannot be used in all situations.
provide the facilitv for
Ompler, floppv disk svstem, CRT ete. is verv high. Asvstem which can
-h-ievel language, incorporates costlv peripherals,and the total cost of the svstem lies in the range
recommended where cosdv Svstem is
Rs 50000 to a few lacs of rupees. Such costlv svstem can be
data are to be handled. The main aim oi
e conrolled or more computations and large volume of
controlling device. It forms
¿iroproressor-based svstem is to provideinexpensirepvgrammable
micnpvesor applications in auto
Erartof amachine or equipment to be controlled. Most of
not suited to high-level languages. In such
TZT control, instrumentation, communication etc. ar
status intornahion trom input devies and
*cations microprocessors simply receive data and applications the machine or asembly lan
and control signals to output devices. For such
idata microprocessor-based system which is ued tor industrial
control,
preferred. In atypical
;-ige is
program to be executed is a fixed one. The rvgam is not changed or
-srumentation etc., the machine langu.ige andstod in EPROM at
Such aprogram is written in the
hed by the user. programming languages are
applications of different
ime of development of the system. The
scrbed in the subsequent subsections.
4.1 Machine Language
following situations:
ihe machinelanguage is preferred for the
1. For small and simple programs.
Simple control applications where less computation is required
2. final product.
3. Applications where prototvpe is the
ANGRAMMMINGOF MICROPROCESSORS

times faster. In a
languageis about ten 5.9
level
writteninnoone pQ. The same
step: S = high-level language
thing in assembly
lines.
multiplitakes
anguage program caticonabout
can be
10
3 Programs in high-level languages are portable ie. they carn run
micocomputer having standard
Easier documentation. compiler forthat language on any
computer or
program is independent of the
4

5 The
poblem structure
oriented rather than computer orientedof aparticular
computer The
Standard syntax. program is

Disadvantages of High-Level
632 Languages
Onehastolearnthe special rules for writing
1.
speed. One statement in a high-level
programs in a particular high-levellanguage
: Low language corresponds to many instructions in
machine language. Hence, the high-level language takes
omputation time is more.
more time to produce resuit ie
3. Low efficiency of memory utilization..A program in high-level language occupies alarger
part of the memory.
4 Extensive hardware and software supports are required.
: Acompiler has to be proVided to convert a high-level language program into a machine
language program. The compiler is costly.
# AREAOF APPLICATIONS OF VARIOUS LANGUAGES
Each programming language has its own merits and demerits. Depending on the type of prob
.cost and situation a suitable programming language is selected. Though high-level languages
Ever convenient and powerful, they cannot be used in all situations. The cost of perip'erals such
sCompiler, floppy disk system, CRT etc. is very high. Asystem which can provide the tacility tor
ngh-level language, incorporates costly peripherals, and the total cost of the system lies in the range
tks 50,000 toa few lacs of rupees. Such costly system can be recommended where costly svstem is
*Controlled or more computations and large volume of data are to be handled. The main aim ot
Suroprocessor-based system is to provide inexpensive programmable controlling device. It iorms
part of a machine or equipment to be controlled. Most of microprocessor applications in auto
t COntrol, instrumentation, communication etc. are not suited to high-level languages. In such
plications from input dev ices and
receive data and status information
controlIsignals tosimply
ad data and microprocessors output devices. Forsuch applications the machine or assembly lan-
Siage is preferred. In a typical microprocessor-based system which is used for industrial control,
one. The program is not changed or
odistrfuiement
d ation etc., the progranm to be executed is a fixed
language and storedin EPROM at
etime ofbyf development
the user. Suchof atheprogram
system. written
is The in the machine
applications of ditterent programming languages are
sribed in the subsequent subsections.
Machine Language
The machine language is preferredfor the following situations:
1. For
smmalcontrol
2 Simple
3
l and simple programs.
applications whereless computation isrquired.
Applications where prototype is the final product.
5.10 FUNDAMENTALS OF MICROPROCESSORS AND MICROCOMPUTERe

5.4.2 Assembly Language


The assembly language is recommended in the following situations:
1. Small to moderate size of
program.
2. Real-time control applications.
3. Small volume of data are to be processed.
4. Where cost of the memory is a consideration.
5. Where less computations are required.
6. In training kits.
7. instrumnentation
While developingetc.a program for microprocessor-based system for industrial control,
8. For industrial application.
5.4.3 High-level Language
High-level language is recommended for the following situations :
1. For large
2. Where largeprograms.
volume of data is to be processed.
3. More computation is involved.
4. Applications requiring large memories.
5. For complex mathematical
computation.
6. Applications where high cost is justified. The
high cost is involved in peripherals and
software supports associated with high-level language.
For microcomputers future trend is in the favour of
reasons: high-level language due to the following
1. Hardware and memory are
2. Software and programmers are
becoming less expensive.
becoming more costly.
3. Large size of memory chips are available at low cost.
4. Compilers are easily available.
5. Efficiernt high-level languages are
being developed.
5.5 STACK
During the execution of a program sometimes it
tain registers because the registers becomes necessary to save the contents of cer
are required for some
other operation in subsequent steps. These
moved to certain memory locations by PUSHcontents are
Then the registers are used for other operation.
operations.
completing these operations those contents which After 2604
saved in the memory are transferred back to the were 2605
by POP operation. Memory registers
locations
set aside by the programmer in the for this purpose is 2606
beginning.
memory locations kept for this purpose is called The set of
2607
NEXT AVAIL ABLE
LOCATION
The last memory location of the stack.
stack is called stacktop. Aspecial occupied portion of the 2608 SP

16-bit register known as 6B


2608
stack pointer holds the address of stacktop. The stack
pointer is initialized in the beginning of the program by STACK TOP
LOCATION
iXI SP or SPHL instruction. Any area of the RAM can be
Fig. 5.1. Stack and
stacktop location.
PROGRAMMING OF MICROPROCESSORS 5.11

used as stack. There is no restriction onthe location of the stack in the memory. Data are stored in the
stack on last-in-first-out (LIFO) principle. Stack access is faster than memory access. Fig. 5.1 shows a
typicalstack and stacktop location. The SI' register holds the address of stacktop location. Fig. 5.2 (a)
shows the position of astack before PUSH operation. Suppose that the conternts of the register pair
B-C is to be pushed. After PUSH operation the stack position has been shown in Fig. 5.2 (b). Similarly,
POP operation is used to transfer the contents from the stack to the register. The stack position before
and after the POP operation has been shown in Fig. 5.3(4)and (b) respectively.
PUSH B REG B REG C

2A
REG B REG C
2602 03 2A

2603 NEXT AVAIL ABLE LOCATION


2602
NE XT AVAILABLE
LOCATION
2604 2603 2A
2603 SP
A1 2605 SP 2604 83
2605
2605 A1
2606 28
2606 2B
2607 2A
2607 2A

2608 68 2608 6B

Fig.5.2 (a). Stack before PUSH operation. Fig.5.2 (b). Stack after PUSH operation.

POP B REG. B REG C


53
REG B REGC
38
84

2604 NEXT AV,AILABLE LOCATION


2605 2605
2605 SP
NEXT AVAILABLE LOCATION
2606 2606

2607 9 2607 9C 2607 SP

2608 1 2608 19

Fig.5.3 (a). Stack before POP operation. Fig. 5.3 (b). Stack after POP operation.
5.6 SUBROUTINES
While writing a program certain operations may occur several times and they are not available
as individual instruction. The program for such operations are repeated again and again in the main
program. Asimple example of such operation is multiplication. The Intel 8085 does not have any
instruction for multiplication and hence, aprogram is written to perform multiplication. Similarly
small programs are written for functions like sine, cosine, logarithm, square root etc. for Intel 8085.
The concept of subroutines is used to avoid the repetition of smaller programs. The small program
foraparticular task is called subroutine. Subroutines are written separately and stored in the memory.
ANDMICROCOMPUTERS
5.12 FUNDAMENTALSOF MICROPROCESSORS

MAIN PR0GRAM sUBROUTINE


They are called at various points of the main program by CALL
instruction where they are required. The last instruction of the
subroutine is RET. After the completion of asubroutine, the
main program begins from the instruction immediately follow CALL SUBAROUT INE
ing the CALL instruction. There may be more than one sub
routine in a program. The technique of subroutine saves
memory locations. Some important subroutines may be written
in a ROM bythe manufacturer. Such subroutines are called by CALL SUBROUTINE RETURN
special instructions given by the manufacturer in the manual.
Fig. 5.4 shows a CALL-RETURN structure.
When program execution jumps from the main program to Fig. 5.4. CALL RETURN structure
a subroutine, the content of the program counter is saved in the of subroutine.
stack so that the program execution may come back to the mairn
program at the proper point after the completion of the subroutine.
5.7 SYSTEM SOFTWARE

The hardware of a computer system can not do anything by itself; software is required to direct it
what to do.The system software is acollection of programs written for acomputer which allows user
to develop andrun his program. The system software is stored in ROM/Disks. It includes operatirg
system, BIOS, assembler, cornpiler, editor, etc. An operating system is a collection of programs. It
controls the overall operation of a computer. It provides programmers an interface to a computer.
Asimple operating system is called a monitor. Amicroprocessor-kit or a
system is provided with a monitor. It resides in a ROM microprocessor-based
or EPROM. PCs, minicomputers and large
computers are provided with an operating system. It resides on hard disks.
5.7.1 Monitor
Amonitor is a program which resides in a ROM or PROM. It carries out the
(i) Initialisation of the system following functions:
(ii) Loading of programs into RAM.
(iii) Control of input and output devices.
(iv) Displaying of the contents of internal CPU
(v) Modifying the contents of CPU registers or registers or memory location.
(vi) Executior of the program which is in RAM or memory location.
ROM.
In a mícroprocessor kit a monitor
ging programs like controls its entire operation. It contains subroutines for
debug
mands like INSERT,single step operation and program for inserting
DELETE, breakpoint. It also contains com
user in entering and executingDELAY, RELOCATE etc. It controls CRT terminal, printer etc. It helps
machine code program.
In an MDS or
sophisticated microcomputer, minicomputer or large
BIOS there ís a powerful
tion of BIOS is to load theoperating system. The operating system is stored oncomputer in addition to
a disk. The major
operating system into RAM,and to control basic func
5.7.2 Operating System input/output operations.
An operating system of a
sible for managing files on thecomputer is the main component of the
disks and communication system software. It is respon
memory space management, job scheduling etc. It is a between the computer and peripherals.
usually stored on disks. program or collection of programs which
are
PROGRAMMING OF MICROPROCESSORS 5.13

An operating systemhelps user in performing the following tasks:


() To create disk files
(ii) To write programs and data into files; edit them and store them
(ii) To read data from files
(iv) To link subroutines with the main program
(v) To load programs and execute them
(vi) To debug programs.
An operating systemrelieves user of the burden of keeping track of tracks and sectors of the
disks. All these are done by the operating system. It allows programmer to write high-level language
programs without knowing the hardware details of the computer system.
An operating system contains following standard programs which help users in the develop
ment of programs :
File Manager. File Manager is a program which allows user to create, delete, copy or update
files on the disks. The term file refers to the collection of informations supplied by the programmer,
which is stored on the disk as a single entity and is accessible by name.
Linker. A large program is divided in smaller programs known as modules. It is easier to
develop, test and debug smaller programs. A linker is a program which links smaller programs
together to form a large program. While developing a program subroutines, which are stored in
library file, are frequently used in the program. The linker also links these subroutines with the main
program. The linker links object code (machine code) program. It takes up user's program after the
editor hasedited the program and assembler/compiler has produced object-code of the program.
Locator. A locator is a program which assigns specific memory addresses for the machine
codes of the program to be loaded into the memory.
Loader. A loader is a program which loads object code into system memory. It can accept
programs in absolute or relocatable format. If the actual addresses of instructions and data are given
bythe programmer, i.e. the program is in the absolute format, the loader simply loads the program
into memory. If programs are in relocatable format the specific memory addresses are assigned by
the locator before the loader loads the program into memory.
Debugger. Debugger is a program which llows user to test and debug programs. All com
puters including microprocessor kits provide debugging facility. To detect errors a program can be
tested in single steps. Each step of the program is executed and tested. The debugger allows user to
examine the contents of registers and memory locations after each step of execution. In microproces
sor kit SINGLE INSTRUCTION (SI) key has been provided to test programs in single steps. For
details see Section 5.8.3. Debugger also provides facility to insert breakpoint in the program. For
details see Section 5.10.
Assembler or Macroassembler. An assembler or macroassembler generally forms a part of
the operating system of an MDS, microcomputer and personal computer. An assembler is aprogram
which translates an assembly language program into machine language program. For details see
Section 5.2.
An assembler having facilities for macro is known as macro-assembler. For details see Section
5.14.
Important operating systems have been discussed later on after the description of text editor arnd
compilers.
5.14 FUNDAMENTALS OF MICROPROCESSORS AND MICROCOMPUTERS

5.7.3 Text Editor


Atext editor isaprogram which allows user to write source program or text into RAM. The user
writes his program in assembly or high level language in proper format. Aprogram written in these
languages in the proper format is known as source program. The typing or program errors areeasily
corrected using the commands of the editor. To correct errors the cursor is moved on CRT screen
where corrections are to be made and correct characters are typed in. The user can add or delete lines
anywhere in the program using proper commands of the editor. As program is typed in the ASCII or
EBCDIC codes for the characters of the program are stored in successive RAM locations. When the
source program has been typed in and corrected using editor commands, it can be copied from RAM
to a file on the magnetic disk. Such file is known as source file. If errors are detected later on the source
program can be loaded from the source file into RAM and corrections can be made.
Asimple editor may form apart of the operating system but powerful editors are loaded separately.
5.7.4 System Software, Application Software and Utility Programs
System Software. The software required for running user programs is known as system
software. It includes monitor,operating system,compiler, interpreter etc.
Application Software. Special purpose software written for specific use is known as applica
tion software. Examples of application software (or programs) are accounting packages, database
management packages and computer-based engineering design packages.
Utility Programs. These are software tools which help users in developing, writing,
and documenting programs. The utility programs can be classified into debugging
the following two categories:
() File Management Utilities. These are
and renaming files. These programs form a partprograms
to help users in copying printing, erasing8
of the operating system.
(i) Program Development Utilities. These are
programs. These are text editor, assembler, loader, linker,programs to help users in writing and testing
locater, debugger, compilers etc. Assembler,
loader, linker, locater and debugger are included in the operating
included in the operating system. More complex editors are stored system. Asimple text editor may be
separately.Programs loaded separately alsO run under the control ofseparately. Compilers are loaded
the operating system.
5.7.5 UNIX, ZENDX, etc.
UNIX is a 32-bit multiuser,
able. Initially, it was written in multitasking,
assenbly
time sharing operating system. 64-bit UNIX is also avail
language like all other operating system of that time. It was
written by Ken Thompson and Denis Ritchie in 1973 at BellTelephone
became AT&T. Originally, it was written for a small Laboratories which later on
a high-level languageCby both computer PDP-11. In 1977, UNIX was written in
Thompson and Ritchie together. Initially, it was designed for small
computer, but it is now used on various machines ranging from powerful
Computers. Its key advantage is that it is not microcomputers to super
to run on a microprocessor of any make. It istied to a specific microprocessor. It can easily be modified
It is used with Presentation well suited for networking and
Manager or X-WINDOWS to provide graphical environment.
fledged graphical user interface (GUI)called motif was put on thegraphical interface. Later on,, a full
UNIX consists of three layers as shown in Fig. top of X-WINDOWS.
multiuser operating system is from protection point of view. 5.5. The provision of two or more
layers in a
Its inner layers are well protected.
can not write into the menmory area
achieved by allowing user programs where inner layers of operating system are stored. Users
to access operating system This is
mechanism rather than simple, accidental resources through very
call or jump. Amultiuser operating system is specific
tackle the problems of protection, memory
allocation and management, sharing ofdesigned to
resources,
PROGRAMMING OF MICROPROCESSORS 5.15

preserving registers, data and return address of each user. ApicGtionPrograme


The innermost layer, Kernel, is the most important layer.
0tcontains a process scheduler and a hierarchal file structure.
Since UNIX is a multiuser operating system, a number of Shell

users are entertained simultaneously on a time-slice basis. To


process multiple programs or tasks sequentially, ascheduie
must be prepared. The part of this operating system which
(Cnmomong
Kernel

makes scheduling is called scheduler, despatcher or super


visor. The user's program or task or job is known as a
process. Time-sharing provides a popular scheduling techni
que for multiprogramming with multiaccess interactive
users. Schedule of loading and execution of programs is
Progr 9rommin9 Tools an
done in order to provide a continuous job processing se
quence. Further UNIX Kernelcontrols the resources and al
locates them among users. It controls peripheral devices Fig. 5.5 UNIX layers
such as printers, disks, etc. It provides users with file systems
to store programs and data.
The middle layer of UNIX is called shell. It contains command interpreter. The user's commands
are decoded and interpreted by this layer. This layer of UNIX provides interface to users. The shell
provides anumber of commands. The programmer can write a series of shellcommands and store
in a file to perform certain task. This hle can be made executable. The outermost layer contains
programming tools and application programs. The programming tools include assemblers, com
pilers, editors, debuggers, etc. The application programs include software packages for word
processing., database management, graphics, etc.
UNIX provides a feature called pipe. Using pipe command the output of one program can be
sent directly as input data to another program.
Anumber of versions of UNIX exist. Examples are : XENIX, VENIX, MICRONIX, Berkeley,
Apple version A/UX, IBM's AIX,LINUX, UNIXWARE7, etc. These versions have been developed
by different organizations. XENIX was developed specifically for multiuser PC system by Microsoft
in late 1970s and early 1980s. AIX is for IBM's RS/6000 computers which are based on Power PC
RISC processors. It is available today by SCO (Santa Cruz Operation). SCO is selling SCO UNIX
WARÉZ, which is a32-bit operating system for Intel processors.
64-bit UNIX is available from Digital Equipment Corporation since 1993. It is known as 64-bit
Digital UNIX. It can address upto 14 GB memory. 64-bit operating system is very useful for Internet,
multimedia, very large database, etc.
UNIX uses preemptive multitasking. The term multitasking means the capability to run multi
ple programs at the same time without hindering each application from running. In preemptive
multitasking each application program gets a fair share of processor time. It provides smooth tran
sition from one application to another. The actual time given to each task is decided by the user and
the operating system based on certain criteria.
There are a number of versions of UNIX.Attempts have been made to have a single specification
to be used for 32-bit and 64-bit UNIX developed by different developers. The single UNIX specifica
tion standard is now being used for 32-bit UNIX. Open Group is defining and enforcing the standard.
5.7.6 LINUX
It is a multitasking, multiuser operating system for several types of computer platforms, but
primarily for Intel-based PCs. It uses preemptive multitasking. The system has been designed and
MICROCOMPUTERS
5.16 FUNDAMENTALS OF MICROPROCESSORS AND

built by hundreds of programmers scattered around the world. The goal has been to develop a UNIX
LINUX
clone, free of any commercially copy righted software, that the entire world can use. Actually, a more
was started by acomputer science student named Linus Torvalds. He wanted to develop
robust version of UNIX. His desire was to develop the replacement of the Minix operating system
which was developed by Professor A. Tannebaum. The Minix System was written to demonstrate
severalcomputer science concepts found in operating systems. Torvalds included these concepts
intoa stand-alone system that mimics UNIX. He named it LINUX. It includes most of the commands
of UNIX. LINUX runs on widely available IBM PCS. It also runs on DEC Alpha, SUN SPARCS,
PowerMacs, etc. It comes with complete implementation of TCP/IP networking protocol. TCP
stands for Transmission Control Protocol. IP stands for Internet protocol. TCP/IP is the largest
protocol standard functioning on both LANs and WANS. It provides error checking, flow control (to
prevent swamping of auser by another faster or more powerful user), and status and synchronous
control.TCP works with IP. They are simply different layers of control. TCP is transport layer. IP is
network layer which handles routing and delivery. With LINUX one can connect to the Internet. It
also provides a complete E-mail system. It also has a complete graphical user interface (GU) using
X-Fre 86 which is based on X-Windows system. The X-Windows system is a powerful graphical
environment that supports applications across a network. It was developed at MIT and can be freely
distributed. Anumber of applications programs are available today which can run on LINUX. Ex
amples are :application programs for databases, wordprocessing, telecommunication,wide range
of games, etc.
5.7.7 Intel RMX 86
It is a multitasking operating system for real-time industrial control. It works on the principle of
priority-based scheduling. UNIX works well for a multiuser time-share system. But it is not suitable
for real-time industrial control which requires operation on priority basis. It is not fast
enough to suit
the requirement of real-time control.
5.7.8 WINDOWS Family
INTRODUCTION. Microsoft corporation developed agraphical user interface (GUI) in the year
1990, called WINDOWS. It provides menus and icons (small
representative pictorial images) to in
teract with the computer instead of typing commands. It presents
menus arnd graphical symbols. WINDOWS was not an operating system.programs, procedures and files as
It was simply a computer
software. It was working under DOS operating system. Its different versions were WINDOWS 3,
WINDOWS 3.1 and WINDOWS 3.11. It was a slower system.
Later on Microsoft developed WINDOWS 95,
(Millennium Edition), WINDOWS NT, WINDOWSWINDOWS 97,WINDOWS 98, WINDOWS Me
2000 , 2003 and WINDOWS XP operating sys
tems. The operating system WINDOWS95,97, 98 and Me were for single user
NT and WINDOWS 2000, 2003 for multiuser system i.e. a computers. WINDOWS
system WINDOWS XP. It includes features of
is for computer network. The latest operating
as WINDOWS NT& 2000 series. XP stands forboth series WINDOWS95,97,98 and Me series as well
DOWS XP Professional and WINDOWS XP Home. eXPerience. WINDOWS XP has two versions:WIN
The
more powerful than Home version. The Home version isprofessional version is for business users. It is
for consumers or home users.
WINDOWS -95 is amixed 16-bit and 32-bit multitasking single user
provided with graphical user interface (GUI) of Microsoft, operating system. It is
tures like virtual memory process management and called WINDOWS. It includes the fea
have the limitation of memory addressing capacity. DOSmultiprogramming. Unlike DOS it does not
has the
WINDOwS 95 takes full advantage of memory addressing capacity memory limitation of 640KB.
of a 32-bit microprocessor. It
PROGRAMMING OF MICROPROCESSORS 5.17

always runs in protected mode. It uses long file name in place of 8+3 character file names allowed in
MS-DOS. It does not eliminate MS-DOS completely. It includes MS-DOS version 7to run DOS ap
plications, to provide some low-level BIOS support on non-plug and play machines and to support
antiquated devices that use real-mode drivers.
WINDOWS-98 is an enhanced version of WINDOWS-95. It is faster and easier to use. It is a
complete operating system provided with agraphical user interface. It provides multitasking and
multiple windows. It does not require as many mouse clicks and double clicks as required by pre
vious versions. It includes a new program called Outlook Express that manages both E-mail and
newsgroup informations. Newsgroups are thousands of lists, arranged subjectwise, that contain
messages and files that users can post and read. It allowsusers to manage incoming and outgoing
messages easily. The Internet's online environment is more closely associated with Windows-98
desktop. The start menu is more operational and allows users to make menu on the fly without
messy dialogue boxes. Improved Plug-and-Play features enable users to plug new devices into the
computer without having to set hardware switches or determine appropriate interrupt settings. Ad
vanced system tools now help protect user's computer files and monitor hardware. Windows-98
supports universalserial bus (USB), advanced laptop docking and infrared ports. It has 32-bit en
vironment.
It has web integration that blurs the distinction between PCon the desk and the Internet. It
provides Web-based desktop environment. One can place Web pages right on the desktop instead of
accessing the Internet solely from an Internet browser program. If someone wants help, he can search
Windows-98 help files or access Internet to locatea help topic -all from within the desktop environ
ment. It helps you access the Internet as easily as you access the files on your own PC. It provides
more efficient disk storage system called FAT32 which makes hard disks of holding almost twice as
much as before.
Windows-98 provides a feature known as Direct Cable Connection which allows transfer of files
between computers without need of a network and without moving data between the PCs via disk.
When two computers are connected through a high-speed parallel or serial cable, those computers
can share files and printer resources with one another. This is asimple replacement for an expensive
network if someone wants only two computers to share resources.
WINDOWS Me. Microsoft launched WINDOWS Me, an improved version of its operating sys
tem for home PC users,in the year 2000. Me stands for Millenium.It is largely an extension of WIN
DOWS-98. WINDOWS Me is provided with new and improved music, film, digital photo and
Internet features. It contains Windows Media Player 7, Movie Maker and Internet Explorer version
5.5. It makes PC technology simpler and the Net (computer network) more accessible.
WINDOWS-NT (WINDOWS New Technology). It is a 32-bit multitasking, multiuser operating
system. It provides graphical user interface. It has been developed by Microsoft. It has networking
feature. It gets rid of DOS altogether. It is not restricted to only Intel microprocessors. It is also used
with microprocessors of other manufacturers. It is used for PowerPCs, DEC's Alpha, MIPS proces
sors, etc. It uses preemptive multitasking. It is based on client/server principle which is commonly
used in network computing system. Aserver is acomputer which offers services for other computers
on the network. Services may be any kind of program-routine or data provided by the server. For
example, aserver may provide information froma database which you do not have direct access. A
client is acomputer which gets services from aserver. The client makes contact with aserver on the
network and requests for some sorts of services. It supports TCP /IP, IPX/SPX, data link control for
mainframes, Apple Talk (a packet protocol) for Macintosh network integration, Network File System
created by Sun, etc. TCP is Transmission Control Protocol, IP is Internet Protocol, IPX is Internet
oOFF 99i1555900, 95218218A
5.18

Packet
EXTRA|
FUNDAMENTALS
N vIsTING GUR
OF
MICROPROCESSORS AND
Porate asExchange, and so on.

teatures
well as in small and
WINDOWS-XP
of both
is an
WINDOWS-NT
medium
operating system
the features of a single user operating systemdeveloped
XP stands for networking
becamethe preferred
size enterprises.

such as
operating
by Microsoftin the
year 2001.
MICROCOMPUTERS
system in
l arge cor-
operating WINDOWS 98 and .It
WINDOOWS-XP
is for
eXPerience.
Media
It
Center
has four system n
(multiuser
versions:WINDOWS-XP
Edition and
WINDOWS includes
system) such as WINDOWS Me as welltheas
and servers. It isThefor professionals and WINDOWS Tablet PCProfessional,
consumers.
operating system for single professional
user and
business applications.
version is the superset
Edition.
The
of Home home version
The WINDOWS-2000.XTPhe
professional
is foor
term
Home,
vot
WINDOWS-XP
surf Internet.
people in Microsoft
other
adds features that smaller
make it
gives an interface called
system.
easier to download
Version. Today it is. home users
wid ely used
activitiesIt such as online
Over the Internet. luna with music, process digital photos, and
button but makes Net offers customers shopping,
a nmore
publishingphotosWINDOWS-XP.
to the Web, This interface helns
panel more intuitive. connectivity, E-mail streamlined Windows look. It and sharing
The access and
interaction retains the Windowsapplications
and TV WINDOWS-XP Media
Thethrough convenient user interface
a Center Edition allows users to
with system settings via
Start
control
WINDOWS-XP
capability.
as you
Tablet PC Edition is formakes easier everexperience
Users can use digital
that
to enjoy video, audio, pictures
would with a mouse. Also,penit isto write directly notebook computers. It digital media.
WINDOWS-XP and 64-Bit Edition has been
on the screen
provided with built in and control provides pen
their and speech
wireless computers just
WINDOWS-2000
DOWS-2000.
ferent versions: WINDOWS
It is a
multiuser
developed.
Server 2003.
Its
version 2003technologies.
is
available.
operating system withWINDOW-NT version5 was
WINDOW-2000 Advanced Server networking features. It wasrenamed as WIN
WINDOW-2000
WINDOW-2000 Server
Data Center
Server available in dif
WINDOW-2000
The Professional
WINDOWS-2000 Professional is for workstations and PCs.
types of servers.
WINDOWS
WINDOWS Server 2003 is a
Server 2003 providesmultiuser
Other versions are for
diferent
managingandand a operating
XML Web revolutionary system for
networks Webrunning from a services. It tois application
servers, developed in the year
WINDOW-2003 services
Standard Edition
a
workgroup dataplatform environment
for for
building, 2003.
deploying
powering connected applications,
center. Its different
WINDOW-2003 Enterprise Edition
WINDOW-2003 Data Center versions are:
WINDOW-2003 Web Edition Edition
5.7.9 Other Operating
Systems
SUN's Solaris. SUN's
user interface. It
supports Solaries version 2.6 is a
developed its own version ofnetworking and internet 32-bit operating system. It provides graphical
UNIX, called (TCP/IP), SUN's subsidiary SUNSOFT
OpenWindows. OpenWindows includes Berkeley
PROGRAMMING OF MICROPROCESSORS 5.19

derivative of UNIX alongwith its Open Laok graphical, look-and feel desktop manager. This entire
bundle is called Solaries.
SUN has developed 64-bit operating system Solaries version 7. Under Solaries 7installation and
administration have been made more user friendly with Wizards' and other user-oriented automat
1on tools. SPARC processors or Intel processors can run under Solaries 7. 64-bit Solaries 7 is
downward compatible with 32-bit programs and infact runs them faster than they run under the
32-bit operating system.
Solaris version 9 comes with several new features. It integrates various middleware and
management components. It integrates application server, directory server, security arnd Web ser
Vices. It is an operating system for UNIX server. The integration of middleware with Solaris 9 rnakes
iteasier to build and deploy applications and Web services based on Java, XML, and SOAP tech
nologies. SOAP stands for Simple Object Access Protocol. It is a useful protocol for Internet, intranet
and extranet.

Apple's Macintosh Operating System Mac OS 8.5,9 and X. Apple's Macintosh operating
system was the first operating system which used graphical user interface (GUI). It was widely used
on Apple's 680X0processor based computers. Its earlier versions were Macintosh Systern 7.x. For
PowerPC processor Apple developed Power Macintosh which was developed through 680X0
software processor emulation. For Power Macintosh Soft Windows is also available, which provides
a complete emulated Windows platform. The software emulates a high-speed 80286 processor and
runs most Windows software. This gives Power Macintosh a dual operating system capability. Mac
OS 8.5 is faster and it can easily be installed in less than 15 minutes. It costs about 100 dollars. Its
performance is 3 times faster when saving files over the network. It has improved internet search
functionality. From a single dialog box, auser can search files by content and search the Internet
using several different engines, such as Excite and HotBot, simultaneously. ColourSyn printout,
video, or Web site of what users see on their screen is an area where the Macintosh excels over Win
dows platform.
Macromedia Inc.'s Flash and Shockwave Internet applications player software is packaged with
Mac OS 8.5. Flash and Shockwave Web are applications which allow users to view and participate in
Internet multimedia content including games, animated interfaces, interactive demos, vector-based
Web graphics and cartoons, without having to download and install other plug-ins or software. The
Mac OS 8.5 has also new Web capabilities. The software has a tool named Sherlock, can search for
information on the Internet and on a desktop hard drive simultaneously.
Mac OS version 9 and X(ten) have also been developed. Mac OS Xis provided with the ease
of-use of the Mac and the power of UNLX,blended into a single operating system. It combines new
applications, ease-of-use and a brand new interface, Aqua. The Aqua interface brings Mac to life
with colour, depth, translucence and fluid motion. Buttons indicate active or non-active by glowing
and diming, icons are crisply rendered, and drop shadows give windows depth. Dock is an addition
to Mac OS interface, which holds folders, applications, documents, storage devices, minimized win
dows, QuickTime movies, digital images, links Web sites etc. The Mac OS Xcomes with a new
graphics engine, called Quartz, which is based on Adob's portable document format.
64-Bit Iris. It is a 64-bit operating system developed by Silicon Graphics Inc. It is being used
since 1994.
Novell Netware Version 5.0. It is a network operating system. It is a multitasking, multiuser
operating system. It fairly time slices between processes. Computers connected on the network share
files and resources like printers, plotters, storage devices and computing power. It also provides
electronic mail facility. When we compare the multitasking ability of UNIX and NOVELL Netware,
MICROPROCESSORS AND
FUNDAMENTALS OF MICROCOMPUTERS
5.20 his
multitaskingtothe userat workstation. On
extends theabilityof operatingsystem but does not: allow users
we findsome differences. UNIX multitasking
the other hand Novell Netware by itself is a
themselves ontheir
workstations.
to pertorm multitasking 3operations by
Internet environment besides traditional features of
in the resources. Version 5.0 offers
Novell Netware 5.0 offers services LAN to share files and
the s
on
providing facilities to computersservices, IPX-to-IP support which enablesIPX-based LANsto con-
centralised network management
nect to lP-based networks. bandwidthneefficiently, simplifies protocol
(lIP) uses network
Netware 5's PURE Internet integration with available solution. It also supports other Internos
tprotocol
management and offers better directory services. It also includes what is claimed to he
protocols, in its enhancements to the key
Machine (IVM) for server-based applications and services written in Java
word's fastest Java Virtual
Netware was widely used in LANS. Now situation is changing with the development of
Novell become now the competitor of
WINDOWS-NT which is also a network operating system, and it has in large cor
Novell Netware. WINDOWS NT has been preferred networking operating system
the market share of UNIX.
porates as well as in small and medium-sized enterprises. It is also grabing
5.7.10 BIOS
BIOS stands for Basic nput Output System. It is a set of programs to provide most basic low-level
services such as services for keyboard, disks, serial port, printer, display, bootstrap, etc. BOS programs
are stored ina ROM. The term ROM-BlIOS is also used. There is BIOS at operating system (OS) level also.
OS-BIOS povides services at user's level such as to create,edit, read, write file and so on.
When power is switched on ROM-BIOS takes the control of a computer. First of all, ROM-BIOS
programs for power-on-self test are executed. These tests check that whether the computer is in
proper working order; allunits of the computer are functioning or not. Check test is performed to
examine memory for defects and to see that the computer is not malfunctioning. After power-on-self
test is performed booting process is done. The process of loading the operating system into main
memory is called booting. ROM-BIOS contains a program called bootstrap loader. This
directs CPU to read from the disk a specific program called boot (a program
svstem) and to load it into the main memory. When this boot small portion of the operating
System is loaded into the main memory from the disk. Other program is executed, the operating
programs of ROM-BIOS are to analyse
system configuration, for I/O supports for disks, keyboard, CRT,
printer, etc.
ROM-BIOS chip is placed on the motherboardof the computer. Certain
controller, SCSI controllers, etc. may contain their own adapter boards such as
ROM-BIOS to control their own functions. VGA
5.8 SOME IMPORTANT COMMANDS
The microprocessor kits used in
checking, INSERT, BLOCK MOVE, DELAY laboratories have commands like DELETE, SINGLE STEP
etc. Some of these
5.8.1 INSERT commands are described below:
The INSERT Command
gram. The format issINS facilitates the programmer to insert one or more
(<LOLMT>)
ber of bytes to be inserted> NEXT (<HILMT>) NEXT
NEXT <Data> <Low Insert instructions in the pro
highest addresses of the user's NEXT, .., EXEC. LOLMT and Address> NEXT <Num-
program
first byte has to be inserted. When respectively.
INSERT The lowinsert HILMT are the lowest and
key is address is the
address field. LOLMT is i inserted and then next key ispressed some address will beaddress where the
displayed in the
are done in a sequence as showninin the
format. The pressed. Now HILMT is
kit press SHIFT before pressing INSERT key. above format is for inserted. ( Other entries
Professional''ss kit. For Vinytics
PROGRAMMING OF MICROPROCESSORS 5.21

5.8.2 DELETE
This command is used to delete one or more instructions from the program. The format is as
follows:
DEL(<LOLMT>)NEXT (<HILMT>) NEXT <Low
Delete Address> NEXT <High Delete Address> EXEC.
The low delete address is the address of the first byte to be deleted. High delete address is the
address of the last byte to be deleted. The above format is for Professional's kit. For Vinytics's kit
press SHIFT before pressing DEL key.
5.8.3 SINGLE INSTRUCTION
This command helps programmer to execute his program one instruction at a time. The format
isgoSlto(<Address>)
the
NEXT, ..,NEXT, EXEC, Exam. Memory or Register, EXEC, SINGLE INST, (it will
address where the program had been interrupted).
In case anew address is entered, the pressing of the next key displays the 1st byte of the instruc
tion stored at that location. Otherwise the pressing of the NEXd key executes the instruction at that
address.
In most of the cases a program does not run properly at irst trial. To detect errors the program
is executed one instruction at a time. The corrections aremade and the program is executed.
5.8.4 RELOCATE
Using this command the programmer can relocate a program written fora particular memory
locations to some other memory locations. The format is as follows:
SHIFT, REL (<LOLMT>)NEXT (<HILMT>) NEXT (<desired LOLMT>) EXECUTE, RESET.
Now the program has been shifted to the desired memory locations. During the relocation of a
program the jump and call addresses are also modified accordingly. This is for Vynitics' kit.
5.8.5 DELAY
A delay subroutine has been provided in the monitor. It is called by the address given by the
kit-manufacturer. To obtain the desired delay time the proper number is inserted in D-E register pair.
A
formula tocalculate delay time is given in the kit-manual. The programmer can write his own
delay subroutine. Such subroutines are given in Section 9.2.
5.9 SOFTWARE DEVELOPMENT
First of allthe problem is defined. It includes input-output specifications, processing require
ments, execution time, accuracy etc. An algorithm can be written tosolve the problem. An algorithm
isa precise statement of the procedure required for solving a problem. An algorithm can be written
in various forms. It may be expressed by means of flow charts, using English or any high-level lan
guage. The following are the stages for the development of software:
)) Problem definition
(ii) Program design
(iüi) Coding
(iv) Debugging
(v) Testing
(vi) Documentation
(vii) Maintenance
(vi) Extension and redesign
FUNDAMENTALS OF MICROPROCESSORS AND MICAOCOMPUTERS

5.22 charts program can be


detect writ en
prepared. Using tlow essential to
problem the flowchart is time, and hence itis errors
Having defined.a correctlyfirst removing errorssin the
easily. Most of the programs do not run
process
and
of finding steppingand break point program
is
and make corrections in the program.
The single techniques.
is made using of a program examines itssvalidity and it
called debugging Debugging of aprogram
made. Thetesting includes comments.,flow charts
Errors are detected and corrections are Documentation
performsitstask. and the sequence of steps.
ensures that the progtam correctlv the meaning of every step
etc Thev help programmerto
understand
experience programs need correctionsthe and updating,
conditions or field advantage of
Derending on the changingg programmer takes programs
This is called maintenance of the program. A for newtasks.
his programs
developedin the past. He redesigns and extendsare reliability, speed, hardware cost, Programming time
program
Ihe criteria for evaluation of a and extendibility. Agood program should utilise memory and
and cost, ease of use, error tolerance speed can do more work than that with lower speed. An
time efficiently. Aprogram with higher as possible to perform a certain
task. It will depend
interface should be simple and less costly as far also
method of attack of the problem. A program should be prepared in such a form that candata
On the be easy to understand. Strictly defined and
complex
te used by other programmers. It should make aprogram simple and
may lead to a difficult program. Good design and clear documentation input data. In case of errors in
it can be used by others. Aprogram should react if there are errors in operator.
inputs, shut down is not required. Some sort of indications are desired to alert the
5.10 DEBUGGING OF PROGRAMS
The word 'bug' means ablood-sucking insect infesting beds. But in computer's terminology it
means erro. To debug' means to eliminate errors. Usually, newly prepared programs contain errors.
They do not run correctly first time. A
new program has to be tested. To find errors and to remove
them from the program is called debugging of the program. There are the following two common
methods used for debugging of microprocessor programs :
() Single step control.
(in) Break-point technique.
5.10.1 Single-Step Control
The single-step control allows users to execute a program one step at a time. After executing one
instruction the user can examine thè contents of registers and memory to see whether the inter
mediate results are correct or not. This method is very slow. It is not
Furthermore, this method cannot find timing errors and errors in DMAsuitable for long programs.
or interrupt.
5.10.2 Break-point Technique
When a program is long and erTor is not in the beginning of the
program bysingle-step control becomes very difficult program, the checking of the
and time consuming. Furthermore, when a
program contains aloop, it is a difficult task to cross the loop by single-step
the break-point technique can be used. Abreak-point is a point in a program atcontrol. In such situations
be halted to examine the current contents of registers, memory and I/O ports. A which execution can
introduced the desired point in the program using software
at break-point can be
structions are software interrupts. Thius instruction. In Intel 8085, RST n in
nrogrammer can introduce a break-point atmethod any
is faster. The programs run at full
position of a program and the program speed. The
at full speed until the is
break-point is reached. The break-point is used to localize error orexecuted
through sections which contain no error. Then detailed to pass
mwhich contains errors. The debugging is dorne for the section of the
single-step control is used for such a section of the
program to
PROGRAMMING OF MICROPROCESsORS
5.23

find out which instruction contains error. Usually, a break-ppoint does not affect the timing of the
ongram, and hence it can be used to check input/output and interrupts. Most MDS and simulator
prgrams have tacilities to introduce
Asimple example ot break point break-points.
technique is given below. The program contains a loop. It is
very difficult task to crOss the loop by single step technique. Abreak point has been introduced after
h loop, which makes the testing of the
program very easy.
PROGRAM
Memory Machine Label Mnemonics Comments
Codes
Operands
Addrss
2400 06, FF MVI B, FF Get FF in register B.
2402 05 LOOP DCR B Decremernt register B.
2403 C2, 02, 24 JNZ LOOP Is conternt of B zero?
No, jump to LOOP.
2406 EF RST 5 Break point.
2407 3E, 02 MVI A, 02 Get 02 in A.
2409 32, 00, 25 STA 2500 H Store 02 in 2500 H
240C 76 HLT Stop.
At memory locations 2402-2405H there is aloop. Tocross the loop abreak point has been intro
duced at the memory location 2406 H. When the above program is executed 'E is not displayed by
the microprocessor kit; EC-85 is displayed (it is for Professional's kit). After this the key for "Single
Instruction" SI is pressed. Now the address next to the address of the instruction RST 5 i.e. 2407 H is
displayed. Nowonward the program can be tested in single step.
5.11 MODULAR PROGRAMMING
When programs become very long, they are divided into smaller programs or modules. These
smaller programs can be written, tested and debugged separately. This technique of programming
is known as modular programming.
The advantages of modular programming are :
1. It is easy to write, test and debug a module.
2. Generally the modules of common nature are prepared, which can be used at many places.
3. The programmer can divide tasks and use the previously written programs.
4. If a change is to be made, it is made in the particular module; the entire program is not
affected.

The disadvantages of modular programming are :


1. The combining of modules together is a difficult task.
2. It needs carefuldocumentation as it may affect the other parts of the program.
data from other
3. While testing modules it is found that the module under test may requireproblems special
modules or its results may be used by other modules. To solve such
programs called drivers are to be developed to produce the desired data for the testing of
modules. The development of drivers requires extra effort and time.
4. Modular programming requires extra time and memory.
Jins55900,ON95218218A
FF EXTR¢I VISITING YUR TaC.

5.24 NEAREST STORE


que The modular FUNDAMENTALS OF MICROPROCESSORS AND
can also be
functional
developed. They
pr
and ogrammi
lines used for ng
shorter
hence, they
was originally
programs
can
developed
written for
for MICROCOMPUTEDe
writing long programs but thiss
Longer
tasks. Theymodules
are very
do not useful. form
There
a microcomputers. Modules
is libraryot programs. Modules of : 20 to are
dividtechni-
ed
should be of become generalunnecessary
of wastage of time in 50 lines should
on
5.12 STRUCTURED PROGRAMMINGgeneral form. nature. The modules should preparing
be shorter
developed modules
be
for
commmon
logics.Structured
This programming is a
method
in can technique
also be used for adoptedtechnique
was to
to write write a program using
structural
level writing shorter very long programs exceeding specially1000defined program
below: complprogramming
of have programs for
1. A
exity. A
program cansingle-entry
be written and single-exit.microcomputers.
The
using only three typesstructures
lines. But this
The logic structures
of basic may be nested to any
used
one in thesequential structure. In this structures as described
2. A sequence in structure
which they are written. the
instructions
conditional structure.is Ifa certain condition is
otherwise theTheother program
or
programs are executed one by
PROGM2.
program flow chart given condition isexecuted.
that if A>Suppose there satisfied,
are two
a
particular program is executed;
is shown in
Fig. 5.6.
B,
execute programs
PROGM1; otherwise namely execute PROGM1
PROGM2. The
and

START

IS
NO
A>8

+ YES
PROGM1 START

PROGM 2
NO
A8

rEs
PROGM
ENO
STOP
Fig. 5.6. Program FlowChart for
Conditional Structure. Fig. 5.7 Program Flow
a A loop Chart for Loop
it structure. If a certain
does not go into the loop. For condition satisfied, the program
is
Structure.
nrooram PROGM. If this conditionexample, the given condition is that ifmoves in a loop,otherwise
is not satistied the A>B, execute the given
The program flow chart is shown in Fig. 5.7. computer will not execute the given program.

You might also like