Microprocessor Overview and Applications
Microprocessor Overview and Applications
MICROPROCESSOR
Microprocessor
It is a multipurpose, programmable, clock-driven, register-based electronic device that reads binary
instructions from memory, accepts binary data as input and processes data according to instructions
(program), and provides result as output.
It can also be defined as a programmable device that takes in numbers, performs on them arithmetic or
logical operations according to the program stored in memory and then produce other numbers as results.
Applications of Microprocessors
Instrumentation:
It is very useful in the field of instrumentation. Frequency counters, function generators, frequency
synthesizers, spectrum analyses and many other instruments are available, when microprocessors are used
as controller. It is also used in medical instrumentation.
Control
Microprocessor based controllers are available in home appliances, such as microwave oven, washing
machine etc., microprocessors are being used in controlling various parameters like speed, pressure,
temperature etc. These are used with the help of suitable transduction.
Communication
Microprocessors are being used in a wide range of communication equipments. In telephone industry, these
are used in digital telephone sets, telephone exchange and modem etc. The use of microprocessor in
television, satellite communication has made teleconferencing possible. Railway reservation and air
reservation system also uses this technology. LAN and WAN for communication of vertical information
through computer network.
Consumer
The use of microprocessor in toys, entertainment equipment and home applications is making them more
entertaining and full of features. The use of microprocessors is more widespread and popular. Now the
Microprocessors are used in:
1. Calculators
2. Accounting system
3. Games machine
4. Complex Industrial Controllers
5. Traffic light Control
6. Data acquisition systems
7. Multi user, multi-function environments
8. Military applications
1
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
Pag e |1
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
9. Radars
10. Washing machines
11. Satellites
12. Flights
Increase in application of microprocessors has been due to rapid advancement in electronics industry and
large scale integration of devices.
Microprocessor has a fixed set of instructions in binary pattern called machine language. These binary
instructions are given abbreviated names called mnemonics.
A program is a set of instructions written for a microprocessor to perform a task and a group of programs is
called software.
In embedded systems, the microprocessor is part of the final product and is not available for programming
to the end user. A copying machine is a typical example of embedded system.
Microprocessors used in such systems are generally categorized as:
1. Microcontroller
2. General purpose microprocessor
Microprocessor recognizes and processes a group of bits called word (the number of digits that can be
processed at a time). Microprocessor is classified according to their word length. For example a processor
with 8-bit word is called an 8-bit microprocessor and that with 32-bit word is called a 32-bit
microprocessor.
Since microprocessor is programmable, it can be instructed to perform a given task within its capacity.
2
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
Pag e |2
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Just as the transistor, the vacuum tube can switch electricity on or off, or amplify a current. So why was the
vacuum tube replaced by the transistor? There are several reasons. Vacuum tubes:
1. were bulky, hence less suitable for portable products.
2. had higher operating voltages generally required.
3. had high power consumption; needs heater supply that generates waste heat and yields lower
efficiency, notably for small-signal circuits.
4. Glass tubes are fragile, compared to metal transistors.
5. Sometimes more prone to microphonics (transmittance of mechanical vibrations through an
electrical component) than transistors, depending upon circuit and device.
6. Cathode electron-emitting materials were used up in operation.
7. had high-impedance devices that needed impedance matching transformer for low-impedance loads,
like speakers; however, the magnetic cushion provided by an output transformer prevents the output
tubes from blowing up.
8. Sometimes had higher cost than equivalently powered transistors.
The vacuum tube looks and behaves very much like a light bulb; it generates a lot of heat and has a
tendency to burn out. Also, compared to the transistor it is slow, big and bulky.
When engineers tried to build complex circuits using the vacuum tube, they quickly became aware of its
limitations. The first digital computer ENIAC, for example, was a huge monster that weighed over thirty
tons, and consumed 200 kilowatts of electrical power. It had around 18,000 vacuum tubes that constantly
burned out, making it very unreliable. They required warming up before they could operate.
An integrated circuit is a thin slice of silicon or sometimes another material that has been specially
processed so that a tiny electric circuit is etched on its surface. The circuit can have many millions of
microscopic individual elements, including transistors, resistors, capacitors, and conductors, all electrically
connected in a certain way to perform some useful function.
The first integrated circuits were based on the idea that the same process used to make clusters of
transistors on silicon wafers might be used to make a functional circuit, such as an amplifier circuit or a
computer logic circuit. Slices of the semiconductor materials silicon and germanium were already being
printed with patterns, the exposed surfaces etched with chemicals, and then the pattern removed, leaving
dozens of individual transistors, ready to be sliced up and packed individually. But wires, a few resistors
3
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
Pag e |3
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
and capacitors might later connect those same transistors to make a circuit. Why not doing the whole thing
at one time on that slice of silicon?
The idea occurred to a number of inventors at the same time, but the first to accomplish it were Jack
Kilby of Texas Instruments and Robert Noyce of Fairchild Semiconductor Incorporated. The idea caught
on like wildfire because the integrated circuit had many of the advantages that had made the transistor
attractive earlier. These advantages included small size, high reliability, low cost, and small power
consumption. However, these circuits were difficult to make because if one component of the chip was
faulty, the whole chip was ruined.
As engineers got better and better at squeezing more and more transistors and other components onto a
single chip, the problems of actually making these chips increased. When the transistors were shrunk down
to microscopic size, even the smallest bit of dust could ruin the chip. That's why today, chips are made in
special "clean rooms" where workers wear the "bunny suits" that we often see on TV.
Compared to the original integrated circuit, which was a simple device with just a few components, the
number of components on today's' integrated circuits is amazing. In the 1960s, an engineer named Gordon
Moore predicted that the number of elements on a chip would double every year (later revised to every two
years) into the foreseeable future. "Moore's Law" has held true so far. By the beginning of the twenty-first
century, the Intel Pentium chip had over 100 million transistors on it, with the total number of components
including resistors, capacitors, and conductors being even larger.
Microprocessor History
In the beginning, there was Intel. Intel was and is a Company in America engaged in designing and
manufacturing products such as microprocessors, chipset, computers, stand-alone system-on-chip among
others and technologies such as the cloud. Intel invented the microprocessors or perhaps more accurately,
they invented the term “microprocessor”. An early 8-bit chip, the four-phase system AL1, had been
invented by Lee Boysel in 1969 as part of a multi-chip CPU. But it wasn’t called a microprocessor until a
court case in the 1990’s when it was demonstrated that AL1 could function as the core of a computer.
For all practical purposes, however, the PC age began with Intel's first microprocessor, which by itself
contained as much processing power as the most powerful computer that existed in the world at the time:
the ENIAC, which filled an entire room. The world's first commercially-viable microprocessor was dubbed
the Intel 4004. It was quickly succeeded less than a year later by the 8008, which was twice as powerful.
In 1978, Intel released the 16-bit 8086 processor. The 8088, also a 16-bit chip, followed less than a year
later. The 8088 incorporated technologies designed to make it backward-compatible with the 8-bit chips
that were still in wide use at the time. IBM chose the 8088 chip to power their original Personal Computer.
And so it was that IBM, Intel, and a little startup company called Microsoft brought computing to the
masses.
In the early 1990's, Intel released the i386 processor. The 386 was the first commercially available 32-bit
microprocessor. For the first time, it made multitasking (running more than one program at a time) possible
on desktop computers. The i486 added an onboard math co-processor, improved data transfer, and an
onboard memory cache, all of which were stunning advances in technology in that era.
4
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
Pag e |4
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
The Intel Pentium processor, released in 1993, was the first commercially available microprocessor capable
of executing two instructions for every clock cycle. Later releases in the Pentium line revolutionized
everything from the way data is moved about on the chips, to the way that multimedia content is handled.
Those improvements have since been eclipsed, however, by Intel's line of multi-core, 64-bit processors,
such as the popular Core™ series, which boast capabilities that were unheard of only a few years ago.
Many other manufacturing companies have also come up with advanced microprocessors
Evolution of Microprocessor:
Microprocessors were categorized into five generations: first, second, third, fourth, and fifth generations.
Their characteristics are described below:
First-generation
The microprocessors that were introduced in 1971 to 1972 were referred to as the first generation systems.
First-generation microprocessors processed their instructions serially they fetched the instruction, decoded
it, then executed it. When an instruction was completed, the microprocessor updated the instruction pointer
and fetched the next instruction, performing this sequential drill for each instruction in turn.
Second generation
By the late 1970s, enough transistors were available on the IC to usher in the second generation of
microprocessor sophistication: 16-bit arithmetic and pipelined instruction processing.
Motorola’s MC68000 microprocessor, introduced in 1979, is an example. Another example is Intel’s 8080.
This generation is defined by overlapped fetch, decode, and execute steps (Computer 1996). As the first
instruction is processed in the execution unit, the second instruction is decoded and the third instruction is
fetched.
The distinction between the first and second generation devices was primarily the use of newer
semiconductor technology to fabricate the chips. This new technology resulted in a five-fold increase in
instruction, execution, speed, and higher chip densities.
Third generation
The third generation, introduced in 1978, was represented by Intel’s 8086 and the Zilog Z8000, which were
16-bit processors with minicomputer-like performance. The third generation came about as IC transistor
counts approached 250,000.
Motorola’s MC68020, for example, incorporated an on-chip cache for the first time and the depth of the
pipeline increased to five or more stages. This generation of microprocessors was different from the
previous ones in that all major workstation manufacturers began developing their own RISC-based
microprocessor architectures (Computer, 1996).
Fourth generation
As the workstation companies converted from commercial microprocessors to in-house designs,
microprocessors entered their fourth generation with designs surpassing a million transistors. Leading-edge
microprocessors such as Intel’s 80960CA and Motorola’s 88100 could issue and retire more than one
instruction per clock cycle.
5
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
Pag e |5
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Fifth generation
Microprocessors in their fifth generation, employed decoupled super scalar processing, and their design
soon surpassed 10 million transistors. In this generation, PCs are a low-margin, high-volume-business
dominated by a single microprocessor.
6
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
Pag e |6
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Classification of Microprocessor:
The microprocessor is identified with the word size of data. For E.g. The ALU can perform a 4- bit data
operation at a time these microprocessor is called as 4-bit microprocessor.
4-bit Microprocessors
The first microprocessor was introduced in 1971 by Intel Corp. It was named Intel 4004 as it was a 4 bit
processor. It was a processor on a single chip. It could perform simple arithmetic and logic operations such
as addition, subtraction, Boolean AND and Boolean OR. It had a control unit capable of performing control
functions like fetching an instruction from memory, decoding it, and generating control pulses to execute it.
It was able to operate on 4 bits of data at a time. This first microprocessor was quite a success in industry.
Soon other microprocessors were also introduced. Intel introduced the enhanced version of 4004, the 4040.
Some other 4 bit processors are International’s PPS4 and Thoshiba’s T3472.
8-bit Microprocessors
The first 8 bit microprocessor which could perform arithmetic and logic operations on 8 bit words was
introduced in 1973 again by Intel. This was Intel 8008 and was later followed by an improved version, Intel
8088. Some other 8 bit processors are Zilog-80 and Motorola M6800.
16-bit Microprocessors
The 8-bit processors were followed by 16 bit processors. They are Intel 8086 and 80286.
32-bit Microprocessors
The 32 bit microprocessors were introduced by several companies but the most popular one is Intel 80386.
Pentium Series
Instead of 80586, Intel came out with a new processor namely Pentium processor. Its performance is closer
to RISC performance. Pentium was followed by Pentium Pro CPU. Pentium Pro allows allow multiple
CPUs in a single system in order to achieve multiprocessing. The MMX extension was added to Pentium
Pro and the result was Pentium II. The low cost version of Pentium II is Celeron.
The Pentium III provided high performance floating point operations for certain types of computations by
using the SIMD extensions to the instruction set. These new instructions make the Pentium III faster than
high-end RISC CPUs.
Interestingly Pentium IV could not execute code faster than the Pentium III when running at the same clock
frequency. So Pentium IV had to speed up by executing at a much higher clock frequency.
7
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
Pag e |7
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
1. Microprocessor
i. Reads instructions from the memory.
ii. Communicates with all peripheral (memory and I/Os) using the system bus.
iii. Controls timing of information flow.
iv. Performs the computing task.
2. The Memory
i. Stores the binary information, called instruction and data.
ii. Provides instructions and data to the microprocessor on request.
iii. Stores the results and data for the microprocessor.
3. The Input device
i. Enters data and instructions under the control of a program.
4. The output device
i. Accepts data from the microprocessor as specified in a program.
5. The bus
i. Carries bits between the microprocessor and memory and I/Os.
Advantages
1. Computational/processing speed is high.
2. Intelligence has been brought to systems through microprocessors.
8
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
Pag e |8
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
A Computer System
A simple computer system comprises the basic components:
i. Process(Control Unit and the Arithmetic and Logic Unit)
ii. Main memory
iii. Input /Output unit
iv. Storage device
9
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
Pag e |9
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
2. Control Unit
- It is the device in charge of the operations of the computer and its peripheral
- The control unit provides the necessary timing and control signals to all the operations in the
microcomputer.
- It controls the flow of data between the microprocessor and memory and peripherals.
- It decodes (deciphers) decipher each instruction stored in it and then carries out the
instructions
- It also directs the movement of electronic signals between main memory and ALU.
- It also directs these electronic signals between the main memory and the input and output
devices.
For every instruction, the control unit carries out FOUR basic operations, known as the
machine cycle. In the machine cycle, the CPU:
i) Fetches an instruction
ii) Decodes the instruction
iii) Executes the instruction
iv) Stores the results
10
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 10
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
4. Register Array
- This is yet another important component of the CPU though not shown in the block diagram
above.
- It consists of various registers identified by letter such as B, C, D, E, H, L, etc. These
registers are used to store data and addresses temporarily during the execution of a program.
5. Input Unit
- The input section transfers data and instructions in binary from the outside world to the
microprocessor.
- It includes such devices as a keyboard, switches, a scanner, and an analog-to-digital
converter.
6. Output Unit
- The output section transfers data from the microprocessor to such output devices as LED,
CRT, printer, magnetic tape, or another computer.
11
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 11
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
- Word (or word length) is the number of bit the microprocessor recognizes and processes at a
time.
- Each machine has its own set of instructions based on the design of its CPU or its
microprocessor.
- To communicate with a computer, one must give instructions in binary language (machine
language). This is the natural dialect of a computer. It is machine oriented program i.e. the
language which machine can follow very easily.
- The program written in machine language is called Objet Program.
- In earlier computers all programs were written in machine language. The instructions were
written in binary (1’s and 0’s).
12
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 12
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Microcontroller Microprocessor
1. CPU on a single chip 1. CPU and several supporting chips
2. Consist memory I/O ports 2. Memory, I/O Port to be connected externally
OR OR
13
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 13
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Microprocessor Microcontroller
Data It has many instructions to move data It has one or two instructions to move data
memory between memory and CPU. between memory and CPU.
Cost Cost of the entire system increases. Cost of the entire system is low.
Bit
It has one or two bit handling instructions. It has many bit handling instructions.
instructions
Register It has less number of registers; hence the It has more number of registers; hence the
numbers operations are memory based. programs are easier to write.
Access time for memory and I/O devices Less access time for built-in memory and
Time
is more. I/O devices.
14
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 14
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
15
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 15
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
b) Register Unit
It contains various 8-bit or 16-bit registers. These registers are used primarily to store data
temporarily during the execution of a program. Some of the registers are accessible to the user
through instructions. It means there contents can be read and/or changed through instructions. Some
of the registers are not accessible to user but they are used by the processor for the execution of an
instruction.
8085A microprocessor contains 8-bit registers such as Accumulator (Reg. A), B, C, D, E, H, L etc
and16-bit registers such as Program Counter (PC), Stack Pointer (SP).
16
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 16
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
c) Control Unit
It provides necessary timing & control signals required for the operation of microcomputer. It
controls the flow of data between the microprocessor and peripherals (input, output & memory).
The control unit gets a clock signal which determines the speed of the microprocessor. In all, the
CPU has the following basic functions:
a) It fetches an instructions word stored in memory.
b) It decodes the instruction to determine what the instruction is telling it to do.
c) It executes the instruction.
Executing the instruction may include same of the following major tasks:
1. Transfer of data from one register to another register in the CPU itself.
2. Transfer of data between a CPU register & specified memory location or input/output
device.
3. Performing arithmetic and logical operations on data from a specific memory location or a
designated CPU register.
4. Directing the CPU to change the sequence of fetching instructions, if processing the data
created a specific condition.
5. Performing housekeeping function within the CPU itself in order to establish desired
condition at certain registers.
d. It looks for control signal such as interrupts and provides appropriate responses.
e. It provides status, control, and timing signals that the memory and input/output section can use.
Memory
- It stores both the instructions to be executed (i.e. program) and the data involved. It usually
contains ROM (Read Only Memory) and RWM (Read Write Memory).
- The ROM can only read and cannot be written into and is non volatile that is, it retains its
contents when the power is turned off. A ROM is typically used to store instructions and
data that do not change. For example, it stores the monitor program of a microcomputer.
- One can either read from or write into a RWM in memory read operation or memory write
operation respectively. The RWM is volatile, that is it does not retain its contents when the
power is turned off.
- It is used to store user programs and data which are temporary might change during the
course of executing a program.
- During a memory read operation, the content of the addressed location is not destroyed.
- During a write operation, the original content of the addressed location is destroyed.
17
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 17
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Memory sections often subdivided into units called pages. The entire memory section may involve
million of words, whereas a page contains between 256 & 4k warts. The computer may access a
memory location by first accessing a particular page and then accessing a location (or line number)
on that page.
The advantage of paging is that the computer can reach several locations on the same page with just
the address on the page. The process is like describing street address by first specifying a street and
then listing the house numbers. The control section transfers data to or from memory as follows:
1. The control section reads an address to the memory.
2. The control section sends a read and write signal to the memory to indicate, the direction
of the transform.
3. The control section waits until transfer has been completed. This delay precedes the ctual
data’s transfer in the input case and follows it in the output case.
Clock Generator:
Operations inside the microprocessor as well as in other parts of the microcomputer are usually
synchronous by nature. This is done so that events in different parts of the system can proceed in a
systematic fashion.
The clock needed to perform this synchronous operation is provided by the clock generator. The
clock generator generates the appropriate clock periods during which instruction executions are
carried out by the microprocessor.
Some of the microprocessors have an internal clock generator circuit to generate a clock signal.
These microprocessors require an external crystal or RC network to be connected at the appropriate
pins for deciding the operating frequency (e.g. 8085A). Some microprocessors require an external
clock generator (e.g. 8086). These microprocessors also provide an output clock signal which can
be used by other devices in the microcomputer system for their own timing and synchronizing.
18
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 18
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Address Bus
It is a group of conducting wires which carries address only. The address bus is unidirectional
because data flow in one direction, from microprocessor to memory or from microprocessor to
Input/output devices. We can find that how much memory location it can use the formula 2^ N.
where N is the number of bits used for address lines.
Length of Address Bus of Intel8085 microprocessor is 16 Bit (That is, Four Hexadecimal Digits),
ranging from 0000 H to FFFF H, (H denotes Hexadecimal). The Intel 8085 microprocessor can
transfer maximum 16 bit address which means it can address 65, 536 different memory location.
The Length of the address bus determines the amount of memory a system can address. Such as a
system with a 32-bit address bus can address 2^32 memory locations. If each memory location
holds one byte, the addressable memory space is 4 GB. However, the actual amount of memory that
can be accessed is usually much less than this theoretical limit due to chipset and motherboard
limitations.
Question:
If a processor has 4 GB memory then how many address lines are required to access this memory?
19
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 19
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Answer:
4GB= 4 * 1GB
4 = 22
1GB = 230
4GB = 22 * 230 = 232
So, 32 address lines are required to access the 4 GB memory.
Data Bus
It is a group of conducting wires which carries Data only. Data bus is bidirectional because data
flow in both directions, from microprocessor to memory or Input/output devices and from memory
or Input/output devices to microprocessor.
Length of Data Bus of 8085 microprocessor is 8 Bit (That is, two Hexadecimal Digits), ranging
from 00 H to FF H (00000000H to 11111111H). H denotes Hexadecimal.
When it is write operation, the processor will put the data (to be written) on the data bus, when it is
read operation, the memory controller will get the data from specific memory block and put it into
the data bus.
The data bus also connects the I/O ports and CPU. The largest number that can appear on the data
bus is 11111111.
It has 8 parallel lines of data bus. So it can access up to 2^8 = 256 data bus lines.
Control Bus
The control bus is used for sending control signals to the memory and I/O devices. The CPU sends
control signal on the control bus to enable the outputs of addressed memory devices or I/O port
devices.
Some of the control bus signals are as follows:
1. Memory read
2. Memory write
3. I/O read
4. I/O write
5. Opcode fetch
- The word (or word length) is defined as the number of bits the microprocessor recognizes and
processes at time.
- Each machine has its own set of instructions based on the design of its CPU or of its
microprocessor.
- To communicate with the computer, one must give instructions in binary language (machine
language). This is the natural dialect of a computer. It is machine oriented program ie the language
which the machine can follow very easily. The program written in machine language is also known
as object program.
20
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 20
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
- In earlier computers, all programs were in machine language. Such programs contained very
detailed instructions for each calculation and for the usual clerical chores accompanying each task.
The instructions were written in binary i.e. each instructions consisted a string of characters
containg a particular combination of 1’s and 0’s
Example
Add and store of 2-number as in the table below
Instruction Number Operation Code (Opcode) Memory address (Operand)
1 0110B 10001110B
2 0111B 10001111B
3 1000B 01110001B
Table 2.0 (a) Exhibits addition and storing of results of two numbers
- It requires code for addition process as well as for the data to be added. The code required for
performing any operation on computer is called opcode (Operation Code) and the data/address on
which operation is performed is called operand.
- Writing of program in binary form is very tedious and confusing as it would be composed long
strings of 1s and 0s. This problem is partially overcome by writing programs and data in octal and
hexadecimal form. Table 2.0 (b) below shows equivalent binary, octal and hexadecimal codes of
instructions and memory used in table 2.0 (a)
- It is evidence from table 2.0 (b) that the machine language programs can be written either in Binary
(represented by B) or in Octal (represented by O), or in Hexadecimal (represented by H) forms.
- Because it is difficult for most people to write programs in sets of 0s and 1s, computer
manufacturers have devised English-like words to represent the binary instructions of a machine.
Programmers can write programs, called assembly language programs, using these words.
- Each manufacturer of a microprocessor has devised a symbolic code for each instruction, called a
mnemonic.
- Mnemonic – a combination of letters to suggest the operation of an instruction
- Example of assembly language program is
Mnemonic Meaning
ADD addition
SUB subtraction
MOV movement
21
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 21
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
- It is much easier to remember ADD than 0111B that stands for additions. So, to help the
programmer, a number of mnemonics has been composed. The word mnemonics pronounce as
nemonik refers to an aid to remember. The programmer understands these mnemonics but not by
the computer (microprocessor). Therefore, the mnemonics must be translated into a form that the
microprocessor can understand.
- There are two methods of converting mnemonics in binary form that microprocessor can
understand. They are:
• Hand assembly
• Machine assembly
- Instruction is a binary pattern entered through an input device into memory to command the
microprocessor to perform specified function.
- Programs written in assembly language are specific to a given machine and therefore they are not
transferable from one machine to another.
- To circumvent this limitation, such general- purpose languages as BASIC, FORTRAN. PASCAL,
C, AND C++ have been devised; a program written in any of languages can be machine –
independent. These languages are called high-level languages.
- Machine language and assembly language are microprocessor specific and are both considered low-
level language.
Machine language is a computer programming language consisting of binary or hexadecimal
instructions which a computer can respond to directly. It is in binary, and the assembly language is
in English-like word; however, the microprocessor understands only the binary. These English-like
words are translated binary codes using a program called assembler.
- Assembler – is a computer program that translates an assembly language program from mnemonic
to the binary machine code of a computer.
- Interpreter – a program that translates the English-like statements of a high-level language into the
machine language of a computer. An interpreter translates one statement at a time from a source
code to an object code.
- Monitor program – a program that interprets the input from a keyboard and converts the input into
its binary equivalent.
- Compiler - a program that converts instructions into a machine-code or lower-level form so that
they can be read and executed by a computer. The compiler translates the whole program at a
go.
- Source code is a program written either in mnemonics or an assembly language or high-level
language (before it is assembled or compiled).
- The block diagram shows translation of High level Language Program to Machine Language
Compiler
Source Code or Object Code
22
Interpreter
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 22
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
ASCII Code
A computer is a binary machine. To communicate with computer in alphabetic letter in alphabet letters and
decimal numbers, translation codes are necessary.
The commonly used code is known as ASCII – American Standard Code for Information Interchange. It is
a 7-bit code with 128(27) combinations, and each combination from 00H to 7FH is assigned to a letter, a
decimal number, a symbol, or a machine command. For example 30H to 39H represent 0 – 9 decimal 30H
to 39H represent 0 to 9 decimal digits, 41H to 5AH represent capital letters A through Z, 20H to 2FH
represent various symbols, and initial codes 00H to 1FH represent such machine commands as carriage
return and line feed.
In microcomputer systems, keyboards (Called ASCII keyboards), video screens, and printers are typical
examples of devices that use ASCII codes. When “9” is pressed on an ASCII keyboard, the computer
receives 39H in binary, called an ASCII character, and the system program translate ASCII characters into
appropriate binary numbers.
However, recent computers use many more characters than the original 128 combinations; this is called
Extended ASCII. It is an 8-bit code that provides 256(28) combinations; the additional 128 combination are
assigned to various graphic characters.
Operating System
The interaction between the hardware and the software is managed by a set of programs called operating
system of a computer. It oversees all operations of the computer.
23
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 23
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Security − Prevents unauthorized access to programs and data by means of passwords and other
similar techniques.
Job Accounting − Keeps track of time and resources used by various jobs and/or users.
Control Over System Performance − Records delays between the request for a service and from
the system.
Interaction with the Operators − Interaction may take place via the console of the computer in
the form of instructions. The Operating System acknowledges the same, does the corresponding
action, and informs the operation by a display screen.
Error-detecting Aids − Production of dumps, traces, error messages, and other debugging and
error-detecting methods.
Coordination Between Other Software and Users − Coordination and assignment of compilers,
interpreters, assemblers, and other software to the various users of the computer systems.
24
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 24
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Utility programs
- Commonly referred to as just "utilities," are software programs that add functionality to your
computer or help your computer perform better. These include antivirus protection, backup, disk
repair, file management, memory management, password protection, and networking programs and
file compression. Utilities can also be applications such as screensavers, font and icon tools, and
desktop enhancements.
- Some utility programs help keep your computer free from unwanted software such as viruses or
spyware, while others add functionality that allows you to customize your desktop and user
interface.
- Utility is a program that performs a very specific task, usually related to managing system
resources. It is program that performs a specific task related to the management of computer
functions, resources, or files, as password protection, memory management, virus protection, and
file compression.
- In general, programs that help make your computer better are considered utilities.
- Operating systems contain a number of utilities for managing disk drives, printers, and
other devices.
Utilities differ from applications mostly in terms of size, complexity and function.
- Utilities are sometimes installed as memory-resident programs.
Application Programs
- This is a program is a comprehensive, self-contained program that performs a particular function
directly for the user. Among many others, application programs include:
Email
Web browsers
Games
Word processors
Enterprise software
Accounting software
Graphics software
Media players
Database management
- Because every program has a particular application for the end user, the term "application" is used.
For instance, a word processor can help the user create an article, whereas a game application can
be used for entertainment.
- An application program is also known as an application or application software.
Components of a computer
- The two major components of a computer can be summarized by the following illustration.
25
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 25
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
THE MICROPROCESSOR
- This is a multipurpose, programmable, clock driven, register based electronic device that reads
binary information from a storage device called memory, accepts binary data as input and processes
data according to those instruction and provides results as output.
- They operates at different speeds e.g. 166MHz, 233MHz, 450MHz, 733MHz, 850MHz, GHz, 2.4
GHz , 3GHz etc .
- The faster a CPU is, the faster it executes programs to accomplish tasks.
The Architecture
- The word "architecture" typically refers to building design and construction. In the computing
world, "architecture" also refers to design, but in this case describes the design of computer
systems.
26
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 26
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
- The internal logic design of the microprocessor called its "Architecture", determine how and what
various operations are performed by the microprocessor.
Since the Instruction Memory and the Data Memory are the same, the Processor or CPU cannot
access both Instructions and Data at the same time as they use a single bus.
27
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 27
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
The Von Neumann architecture developed for the ENIAC (Electronic Numerical Integrator And
Computer) uses the same memory and data paths for both program and data storage. ENIAC
was the world's first general-purpose computer. ENIAC was designed and built for the United
States Army to calculate artillery firing tables.
Both the concepts are similar except the way they access memories. The idea behind the Harvard
architecture is to split the memory into two parts – one for data and another for programs.
Real world computer designs are actually based on modified Harvard architecture and are
commonly used in microcontrollers and DSP (Digital Signal Processing).
Almost all Microcontrollers, including 8051 Microcontroller implement Harvard Architecture.
28
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 28
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Harvard architecture is more complicated but separate pipelines remove the bottleneck that Von
Neumann creates.
The Intel 8085 ("eighty-eighty-five") is an 8-bitmicroprocessor produced by Intel and introduced in 1976. It
is an 8-bit microprocessor with 16-bit address width capable of addressing 64kB of memory, with 40 pins
and formed with 6500 transistors. It requires a +5 volt power supply and operates with a 3 MHz frequency
It is an easy to use and still widely used system. It has simple architecture and have adequate instruction set
that enable students to learn necessary programming concept easily.
29
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 29
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
It is a software-binary compatible with the more-famous Intel 8080 with only two minor instructions added
to support its added interrupt and serial input/output features. However, it requires less support circuitry,
allowing simpler and less expensive microcomputer systems to be built. The Intel 8085 is a
conventional von Neumann design based on the Intel 8080.
30
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 30
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Processing Unit
The processing unit consists of:
i. Arithmetic and Logic Unit
ii. Accumulator
iii. Status Flags
iv. Temporary Register
31
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 31
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Instruction Unit
This unit consists of:
i. Instruction Register
ii. Instruction Decoder
iii. Timing and Control Unit
Processing Unit
The control unit (CU)
The control unit works by receiving input information that it converts into control signals. It directs the
operation of the processor.
It tells the computer’s memory, arithmetic/logic unit and input/output devices how to respond to program
instructions.
1. Fetching instructions one by one from primary memory and gather required data and operands to
perform those instructions.
2. Sending instructions to ALU to perform additions, multiplication etc.
32
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 32
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
However six steps could be involved in execution an instruction by CPU though not each of them are
required for any instructions
33
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 33
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
34
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 34
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Registers
- The CPU consists of a number of registers. These registers can be found in processing unit,
Instruction unit or storage and interface Unit.
- These are high speed storage locations that temporarily store data and instructions during
processing. They may store a program instruction while it is being decoded, store data while it is
being processed by the ALU, or store the results of a calculation.
- Register are used to quickly accept, store, and transfer data and instructions that are being used
immediately by the CPU, there are various types of Registers that are used for various purpose.
- These Registers are used for performing the various operations. While we are working on the
system, these Registers are used by the CPU for performing operations. When we gives some input
to the system then the input will be stored into the registers and the system will gives us the results
after processing , the result will also be from the registers.
35
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 35
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Registers Performance:-
i Fetching: The Fetch Operation is used for taking the instructions that are given by the user and
the Instructions that are stored into the Main Memory will be fetch using the registers.
ii Decoding: The Decode Operation is used for interpreting the Instructions meaning the
Instructions are decoded i.e the CPU will find out which Operation is to be performed on the
Instructions.
iii Executing: Execution operation is performed by the CPU and Results produced by the CPU are
then stored into the Memory and after that they are displayed on the user Screen.
Classification of Registers
There are eight addressable 8-bit registers in Intel 8085 microprocessor: A, B, C, D, E, H, L, F, and two 16-
bit registers PC and SP. These registers can be classified as:
1. General Purpose Registers
2. Temporary Registers : a) Temporary data register b) W and Z registers
3. Special Purpose Registers : a) Accumulator b) Flag registers c)
Instruction register
4. Sixteen bit Registers : a) Program Counter (PC) b) Stack Pointer (SP)
P a g e | 36
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
b. W and Z registers: W and Z registers are temporary registers. These registers are used to hold 8-bit
data during execution of some instructions. These registers are not available for programmer,
since 8085Microprocessor Architecture uses them internally.
Use of W and Z registers:
The CALL instruction is used to transfer program control to a subprogram or subroutine. This
instruction pushes the current PC contents onto the stack and loads the given address into the PC.
The given address is temporarily stored in the W and Z registers and placed on the bus for the fetch
cycle. Thus the program, control is transferred to the address given in the instruction. XCHG
instruction exchanges the contents of H with D and L with E, at the time of exchange W and Z
registers are used for temporary storage of data.
3. Special Purpose Registers:
i. Register A (Accumulator)
This Register is used for storing not only the results produced by the system but also contains one
of the operands during data processing.
When the CPU generates some results after the processing, all the results are stored into the A
register. In summary
- It is an 8-bitregister.
- It the main register of microprocessor.
- It is also called register ‘A’.
- It is used in the arithmetic and logic operations.
- It always contains one of the operands on which arithmetic/logic has to
be performed.
- After the arithmetic/logic operation, the contents of accumulator are replaced by the result.
ii. Flag Register
Flags are nothing but a group of individual Flip-flops. The flags will show either a logical (0 or 1)
(i.e.) a set or reset depending on the data conditions in accumulator or various other registers. It
alerts the processor that some event has taken place i.e they are used to check the status of
Accumulator after the operation is performed.
For example, if zero value is put into an arithmetic register (accumulator) as a result of an
arithmetic operation or a comparison, then the zero flag will be raised by the CPU. Thus, the
subsequent instruction can check this flag and when a zero flag is "ON" it can take an appropriate
route in the algorithm.
The figure below illustrates flag/status registers used by the Intel 8085 Microprocessor
37
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 37
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
38
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 38
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
In summery
P a g e | 39
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
4. Instruction Register
An instruction fetched from the memory is temporarily stored in instruction register (IR) prior to its
decoding.
In a typical processor operation, the processor first fetches the opcode of instruction from memory
(i.e. it places an address on the address bus and memory responds by placing the data stored at the
specified address on the data bus).
The CPU stores this opcode in the instruction register. This opcode is further sent to the instruction
decoder to select one of the 256 alternatives.
In a nutshell
It is used to hold the current instruction which the microprocessor is about to execute. That
is, it is used to store the opcode of the current instruction that is being fetched from the
memory before execution.
5. Sixteen Bit Registers
a. Program counters (PC)
- It is a 16 bit register used as memory pointer. It stores the memory address of the next
instruction to be executed. So we can say that this register is used to sequencing the
program. Generally the memory has 16 bit addresses so that it has 16 bit memory. The
program counter is set to 0000H.
- Program Counter acts as a pointer to the next instruction. How processor increments
program counter depends on the nature of the instruction; for one byte instruction it
increments program counter by one, for two byte instruction it increments program counter
by two and for three byte .instruction it increments program counter by three such that
program counter always points to the address of the next instruction.
- In case Of JUMP and CALL instructions, address followed by JUMP and CALL
instructions is placed in the program counter. The processor then fetches the next instruction
from the new address specified by JUMP or CALL instruction.
In a nutshell
40
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 40
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
- The program counter (PC), commonly called the instruction pointer (IP) in Intel x86
microprocessors, and sometimes called the instruction address register, or just part of the
instruction sequencer in some computers.
- It is a 16-bitregister.
- It is used to hold the address of next instruction to be executed.
- The microprocessor increments the value of Program Counter after the
execution of the current instruction, so that, it always points to the next
instruction.
41
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 41
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Stack example
Instruction Decoder
- As mentioned earlier, the processor first fetches the opcode of instruction from memory and
stores this opcode in the instruction register. It is then sent to the instruction decoder.
- Instruction decoder identifies the instructions. It takes the information from instruction
register and decodes the instruction to be performed. The instruction decoder decodes it and
accordingly gives the timing and control signals which control the register, the data buffers,
ALU and external peripheral signals depending on the nature of the instruction.
In a nutshell
- Instruction decoder decodes information present in the instruction register for further
processing.
- It generates various machine cycles depending upon the instruction.
- The machine cycles are then given to the Timing and Control Unit.
42
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 42
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Address Buffer
This is an 8-bit unidirectional buffer. It is used to drive external high order address bus (A15-A8). It is
also used to tri-state the high order address bus under certain conditions such as reset, hold, halt, and when
address lines are not in use.
Address/Data Buffer
- This is an 8-bit bi-directional buffer
- It is used to drive multiplexed address/data bus, i.e. low order addresses bus (A7-A0) and
data bus (D7-D0). It is also used to tri-state the multiplexed address/data bus under certain
conditions such as reset, hold, and halt and when the bus is not in use.
- The contents of the stack pointer and program counter are loaded into the address buffer
and address data buffer. The address and data buffers are used to drive external address and
data buses respectively. As the memory and I/O chips are connected to these buses, the
CPU can exchange desired data to the memory and I/O chips.
- The address-data buffer is not only connected to the external data bus but also to the internal
data bus which consists of 8-bits. The address data buffer can both send and receive data
from internal data bus.
Incrementer/DecrementerAddress Latch
- This is 16-bit register used to increment or decrement the content of the PC or SP as a part
of execution of instruction related to them.
- It is actually a function performed by the ALU. The Incrementer is used to increment the PC
value, after Intel8085 has fetched a byte of the instruction. This way, the PC will be pointing
to the next instruction by the time the current instruction is fully fetched.
- It is also used for the incrementing of the SP value after a byte is popped out of the stack
top.
- The decrementer is used for decrementing the SP value before a byte is pushed above the
stack top. It
Interrupt Control
- Interrupts are used to disrupt the normal sequence of main program execution to draw
CPU’s attention to an external event e.g. a request from an I/O device. When the CPU
receives an interrupt, it temporarily suspends the execution of the current program, attends
to the interrupting device or event, and then returns to continue with the main program
execution.
- The interrupt control block has five interrupt inputs RST 5.5, RST 6.5, RST 7.5, TRAP and
INTR and one acknowledge signal INTA.
Serial I/O Control
- There are two pins in this unit. This unit is used for serial data communication.
- In situations like, data transmission over long distance and communication with cassette
tapes or a CRT terminal, it is necessary to transmit data bit by bit to reduce the cost of
cabling.
43
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 43
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
In serial communication one bit is transferred at a time over a single line. The Intel 8085’s
-
serial I/O control provides two lines, SOD and SID for serial communication.
- The serial output data (SOD) line is used to send data serially and serial input data (SID)
line is used to receive data serially.
Timing and Control Circuitry
- It provides timing and control signal to the microprocessor to perform the various
operations. It has three control signals. It controls all external and internal circuits.
- It operates with reference to clock signal. It synchronizes all the data transfers.
The three control signal:
- There are three status signal used in microprocessor S0, S1 and IO/M. It changes its status
according the input provided to these pins.
- The control circuitry in the Intel 8085 Microprocessor Architecture is responsible for all the
operations. It includes an oscillator and a control-sequencer that produces the control
signals needed for internal and external control.
- The 8085 timing and control unit generates control signals that can be used to select
appropriate external devices and functions to perform READ and WRITE operations and
also to select memory or I/O port.
Index Register
- It is a register common in 8-bit processors but is not specifically incorporated in the Intel
8085 CPU
- It is also known as base register. The Index register is an internal register within the
microprocessor unit whose contents is modified (subtracted from or added to) during the
execution of an instruction to determine the memory location which will be accessed by the
CPU.
- The byte that is added to or subtracted from the Index register contents is called the
Displacement.
44
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 44
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
- Therefore there are TWO sources of address for the microprocessor address information, the
PC and the MAR.
- The PC is used for the opcode address while the MAR is used for data/operand address. A
multiplexer is used to switch to either the PC or the MAR onto the address bus, depending
on whether the CPU is in opcode fetch cycle or memory read/write cycle.
Index Register
This is a hardware element which holds a number that can be added to (or, in some cases, subtracted from)
the address portion of a computer instruction to form an effective address. It is also known as base
register. An index register in a computer's CPU is a processor register used for modifying operand
addresses during the run of a program.
The 8085 microprocessor is a clock-driven semiconductor device consisting of electronic logic circuits
manufactured by using either a large-scale integration (LSI) or very-large-scale integration (VLSI)
technique. It is capable of performing various computing functions and making decisions to change the
sequence of program execution. It has all the circuitry that makes up a CPU (hence it is a CPU on a single
chip). 8085 microprocessor is a 40 pin IC, DIP package.
45
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 45
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
46
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 46
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
47
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 47
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
48
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 48
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
49
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 49
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
50
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 50
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
51
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 51
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
52
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 52
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
53
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 53
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
54
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 54
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
1. Microprocessor-Initiated Operations
Generally, microprocessor performs primarily four operations.
a) Memory Read: Reads data from memory.
b) Memory Write: Writes data into memory.
c) I/O read: Accepts data from input devices.
d) I/O Write: Sends data to output devices.
All these operations are part of the communication process between the microprocessor and peripheral
devices (including memory).
To communicate with a peripheral (or a memory location), the microprocessor needs to perform the
following steps:
Step 1: Identify the peripheral or the memory location (with its address).
Step 2: Transfer data
Step 3: Provide timing or synchronization signals.
The 8085 performs these functions using three sets of communication lines called buses: The address bus,
the data bus, and the control bus.
To communication with a memory, for example to read instruction from memory location:-
1- Microprocessor places address on address bus.
2- The address on the bus is decoded.
3- The memory location is identified.
4- The microprocessor sends a pulse called memory read as control signal.
5- The pulse activates the memory chip.
6- The contents of the memory location are placed on the data bus as in the figure below.
55
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 55
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
56
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 56
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
A T-State is the time period of the one complete cycle of the internal clock signal of the processor.
The time taken to execute a machine cycle is expressed in terms of T-states. In Intel 8085, if the external
clock frequency applied through X1 & X2 pins are 6 MHz; then the internal clock frequency is 3 MHz
.Therefore, one T-State equals to T = 1/F = 1/3MHz = 0.333μs.
T-States
This is one clock period
Machine Cycle
Time required by the microprocessor to complete an operation of accessing memory or input/output
devices. Machine cycle is comprised of some member of T-states.
The five major types of machine cycles a microprocessor can undergo are will be handled later.
Instruction Cycle
This comprise of one or more number of machine cycles. That is the number of timing T-states needed
to fetch and execute an instruction is called Instruction cycle.
The instruction cycle can also be referred to as the fetching and execution of a single instruction. The three-
stage or four steps which the CPU carries each instruction i.e fetch, decode, execute, and store.
57
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 57
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
A machine cycle is a complete fetch-execute operation. Fetch cycle takes 4T-states and execution cycle
takes 3T-states.
Time Delay
The procedure used to design a specific delay is similar to that used to set up a counter. A register is loaded
with a number, depending on the time delay required, and then the register is decremented until it reaches
zero by setting up a loop with a conditional Jump instruction. The loop causes the delay, depending upon
the clock period of the system.
To calculate the time delay in a loop, we must account for the T-states required for each instruction and for
the number of times the instructions are executed in the loop. In above example, register C is loaded with
the count FFH (25510) by the instruction MVI, which is executed once and takes seven Tstates. The next
two instructions, DCR and JNZ, form a loop with a total of 14 (4+10) T-states.
58
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 58
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Note: The T-states for JNZ instruction are shown as 10/7. This is why the 8085 microprocessor requires
10 T-states to execute a conditional Jump instruction when it jumps or changes the sequence of the
program and 7 T-states when the program falls through the loop (goes to the instruction following the
JNZ). This difference can be accounted for the delay calculation by subtraction the execution time of three
states. Therefore, adjusted loop delay is:
Now the total delay must take into account the execution time of the instructions outside the loop. In the
above example, we have only one instruction (MVI C) outside the loop. Therefore, the total delay is:
Total Delay = Time to Execute Instructions Outside Loop + Time to Execute Loop Instructions
The following set of instructions uses a register pair to set up a time delay.
Delay Calculation:
59
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 59
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
The loop includes four instructions: DCX, MOV, ORA and JNZ and takes 24 clock periods for execution.
The loop is repeated 2384H times, which is converted to decimal as:
Delay Calculation:
Let’s further understand the process of delay calculation in 8085 using yet another example. We need to
calculate the exact duration in microseconds or milliseconds which would be provided by given delay
routine.
P a g e | 60
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
NOTE: Always remember to start from inner most loops and then move towards outer loop.
In this program, for sake of simplicity, I have also associated line numbers
Steps:
1. 1st innermost loop is at line no. 3 and 4. Now line 3 and 4 is going to get repeated for FFH or 256
times i.e. (10+4) T-states would be repeated for256 times. But since, in the last iteration, JNZ
condition fails and JZ instruction gets executed. JNZ instruction takes 10 T-states whereas JZ takes 7
T-states. So for 14 T-states are processed for 254 iterations, but in 255th iteration, it took only 11 T-
states, so while calculating:
(255 x 14) - 3 = 3567 T-states
2. Now, these 3567 T-states, along with (7+4+10) T-states are placed in another outer loop, which is
going to rotate for 10H times or 16 times. Don't forget to subtract 3 for the same reason mentioned in
point 1.
( (3567 + 7 + 4 + 10) x 16) - 3 = 57405 T-states
3. Now, combine this value to the T-state of 1st instruction of delay routine
(57405+7) = 57412 T-state
4. Since 1 clock duration = 1 T-state = 0.5usec, so
(57412 x 0.5usec) = 28.706 msec
This given routine is going to generate delay of 28.706 msec. This same process is applied to calculate the
execution time of any 8085 microprocessor program such that user can calculate how responsive system
might be, if the system is running using given program and said specification.
Determine the execution time or the following program segment using Intel 8085 microprocessor with a
system clock frequency of 3 MHZ
Instruction T-States
MVI A, 30H 7
MVI B, 20H 7
ADD B 4
STA 8054 13
HLT 4
Solution
Te = nTc
Where
Te = total execution time
Tc= the period time
n= total number of T-states for the program without loop
61
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 61
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
1
Tc =
f
But f = 3x106 Hz
Tc =1/3x106 Hz
= 0.33333µs
MVI A, 30H 7 X 0.33333µs = 2.333 x10-6
MVI B, 20H 7 X 0.33333µs = 2.333 x10-6
ADD B 4 X 0.33333µs = 1.33 x10-6
STA 8054 13 X 0.33333µs = 4.33 x10-6
HLT 4 X 0.33333µs = 1.33 x10-6
Total 11.65µs
The first machine instruction cycle is always an opcode fetch, and the 8-bit obtained during an opcode
fetch are always interpreted as the opcode of an instruction.
The number of machine cycles required to execute an instruction depends on that particular instruction.
Instruction Format
Each instruction has two parts: one is task to be performed, called the operation code (opcode), and the
second is the data to be operated on, called the operand.
An operand can be:
• A datum
• A register
• A memory location
P a g e | 62
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Instruction Set
This is a complete set of all the instructions in machine code that can be recognized and executed by a
Central Processing unit.
2. Arithmetic group: Instructions meant for arithmetic operations that add, subtract, increment or
decrement data in a register are put in this group.
Examples
ADD Add to Accumulator
ADI Add Immediate Data to Accumulator
ADC Add to Accumulator Using Carry Flag
ACI Add immediate data to Accumulator Using Carry
SUB Subtract from Accumulator
SUI Subtract Immediate Data from Accumulator
SBB Subtract from Accumulator Using Borrow (Carry) Flag
SBI Subtract Immediate from Accumulator Using Borrow (Carry)
Flag.
INR Increment Specified Byte by One
DCR Decrement Specified Byte by One
INX Increment Register Pair by One
DCX Decrement Register Pair by One
63
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 63
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
3. Logic group: This group performs logical (Boolean) operations on data in registers and memory and
on conditional flags. The logical AND, OR, and Exclusive OR instructions enables you to set
specific bits in the accumulator ON or OFF.
Examples
ANA Logical AND with Accumulator
ANI Logical AND with Accumulator Using Immediate Data
ORA Logical OR with Accumulator
OR Logical OR with Accumulator Using Immediate Data
XRA Exclusive Logical OR with Accumulator
XRI Exclusive OR Using Immediate Data
The Compare instructions compare the content of an 8-bit value with the contents of the
accumulator;
CMP Compare
CPI Compare Using Immediate Data
The rotate instructions shift the contents of the accumulator one bit position to the left or right:
RLC Rotate Accumulator Left
RRC Rotate Accumulator Right
RAL Rotate Left through Carry
RAR Rotate Right through Carry
4. Branch group: The branching instructions alter normal sequential program flow, either unconditionally
or conditionally. The unconditional branching instructions are as follows:
JMP Jump
CALL Call
RET Return
Conditional branching instructions examine the status of one of four condition flags to determine whether
the specified branch is to be executed. The conditions that may be specified are as follows:
NZ Not Zero (Z = 0)
Z Zero (Z = 1)
NC No Carry (C = 0)
C Carry (C = 1)
PO Parity Odd (P = 0)
PE Parity Even (P = 1)
P Plus (S = 0)
64
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 64
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
M Minus (S = 1)
Thus, the conditional branching instructions are specified as follows:
I/0 instructions
IN Initiate Input Operation
OUT Initiate Output Operation
The operand (or data) can be specified in various ways. It may include 8-bit (or 16-bit) data, an internal
register, a memory location, or 8-bit (or 16-bit) address.
65
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 65
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
In the Intel 8085, "byte" and "word" are synonymous because it is an 8-bit microprocessor. This is not
always true with other microprocessors.
However, instructions are commonly referred to in terms of bytes rather than words.
66
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 66
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
One-Byte Instructions
A 1-byte instruction includes the opcode and operand in the same byte. Operand(s) are internal registers
and are coded into the instruction. For example:
Mnemonic- MOV B, A
Opcode- MOV
Operand- B, A
Mnemonic- ADD B
Opcode- ADD
Operand- B
Mnemonic- CMA
Opcode- CMA
Operand- NA
P a g e | 67
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Similarly, in the third instruction, the accumulator is assumed to be the implicit operand. These instructions
are stored in 8-bit binary format in memory; each requires one memory location.
The length of these instructions is 8-bit; each requires one memory location. The mnemonic is always
followed by a letter (or two letters) representing the registers (such as A, B, C, D, E, H, L and SP).
Two-Byte Instructions
In a two-byte instruction, the first byte specifies the operation code and the second byte specifies the
operand. Source operand is a data byte immediately following the opcode. For example:
Instructions require two memory locations to store in the memory.
Assume that the data byte is 32H. The assembly language instruction is written as
Note – This type of instructions needs two bytes to store the binary codes. The mnemonic is always
followed by 8-bit (byte)
Three-Byte Instructions
68
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 68
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
The1st byte specifies opcode and 2nd & 3rd bytes specifies 16-bit address
2nd byte holds the low order address.
3rd byte holds the high order address.
Instructions require three memory locations to store single byte in the memory.
Note that the second byte is the low-order address and the third byte is the high-order address.
Opcode + data byte + data byte
Note – These instructions would require three memory locations to store the binary codes. The mnemonic
is always followed by 16-bit (or adr).
Control Instructions
69
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 69
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
HLT none Halt and enter The CPU finishes executing the current instruction and halts any
wait state further execution. An interrupt or reset is necessary to exit from
the halt state.
Example: HLT
DI none Disable The interrupt enable flip-flop is reset and all the interrupts
interrupts except the TRAP are disabled. No flags are affected.
Example: DI
EI none Enable The interrupt enable flip-flop is set and all interrupts are
interrupts enabled. No flags are affected. After a system reset or the
acknowledgement of an interrupt, the interrupt enable flip-flop
is reset, thus disabling the interrupts. This instruction is
necessary to re-enable the interrupts (except TRAP).
Example: EI
RIM none Read interrupt This is a multipurpose instruction used to read the status of
mask interrupts 7.5, 6.5, 5.5 and read serial data input bit. The
instruction loads eight bits in the accumulator with the
following interpretations.
Example: RIM
SIM none Set interrupt This is a multipurpose instruction and used to implement the
mask 8085 interrupts 7.5, 6.5, 5.5, and serial data output. The
instruction interprets the accumulator contents as follows.
Example: SIM
70
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 70
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Logical Instructions
Opcode Operand Explanation of Description
Instruction
CMP R Compare register The contents of the operand (register or memory) are M
M or memory with compared with the contents of the accumulator. Both
accumulator contents are preserved. The result of the comparison is shown
by setting the flags of the PSW as follows:
if (A) < (reg/mem): carry flag is set
if (A) = (reg/mem): zero flag is set
if (A) > (reg/mem): carry and zero flags are reset
Example: CMP B or CMP M
CPI 8-bit Compare The second byte (8-bit data) is compared with the contents of
data immediate with the accumulator. The values being compared remain
accumulator unchanged. The result of the comparison is shown by setting
the flags of the PSW as follows:
if (A) < data: carry flag is set
if (A) = data: zero flag is set
if (A) > data: carry and zero flags are reset
Example: CPI 89H
ANA R Logical AND The contents of the accumulator are logically ANDed with M
M register or the contents of the operand (register or memory), and the
memory with result is placed in the accumulator. If the operand is a
accumulator memory location, its address is specified by the contents of
HL registers. S, Z, P are modified to reflect the result of the
operation. CY is reset. AC is set.
Example: ANA B or ANA M
ANI 8-bit Logical AND The contents of the accumulator are logically ANDed with
data immediate with the
accumulator 8-bit data (operand) and the result is placed in the
accumulator. S, Z, P are modified to reflect the result of the
operation. CY is reset. AC is set.
Example: ANI 86H
XRA R Exclusive OR The contents of the accumulator are Exclusive ORed with M
M register or the contents of the operand (register or memory), and the
memory with result is placed in the accumulator. If the operand is a
accumulator memory location, its address is specified by the contents of
HL registers. S, Z, P are modified to reflect the result of the
operation. CY and AC are reset.
Example: XRA B or XRA M
71
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 71
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
XRI 8-bit Exclusive OR The contents of the accumulator are Exclusive ORed with the
data immediate with 8-bit data (operand) and the result is placed in the
accumulator accumulator. S, Z, P are modified to reflect the result of the
operation. CY and AC are reset.
Example: XRI 86H
ORA R Logical OR The contents of the accumulator are logically ORed with M
M register or the contents of the operand (register or memory), and the
memory with result is placed in the accumulator. If the operand is a
accumulator memory location, its address is specified by the contents of
HL registers. S, Z, P are modified to reflect the result of the
operation. CY and AC are reset.
Example: ORA B or ORA M
ORI 8-bit Logical OR The contents of the accumulator are logically ORed with the
data immediate with 8-bit data (operand) and the result is placed in the
accumulator accumulator. S, Z, P are modified to reflect the result of the
operation. CY and AC are reset.
Example: ORI 86H
RLC none Rotate Each binary bit of the accumulator is rotated left by one
accumulator left position. Bit D7 is placed in the position of D0 as well as in
the Carry flag. CY is modified according to bit D7. S, Z, P,
AC are not affected.
Example: RLC
RRC none Rotate Each binary bit of the accumulator is rotated right by one
accumulator right position. Bit D0 is placed in the position of D7 as well as in
the Carry flag. CY is modified according to bit D0. S, Z, P,
AC are not affected.
Example: RRC
RAL none Rotate Each binary bit of the accumulator is rotated left by one
accumulator left position through the Carry flag. Bit D7 is placed in the Carry
through carry flag, and the Carry flag is placed in the least significant
position D0. CY is modified according to bit D7. S, Z, P, AC
are not affected.
Example: RAL
RAR none Rotate Each binary bit of the accumulator is rotated right by one
accumulator right position through the Carry flag. Bit D0 is placed in the Carry
through carry flag, and the Carry flag is placed in the most significant
position D7. CY is modified according to bit D0. S, Z, P, AC
are not affected.
72
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 72
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Example: RAR
CMA none Complement The contents of the accumulator are complemented. No flags
accumulator are affected.
Example: CMA
CMC none Complement carry The Carry flag is complemented. No other flags are affected.
Example: CMC
Branching Instructions
Opcode Operand Explanation of Description
Instruction
P a g e | 73
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
74
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 74
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
75
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 75
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
TRAP 0024H
RST 5.5 002CH
RST 6.5 0034H
RST 7.5 003CH
Arithmetic Instructions
Opcode Operand Explanation of Description
Instruction
ADD R Add register or The contents of the operand (register or memory) are added
M memory, to to the contents of the accumulator and the result is stored in
accumulator the accumulator. If the operand is a memory location, its
location is specified by the contents of the HL registers. All
flags are modified to reflect the result of the addition.
Example: ADD B or ADD M
ADC R Add register to The contents of the operand (register or memory) and M the
M accumulator with Carry flag are added to the contents of the accumulator and
carry the result is stored in the accumulator. If the operand is a
memory location, its location is specified by the contents of
the HL registers. All flags are modified to reflect the result
of the addition.
Example: ADC B or ADC M
ADI 8-bit data Add immediate to The 8-bit data (operand) is added to the contents of the
accumulator accumulator and the result is stored in the accumulator. All
flags are modified to reflect the result of the addition.
Example: ADI 45H
ACI 8-bit data Add immediate to The 8-bit data (operand) and the Carry flag are added to the
accumulator with contents of the accumulator and the result is stored in the
carry accumulator. All flags are modified to reflect the result of
the addition.
Example: ACI 45H
LXI Reg. pair, Load register pair The instruction loads 16-bit data in the register pair
16-bit data immediate designated in the operand.
Example: LXI H, 2034H or LXI H, XYZ
DAD Reg. pair Add register pair The 16-bit contents of the specified register pair are added
to H and L to the contents of the HL register and the sum is stored in
76
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 76
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
registers the HL register. The contents of the source register pair are
not altered. If the result is larger than 16 bits, the CY flag is
set. No other flags are affected.
Example: DAD H
SUB R Subtract register The contents of the operand (register or memory ) are
M or memory from subtracted from the contents of the accumulator, and the
accumulator result is stored in the accumulator. If the operand is a
memory location, its location is specified by the contents of
the HL registers. All flags are modified to reflect the result
of the subtraction.
Example: SUB B or SUB M
SBB R Subtract source The contents of the operand (register or memory ) and M
M and borrow from the Borrow flag are subtracted from the contents of the
accumulator accumulator and the result is placed in the accumulator. If
the operand is a memory location, its location is specified
by the contents of the HL registers. All flags are modified
to reflect the result of the subtraction.
Example: SBB B or SBB M
SUI 8-bit data Subtract The 8-bit data (operand) is subtracted from the contents of
immediate from the accumulator and the result is stored in the accumulator.
accumulator All flags are modified to reflect the result of the subtraction.
Example: SUI 45H
SBI 8-bit data Subtract The contents of register H are exchanged with the contents
immediate from of register D, and the contents of register L are exchanged
accumulator with with the contents of register E.
borrow Example: XCHG
INR R Increment register The contents of the designated register or memory) are
M or memory by 1 incremented by 1 and the result is stored in the same place.
If the operand is a memory location, its location is specified
by the contents of the HL registers.
Example: INR B or INR M
INX R Increment register The contents of the designated register pair are incremented
pair by 1 by 1 and the result is stored in the same place.
Example: INX H
77
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 77
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
DCX R Decrement The contents of the designated register pair are decremented
register pair by 1 by 1 and the result is stored in the same place.
Example: DCX H
DAA none Decimal adjust The contents of the accumulator are changed from a binary
accumulator value to two 4-bit binary coded decimal (BCD) digits. This
is the only instruction that uses the auxiliary flag to perform
the binary to BCD conversion, and the conversion
procedure is described below. S, Z, AC, P, CY flags are
altered to reflect the results of the operation.
If the value of the low-order 4-bits in the accumulator is
greater than 9 or if AC flag is set, the instruction adds 6 to
the low-order four bits.
If the value of the high-order 4-bits in the accumulator is
greater than 9 or if the Carry flag is set, the instruction adds
6 to the high-order four bits.
Example: DAA
MOV Rd, Rs Copy from This instruction copies the contents of the source register
M, Rs source(Rs) to into the destination register; the contents of the source
Rd, M destination(Rd) register are not altered. If one of the operands is a
memory location, its location is specified by the contents
of the HL registers.
Example: MOV B, C or MOV B, M
MVI Rd, data Move immediate 8- The 8-bit data is stored in the destination register or
M, data bit memory. If the operand is a memory location, its location
is specified by the contents of the HL registers.
Example: MVI B, 57H or MVI M, 57H
LDA 16-bit Load accumulator The contents of a memory location, specified by a 16-bit
address address in the operand, are copied to the accumulator.
The contents of the source are not altered.
Example: LDA 2034H
LDAX B/D Reg. Load accumulator The contents of the designated register pair point to a
78
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 78
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
LXI Reg. pair, Load register pair The instruction loads 16-bit data in the register pair
16-bit data immediate designated in the operand.
Example: LXI H, 2034H or LXI H, XYZ
LHLD 16-bit Load H and L The instruction copies the contents of the memory
address registers direct location pointed out by the 16-bit address into register
L and copies the contents of the next memory location
into register H. The contents of source memory
locations are not altered.
Example: LHLD 2040H
STA 16-bit 16-bit address The contents of the accumulator are copied into the
address memory location specified by the operand. This is a 3-
byte instruction, the second byte specifies the low-order
address and the third byte specifies the high-order
address.
Example: STA 4350H
STAX Reg. pair Store accumulator The contents of the accumulator are copied into the
indirect memory location specified by the contents of the operand
(register pair). The contents of the accumulator are not
altered.
Example: STAX B
SHLD 16-bit Store H and L The contents of register L are stored into the memory
address registers direct location specified by the 16-bit address in the operand
and the contents of H register are stored into the next
memory location by incrementing the operand. The
contents of registers HL are not altered. This is a 3-byte
instruction, the second byte specifies the low-order
address and the third byte specifies the high-order
address.
Example: SHLD 2470H
XCHG none Exchange H and L The contents of register H are exchanged with the
with D and E contents of register D, and the contents of register L are
exchanged with the contents of register E.
Example: XCHG
79
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 79
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
SPHL none Copy H and L The instruction loads the contents of the H and L
registers to the stack registers into
pointer the stack pointer register, the contents of the H register
provide the high-order address and the contents of the L
register provide the low-order address. The contents of
the H
and L registers are not altered.
Example: SPHL
XTHL none Exchange H and L The contents of the L register are exchanged with the
with top of stack stack location pointed out by the contents of the stack
pointer register. The contents of the H register are
exchanged with the next stack location (SP+1); however,
the contents of the stack pointer register are not altered.
Example: XTHL
PUSH Reg. pair Push register pair The contents of the register pair designated in the
onto stack operand are copied onto the stack in the following
sequence. The stack pointer register is decremented and
the contents of the high order register (B, D, H, A) are
copied into that location. The stack pointer register is
decremented again and the contents of the low-order
register (C, E, L, flags) are copied to that location.
Example: PUSH B or PUSH A
POP Reg. pair Pop off stack to The contents of the memory location pointed out by the
register pair stack pointer register are copied to the low-order register
(C, E, L, status flags) of the operand. The stack pointer is
incremented by 1 and the contents of that memory
location are copied to the high-order register (B, D, H, A)
of the operand. The stack pointer register is again
incremented by 1.
Example: POP H or POP A
OUT 8-bit port Output data from The contents of the accumulator are copied into the I/O
address accumulator to a port port specified by the operand.
with 8-bit address Example: OUT F8H
IN 8-bit port Input data to The contents of the input port designated in the operand
address accumulator from a are read and loaded into the accumulator.
port with 8-bit Example: IN 8CH
address
80
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 80
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
It is define as the way in which data is addressed in the operand part of the instruction. It
indicates to the CPU from where to finds or get data and where to store results
When a CPU executes an instruction, it needs to know where to get data and where to store results.
Such information is specified in the operand fields of the instruction.
To perform any operation, we have to give the corresponding instructions to the microprocessor. In each
instruction, programmer has to specify three things:
1. Operation to be performed.
2. Address of source of data.
3. Address of destination of result.
The term addressing mode refers to the way in which the operand of the instruction is specified.
The Intel 8085 has the following 5 different types of addressing.
1. Immediate Addressing
2. Direct Addressing
3. Register Addressing
4. Register Indirect Addressing
5. Implied Addressing
1. Immediate Addressing
In immediate addressing mode the:
- Data is specified in the operand part of instruction immediately.
- Data is stored along with the instruction and it is directly transferred to the register.
Example
MVI B, 3EH - Move the data 3EH given in the instruction to B register
MVI is the operation (task)
B is the destination
3EH is the immediate data (source)
Mores examples:
MVI B, 45H (move the data 45H immediately to register B)
LXI H 3050H (load the register H-L pair with the operand 3050H immediately)
JMP address (jump to the operand address immediately)
ADI DATA ; Add immediate the data to the contents of the accumulator.
MVI 08H ; Move the data 08 H immediately to the accumulator
SUI 05H ; Subtract immediately the data 05H from the accumulator
MVI A 0FH; Load OFH to register Accumulator
81
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 81
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
2. Direct Addressing
In direct addressing mode:
- The data to be operated on is available inside a memory location and that memory
location is directly specified as an operand. The operand is directly available in the
instruction itself.
- That is, the data is stored in the memory and the exact memory location is specified in the
instruction. The memory address is specified as the lower order in byte3, and the higher
order in byte 2 of the address.
- In this addressing mode, the program instructions and data can be stored in different
memory.
Example
LDA 1050H - Load the data available in memory location 1050H in to accumulator; SHLD 3000H 19
LD is the operation (Task)
A is the destination
1050H is the address of source (i.e. memory address where the data is located)
LDA 2500 H Load the contents of memory location 2500 H into accumulator.
LD is the operation (Task)
A is the destination
2500 H is the address of source (i.e. memory address where the data is located)
82
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 82
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Other examples
3. Register Addressing
In register addressing mode:
- The instruction specifies the name of the register in which the data is available. That is,
in this addressing mode data is specified through register in operand part of instruction.
- The data to be operated is available inside the register(s) and register(s) is(are) operands.
Therefore the operation is performed within various registers of the microprocessor.
- Operands are the names of internal register. The processor gets data from the register
specified by instruction.
Example
MOV A, B - Move the content of B register to A register; SPHL; ADD C.
MOV is the operation
B is the source
A is the destination
Other examples
MOV A, B (move the contents of register B to register A)
ADD B (add contents of registers A and B and store the result in register A)
INR A (increment the contents of register A by one)
SUB D; subtract the contents of D register from Accumulator.
ADD B, C; Add the contents of C register to the contents of B register.
Originally,
(B) = 0FH and (D) = 1FH
and (H) = 0FH and (L) = 1AH
83
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 83
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Other examples
5. Implied Addressing
84
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 84
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Other examples
85
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 85
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
86
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 86
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
High-Level Languages
The solution to many of the difficulties associated with assembly language programs is to use, instead,
"high-level" or procedure-oriented" languages. Such languages allow you to describe tasks in forms that
are problem oriented rather than computer oriented. Each statement in a high-level language performs a
recognizable function; it will generally correspond to many assembly language instructions. A program
called a compiler translates the high-level language source program into object or machine language
instructions.
87
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 87
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Many different high-level languages exist for different types of tasks. If, for example, you can express what
you want the computer to do in algebraic notation, you can write your program in FORTRAN (Formula
Translation Language), the oldest and most widely used of the high-level languages. Now, if you want to
add two numbers, you just tell the computer:
SUM = NUMB1+NUMB2
That is a lot simpler (and a lot shorter) than either the equivalent machine language program or the
equivalent assembly language program. Other high-level languages include COBOL (for business
applications).ALGOL (another algebraic language), PL/I (a combination of FORTRAN, ALGOL, and
COBOL), and APL and BASIC (languages that are popular for time-sharing systems).
In a nutshell
Instruction consists of a mnemonic and one or two operands (data).
Machine Language: Consist of 0s and1s.
Assembly Languages: Uses short form notations, called, mnemonics, to write a program .The Mnemonics
are like MOV , ADD , SUB, etc.
High level languages: It uses English like sentences with proper syntax to write a program.
Assembler translates Assembly language program into machine code.
Compilers like Pascal, Basic, C etc translate the HLL program into machine code. The programmer does
not have to be concerned with internal details of the CPU.
88
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 88
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
P a g e | 89
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Flowcharts
What is a Flowchart?
Flowchart is a graphical representation of an algorithm. Programmers often use it as a program-planning
tool to solve a problem. It makes use of symbols which are connected among them to indicate the flow of
information and processing.
The process of drawing a flowchart for an algorithm is known as “flowcharting”.
2. Input/output: This is depicted by parallelogram, denoting any function of input/output type. Program
instructions that take input from input devices and display output on output devices are indicated with
parallelogram in a flowchart.
3. Processing: This is represented by box, depicting arithmetic instructions. All arithmetic processes
such as adding, subtracting, multiplication and division are indicated by action or process symbol.
4. Decision This is represented by a diamond symbol depicting, a decision point. Decision based
operations such as yes/no question or true/false are indicated by diamond in a flowchart.
90
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 90
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
5. Connectors: Whenever flowchart becomes complex or it spreads over more than one page, it is useful
to use connectors to avoid any confusions. It is represented by a circle.
6. Flow lines: Flow lines indicate the exact sequence in which instructions are executed. Arrows
represent the direction of flow of control and relationship among different symbols of flowchart.
Example of a flow chart
91
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 91
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
92
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 92
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
93
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 93
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
94
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 94
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Assembler instructions
The assembly text is usually divided into fields, separated by spaces and tabs. A format for a typical line
from assembly language program can be given as
Label : Mnemonic Operand1, Operand2 ; Comment. The fields, as shown in Table 2-1.
95
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 95
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
The operation code field is the only field which can never be empty; it always contains either an instruction
mnemonic or directive to the assembler, called a pseudo-instruction, pseudo-operation, or pseudo-op.
The comment and label fields are optional. A programmer will assign a label to a statement or add a
comment as a personal convenience, e.g., to make the program easier to read.
LABELS
The label field is the first field in an assembly language instruction; it may be blank. If a label is present,
the assembler assigns to the label the value of the address for the memory location into which the first
object program byte for that instruction is loaded. You may subsequently use the label as an address or as
data in another instruction's operand field. The assembler will replace the label with the assigned value
when creating an object program.
Labels are most frequently used in Jump, Call or Branch instructions. These instructions place a new value
in the Program Counter and so alter the normal sequential execution of instructions. JUMP 15016 means
"place the value 15016 in the Program Counter". The next instruction to be executed will be the one in
memory location 15016- The instruction JUMP START means "place the value assigned to the label
START in the Program Counter". The next instruction to be executed will be the one in the memory
location to which the label START has been assigned. Table 2-3 contains an example.
96
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 96
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
When the machine language version of this program is executed, the instruction JUMP START causes the
address of the instruction labeled START to be placed in the Program Counter. The instruction with the
label START will be executed next.
Why use a label?
Here are some reasons:
1) A label makes a program location easier to find and remember.
2) The label can be moved to correct a program. You do not have to change any subsequent label
references; the assembler will make all the necessary changes.
3) The assembler or loader can relocate the whole program by adding a constant (are location
constant) to each address in which a label was used. Thus we can move the program to allow for the
insertion of other programs or simply to rearrange memory.
4) The program is easier to use as a library program, i.e., it is easier for someone else to take your
program and add it to some totally different program.
5) You co not have to figure out memory addresses. Figuring out memory addresses is particularly
difficult with microprocessors which have instructions that vary in length. It makes sense to assign
a label to any instruction which you might want to use as destination or otherwise identify.
The assembler must, however, do more than just translate the operation codes. It must also somehow
determine how many operands the instruction requires and what type they are. This may be rather complex
—some instructions (like a Halt) have no operands, others (like an Addition or a Jump instruction) have
one, while still others (like a transfer between registers or a multiple-bit shift) require two. Some
instructions
may even allow alternatives, e.g., some computers have instructions (like Shift or Clear) which can either
apply to the Accumulator or to a memory location. We will not discuss how the assembler makes these
distinctions; we will just note that it must do so.
97
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 97
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
98
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 98
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
PSEUDO-OPERATIONS
Some assembly language instructions are not directly translated into machine language instructions.
These instructions are directives to the assembler; they assign the program to certain areas in memory,
define symbols, designate areas of RAM for temporary data storage, place tables or other fixed data in
memory, and perform other housekeeping functions.
To use these directives or pseudo-operations a programmer places the pseudo-operation's mnemonic in the
operation code field, and an address or data in the address field, if the specified pseudo-operation requires
it.
The most common pseudo-operations are:
DATA
EQUATE or DEFINE
ORIGIN
RESERVE
Different assemblers use different names for these operations but the purposes are the same. Housekeeping
pseudo-operations include:
END
LIST
NAME
PAGE
SPACE
TITLE
P a g e | 99
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
The DATA pseudo-operation treats the data as a permanent part of the program. The format of a DATA
pseudo-operation is usually quite simple. An instruction like:
DZCON DATA 12
will place the number 1 2 in the next available memory location and assign that location the name DZCON.
Usually every DATA pseudo-operation has a label, unless it is one of a series of DATA pseudo-operations.
The data and label may take any form that the assembler permits.
Most assemblers allow more elaborate DATA instructions which handle a large amount of data at one time,
e.g.,
EMESS DATA 'ERROR'
SQRS DATA 1,4.9.16,25
A single instruction may fill many words of program memory, limited only by the length of a line. Note
that if you cannot get all the data on one line, you can always follow one
DATA instruction with another, e.g.
MESSG DATA 'NOW IS THE'
DATA TIME FOR ALL'
DATA 'GOOD MEN'
DATA TO COME TO THE'
DATA 'AID OF THEIR'
DATA 'COUNTRY'
Microprocessor assemblers typically have some variations of standard DATA pseudo-operations. DEFINE
BYTE OR FORM CONSTANT BYTE handles 8-bit numbers; DEFINE WORD OR FORM CONSTANT
WORD handles 16-bit numbers or addresses. Other special pseudo-operations may handle character-coded
data.
The label in the operand field must, of course, have been previously defined. Often, the operand field may
contain more complex expressions, as we shall see later. Double name assignments (two names for the
same data or address) may be useful in patching together programs which use different names for the same
variable (or different spellings of what was supposed to be the same name).
Note that an EQU pseudo-operation does not result in the assembler placing anything into memory. It
simply places an additional name in a table (called a symbol table) which the assembler maintains.
100
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 100
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Most assemblers allow the programmer a lot of freedom in describing the contents of the Operand Address
field. But remember, the assembler has built-in names for registers and instructions and may have other
built-in names.
Some common options for the operand field are:
1) Decimal numbers
Most assemblers assume all numbers to be decimal unless they are marked otherwise. So
ADD 100
means "add the contents of memory location 100 decimal to the contents of the accumulator".
2) Other number systems
Most assemblers will also accept binary, octal, or hexadecimal entries. But you must identify these
number systems in some way, e.g., by preceding or following the number with an identifying
character or letter. Here are some common identifiers:
B for binary
0, Q, or C for octal (we avoid O because of the confusion with zero).
H for hexadecimal (or standard BCD)
D for decimal. D may be omitted, it is the default case.
Assemblers generally require hexadecimal numbers to start with a digit (e.g., 0A36 instead
of A36) in order to distinguish between numbers and names or labels. It is good practice to enter
numbers in the base in which their meaning is the clearest — i.e., decimal constants in decimal;
addresses and BCD numbers in hexadecimal; masking patterns or bit outputs in binary if they are
short, and in hexadecimal if they are long.
3) Symbolic names
Names can appear in the operand field; they will be treated as the data which they represent. But
remember. there is a difference between data and addresses. The sequence
FIVE EQU 5
ADD FIVE
will add the contents of memory location 5 (not necessarily the number 5) to the contents of the
accumulator.
101
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 101
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Most microprocessors have many two and three-word instructions. Thus you will have difficulty
determining exactly how far apart two assembly language statements are. Therefore, using offsets
from the Location Counter frequently results in errors which you can avoid if you use labels.
5) Character codes
Most assemblers allow text to be entered as ASCII strings. Such strings may be surrounded either
with single or double quotation
marks; strings may also use a beginning or ending symbol such as A or C. A few assemblers also
permit EBCDIC strings.
We recommend that you use character strings for all text. It improves the clarity and readability of
the program.
Assemblers vary in what expressions they accept and how they interpret them. Complex
expressions make a program difficult to read and understand. We have made some
recommendations during this section but will repeat them and add others here. In general, the user
should emphasize clarity and simplicity. There is
no payoff for being an expert in the intricacies of the assemblers or in having the most complex
expression on the block. We suggest the following approach:
102
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 102
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
CONDITIONAL ASSEMBLY
Some assemblers allow you to include or exclude parts of the source program, depending
on conditions existing at assembly time. This is called conditional assembly; it gives the assembler
some of the flexibility of a compiler. Most microcomputer assemblers have limited capabilities for
conditional assembly. A usual form is:
IF COND
.
CONDITIONAL PROGRAM
.
.
.
ENDIF
If the expression COND is true at assembly time, the instructions between IF and ENDIF(two pseudo-
operations) are included in the program.
MACROS
You will often find that particular sequences of instructions occur many times in a source program.
Repeated instruction sequences may reflect the needs of your program logic, or they may be compensating
for deficiencies in your microprocessor's instruction set .You can avoid repeatedly writing out the same
instruction sequence by using a macro.
Macros allow you to assign a name to an instruction sequence. You then use the macro name in your
source program instead of the repeated instruction sequence. The assembler will replace the macro name
with the appropriate sequence of instructions. This may be illustrated as follows:
103
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 103
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
Macros are not the same as subroutines. A subroutine occurs once in a program, and program execution
branches to the subroutine. A macro is expanded to an actual instruction sequence each time the macro
occurs; thus a macro does not cause any branching.
P a g e | 104
BY MR. AKETCH – A TVET TRAINER - KENYA COAST NATIONAL POLY
13/02/2019
COMMENTS
All assemblers allow you to place comments in a source program. Comments have no effect on the object
code, but they help you to read, understand, and document the program. Good commenting is an essential
part of writing assembly language programs; without comments programs are very difficult to understand.
Use comments to tell what the program is doing, not what instructions do.
Comments should say things like "IS TEMPERATURE ABOVE LIMIT?", "LINE FEEDTO TTY", OR
"EXAMINE LOAD SWITCH".
LOADERS
The loader is the program which actually takes the output (object code) from the assembler and places it in
memory. Loaders range from the very simple to the very complex.
105
BY M R. AKE TCH – A TVE T TRAINER - KENYA CO AST NATIO NAL POLY 13/ 02/2019
P a g e | 105