SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
Lecture Notes on Microprocessor and Microcomputer
Compiled by
Sep 2019
Ekeeda
INPUT
MICROPROCESSOR & MICROCOMPUTER: -
Microprocessor is an electronic device, which can perform basic arithmetic/logical functions
such as and, or, add, subtract upon given input signals. The word 'micro' is used to indicate the
physical size of the components involved. Microprocessor is a VLSI (Very Large Scale
Integration) device that contains thousands of gates in a single chip. It constitutes the heart of a
microcomputer and it fetches microinstructions from memory, decodes the instructions into a
series of actions, and carries out these actions in a sequence of steps. All microprocessors
contain microprograms, which impart basic logic given by their instruction set for which they
are called “Microprogrammed devices”. The microprocessor is usually enclosed in one IC
package called a 'Microprocessor chip'. The microprocessor and associated support chips make
up the “Central Processor or Central Processing Unit (CPU)” which is also called the ”Micro
Processing Unit” (MPU). The CPU is the nerve center of any digital computer, since it
coordinates and, controls the activities of all the peripheral units and performs all the
calculations. All instructions to be executed must be held within the CPU, and all data to be
processed must be first loaded into it.
In 1971, Intel corporation released the world’s first microprocessor-the 4004, a 4-bit
microprocessor; it can address 4096 4-bit memory locations and its instruction set contained 45
different instructions. Prior to this all processor functions within computers were built of
discrete logical devices. Sometimes the terms, microprocessor and microcomputer are used
interchangeably, but actually microprocessor is the controlling element to which ROM, RAM
and I/O ports are added to make a microcomputer.
Microcomputers are defined as the first small desktop computers that were based upon an 8-bit
microprocessor with upto 64Kbytes of memory, and input/output (I/O) ports for connecting
peripheral units. Microcomputers are also termed as “Personal Computers”. The first
microcomputers were intended for single users only, and this clearly distinguished them from
“Minicomputers” however the later 16, 32 and 64-bit microcomputers have operating systems
and peripheral connectivity to support many simultaneous users, and there is no clear
distinction between them and so-called minicomputers.
DATA BUS
CONTROL
BUS
ADDRESS BUS
Block diagram of a Microcomputer.
APPLICATIONS OF MICROPROCESSORS (MICROCOMPUTERS): -
While comparing microprocessors it is better to consider the application at hand. Generally,
there are three types of microprocessor depending on the usage:
1. General or All-Purpose microprocessor.
2. Embedded or Dedicated microprocessor.
3. Peripheral Control microprocessor.
A General-Purpose microprocessor is capable of executing various instructions and can be
instructed as to what specific sequence of operations it must perform. It has myriad of
applications as personal computer in education, business, and home.
On the other hand, Embedded or Dedicated microprocessors are special purpose
microprocessors, the sequence of micro-operations is fixed and the computer performs the same
specific task over and over again. These used to control 'smart machines' such as microwave
ovens, food blenders, washing machines, and driers. These are also termed as 'Microcontrollers'.
Basically, a microcontroller is a single chip computer. Contained in one integrated circuit (IC)
package are the CPU, ROM, RAM, and several I/O lines. The advantage of using a
microcontroller is that many logic devices can be condensed into a single IC. It greatly improves
MEMORY
(RAM/
ROM)
CPUI/O
PortOUTPUT
Sep 2019
Ekeeda
reliability. Also, by changing the control program in ROM, new control functions can be added
or modified without any rewiring. One of the fastest growing applications of microcontrollers is
in the automotive industry.
Peripheral Control microprocessors are attached to main microprocessors. So they are also
referred as 'Attach/ Slave microprocessors/Coprocessors'. These are used in many computer
systems for video graphics, data communication, sound synthesis, floating-point math, and direct
memory accesses (DMA). Their main objective is to offload the main microprocessor, thus
saving time and improving speeds. As a result, the main processor is able to concentrate on
higher-level tasks resulting in improved system performance. The concept of 'Distributed
Computing or Processing' is evolving, and future microcomputers systems will be designed with
separate processors for each I/O device in the system. Distributed processing is the organization
of processing in such away that a number of machines (microprocessors) can cooperate in
exchanging data over a network. Local processing is carried out locally and the exchanged data
affects the system as a whole.
CLASSIFICATION OF COMPUTER SYSTEMS: -
The real power of a computer is the titanic speed with which it performs calculations. A
computer sequentially performs one operation at a time. The time required to perform
operations is called the 'Processing Speed' of the computer. This rate is expressed in millions of
instruction per second (MIPS). Computers are classified according to their processing speed. It
depends not only on the hardware characteristics of the system but also on the efficiency of its
software components. Some hardware characteristics of importance in achieving high
processing speed are as follows:
Word Length/Size: is the number of bits treated by the computer as a unit. It can be 4-, 8-, 16-,
32-bits and so on e .g., a 16-bit word will be able to hold numbers in the range from -215
through
+215
-1. The number of different types of instructions is directly related to the word length/size.
So it can be concluded that larger the word length, the greater the processing speed.
Data Path Size: depends on the width of the internal CPU buses. Wider data paths speed up
CPU operations, since more information is transmitted in a single transfer.
Other important hardware functions are the logic family, overlapping of CPU instructions,
memory bandwidth, I/O bandwidth etc.
THE Intel 8088/86 MICROPROCESSOR FAMILY: -
The width of the data bus in bits is usually used to categorize the microprocessors. On this basis
of word length they are categorized into:
1. 8-bit microprocessor.
2. 16-bit microprocessor.
3. 32-bit microprocessor and so on.
The width of data bus determines how much data the microprocessor can read or write in one
memory or I/O cycle. The term 16-bit means that its ALU, its internal registers, and most of its
instructions are designed to work with 16-bits (also called 'word'). Some microprocessors have
an internal data bus wider than the external one, e.g. in the Intel 8088 the widths of the external
and internal data buses are 8- and 16-bits respectively, for which it is also referred to as “8/16-
bit microprocessor”. Another example of 8/16-bit microprocessor is Motorola’s 68008. Anyhow,
it is the external data bus that determines the bits transferred during a memory or I/O machine
cycle. Consequently, a device like the 8088 is still considered an 8-bit microprocessor.
The 8088 is one of the pioneer members of the third generation microprocessors, a direct
descendent of the 4004, the world’s first CPU and the heart of the earliest personal computers.
VLSI techniques have given it a lot of muscle- the ability to manipulate 16-bit data, directly
address a MB of memory, a hefty operating speed and a versatile 16-bit instruction set.
FUNDAMENTAL STEPS OF A MICROPROCESSOR CYCLE: -
Execution of an instruction starts from the program counter (PC), which contains the address of
the instruction and ends with the placement of the result in the appropriate location. The
sequence of steps during execution of instructions is:
1. Fetch Instruction: Every instruction cycle begins with an op-code fetch bus cycle i.e., a
memory read of the op-code.
2. Determine Operand: The operand is required to execute the instructions.
3. Execute Instruction: Control signal from the control unit activates the operation, so the
instructions are executed.
Sep 2019
Ekeeda
4. Store the Result: The memory stores the result in the specified location, and the
execution/microprocessor cycle ends.
After completing one instruction, the CPU moves on to the next one. This fetch and execute
process is repeated until all of the instruction s in a specific program have been executed. The
CPU’s lifeblood, its heartbeat is the system clock, which synchronizes all activities within the
computer. Each step in the microprocessor cycle takes at least one tick of the system clock called
a 'Clock Cycle or T Cycle' e.g., one T cycle for 8088 5MHz is 200 nanoseconds. We measure the
speed of an instruction by the number of clock cycles required to execute it. A clock cycle is the
microprocessor's smallest unit of time measurement. Each instruction takes a determined
number of clock cycles to execute, depending on the types of operands. The manufacturer and
the computer designer determine the speed of the clock itself.
8088/8086 CPU ARCHITECTURE: -
The term architecture in relation to microprocessor refers to the internal design and
organization of the device. Every microprocessor does two basic things over and over again-
fetching instructions and then executing them. The older microprocessors could only do one
thing at a time, if it is busy fetching an instruction it could not execute one. Whenever CPU
finished executing one instruction, it had to wait for the next one to be gotten from system
memory. This waiting meant a lot of lost and potentially usable microprocessor time. One of the
features introduced with the 8088 is the idea of instruction queue. This feature is a regular part
of mainframes, but had never appeared in a single chip CPU unit until it was designed into the
8088.
The entire process of reading memory, incrementing the IP, and decoding the instruction is
known as the 'Fetch and Execute principle' of the stored program computer. A stored program
computer that works mainly instructions held in store (ROM/RAM) and these can be altered.
One way of increasing the processing speed of a microprocessor is to clock at a higher
frequency. Another way is to employ the 'Pipelining Technique'.
A computer performs sequentially one operation at a time i.e., CPU performs all the tasks
involved in processing an instruction such as fetching, decoding, determining operands, and
executing instructions serially on a one-at-a-time basis. It is termed as 'Serial or Sequential
Fetch/Execute Cycle'. On the other hand, 8088/8086 incorporates 'Overlap Fetch/Execute Cycle',
which is also known as 'Pipelining Technique'. This technique is based on the overlapping of the
execution of several instructions simultaneously. Each instruction is executed as a number of
cycles that must be performed in sequentially. Thus we enable several instructions to be done by
the execution of different cycles on different instructions concurrently.
Fig shows that a model of 8088/86 CPU, which consists of two separate processors, called the
Bus Interface Unit (BIU) and the Execution Unit (EU). Since these tow units are entirely
independent of each other, the 8088 can do two things at the same time. Together they form a
two-stage pipeline. Each unit performs certain tasks associated with the instruction processing
simultaneously and this allows the 8088/86 to achieve a higher execution rate.
1.Bus Interface Unit (BIU): fetches instructions, calculates addresses, fetches operands and
writes results in memory as requested by the EU. However, if no such requests are outstanding
and the bus is free, the BIU proceeds to fill any vacancies created in the Instruction Queue (IQ).
2. Execution Unit (EU): receives program instructions and data from the BIU, executes these
instructions, and stores the result in the general registers. When the EU completes the execution
of an instruction, it passes to the BIU any results (destined for memory or I/O) and proceeds to
the next instruction. The BIU, of course, very likely to be already waiting in the IQ. So the EU is
completely isolated inside the 8088 and is totally dependent on the BIU for communicating with
the real world.
This technique makes recent microprocessors different from previous ones as in it the BIU does
not have to wait to pass the EU a fetched instruction before reading from memory another one.
Instead, it builds a reserve of 4-6 bytes into First-in-First-Out (FIFO) buffer called an
'Instruction Queue or Pre-fetch Queue' (IQ). FIFO is the processing of items in a list such that
the earliest arrival is processed first and the latest arrival is processed last.
The main advantage of the Pipelining is that the EU can execute instructions almost continually
instead of having to wait for the BIU to fetch a new instruction. The IQ has increased the
processing speed also called “Throughput” (productivity of any machine, system or procedure
measured in some term meaningful to the process under consideration) by storing four pre-
Sep 2019
Ekeeda
fetched instructions (six in the 8086). This is obvious from the model of 8088/86. Another subtle
advantage to the Pipelined Architecture is that as the next several instructions are in the IQ, the
BIU can access memory at a 'leisurely' pace. This means that slow-memory parts such as
printers can be used without affecting overall system performance. There are three conditions
that will cause the EU to enter in a 'wait' mode.
1. Firstly when an instruction requires access to a memory location not in the queue.
2. The second condition occurs when the instruction to be executed is a “Branch/Jump”
instruction. In this case control is to be transferred to a new (non-sequential) address.
3. The last condition occurs during execution of instructions that are slow to execute. This can
cause the BIU to suspend fetching instructions.
CONSTRUCTION OF BIU AND EU: -
Firstly, the main parts of the Bus Interface Unit (BIU) are:
1. The instruction Queue
2. The register array
3. An adder
4. A control section
Secondly, the main parts of the Execution Unit (EU) are:
1. The register array
2. The main ALU
3. A flag register
4. A control section
The register array serves addressing purposes. For BIU it includes four segment registers and
instruction pointer, all of which are 16-bits long. This particular adder is used only for address
calculations. It does not possess the full arithmetic/logic capabilities of ALU of the EU. Each
unit of the 8088 has its own independent control section. The control sections generate the basic
timing pulses to control the activities of the circuits operating within the system to ensure that
each instruction occupies a predetermined period, referred to as “Instruction Time”. Here the
control section of the BIU is responsible for all data transfers over the external CPU bus. The
flag register shows the status of the CPU or the results of microoperations.
CPU ORGANIZATION: -
The basic principles of operation of a microprocessor are similar to those of minicomputer and
mainframe central processors. Although many microprocessors are equipped with advanced
features, their basic organization still consists of three main sections.
1. Arithmetic Logic Unit (ALU)
2. Control Unit (CU)
3. Registers
1. Arithmetic Logic Unit (ALU): An ALU is a multioperation, combinational logic digital
function. To perform a microoperation, the control routes the source information from registers
into the inputs of the ALU. The ALU receives the information from the registers and performs a
given operation as specified by the control. The result is then transferred to destination register.
By definition, the ALU is a combinational circuit; thus the inter-register operation can be
performed during one clock cycle. In some microprocessors the result is placed in a specific
register called an 'Accumulator or Accumulator register', abbreviated AC or A register. The
accumulator register in a processor unit is a multipurpose register capable of performing many
microoperations. The operations performed on the data stored in registers are called
'Microoperations'. A microoperation is an elementary operation that can be performed in
parallel during one clock pulse period. Examples of microoperations are shift, count, add, clear,
and load etc. In fact, the gates associated with an accumulator register provide all the digital
functions found in an ALU.
2. Control unit (CU): The CU generates prefetched signal sequences timed by pulses derived
from a clock. The type of the signal sequence depends on the op-code (operation code) and
inputs fed from source external to the CPU. Such external inputs may be a request to interrupt
the program (an interrupt request) or a request to surrender the external bus (bus request). The
CU generates two types of signals:
A: Internal activation of the ALU and the opening/closing of data paths between registers.
B: External control signals for the memory and the I/O. These are sent either for activation of
data transfer or as response to interrupt or bus requests.
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
ALAH
Very often the CUs of microprocessors employ 'Micro-coding'. Micro-codes or microinstructions
are instructions at machine code level, which directly control the functioning of hardware
independently of operating system or application software. A sequence of microinstructions is
called a ' Micro-program', which is stored entirely within the CU of a microprocessor, and
usually created by the designer of the microprocessor and not normally alterable by users. The
main advantage of micro-program control is that, once the hardware configuration is
established there should be no need for further hardware or wiring changes. Hence a micro-
program stored in the memory implements the CU in the CPU.
3. Registers: are special store locations generally having a capacity equivalent to the word size
of the computer concerned and having specific properties for use during arithmetic and/or
logical operations. The registers in a computer may be classified as either operational or
storage type.
An 'Operational register' is capable of storing binary information in its flip-flops and, in
addition, has combinational gates capable of data processing tasks. A 'Storage register' is used
solely for temporary storage of binary information. This information cannot be altered when
transferred in and out of the register. The bulk of the registers in a digital computer are storage
registers, to which information is transferred for storage and form which information is
available when needed for processing. Comparatively few operational registers are found in the
processors. Registers exchange information through internal buses. Multiple internal buses
allow overlapping of certain operations and therefore increase processing speed. The word
length of each register is usually equal to the width of internal data buses. The number of
registers in a processor may vary from just 1 to 64 registers or more. Some special purpose
registers are as:
A. Program Counter (PC): is also called “Control Counter” stores the address of the next
instruction to be performed. Prior to the execution of a program, the PC is loaded with the
starting address of that program. Thereafter it is incremented every time a new instruction is
fetched such that, since the instructions of a program occupy adjacent ascending addresses, it
always points to the location of the next instruction.
B. Instruction Register (IR): holds the address of the current instruction. Program instruction
consists of two parts; op-code and address field. The IR extracts only the opcode part from the
data buffer. Subsequently the CU decides this opcode and generates the control signals.
C. Buffer Register: holds addresses, data and isolate the external data buses of the CPU from
its internal buses.
D. Status Register: stores the program status word, consisting of status and control bits, which
contain information about the condition of a peripheral unit. This information includes, e.g.,
warning when a peripheral unit needs attention such as there is no paper on a printer and is
entered into the status word automatically.
E. Stack Pointer: holds the addresses of the instructions. We will discuss all registers in detail
below.
INTERNAL 8086/88 REGISTERS: -
While programming 8086/88 we must have adequate knowledge of the various registers in the
EU and BIU. Fig shows these registers into logical groups to form a “Programming Model”.
The 8086 microprocessor has several internal registers that can store binary data. Registers are
special work areas inside the 8086, designed to be accessed at high speed and all these registers
are 16-bits long. Now we will take a closer look at each of these registers in this section.
General/Data Registers: -
Four registers named “Data or General registers” consist of the AX, BX, CX, and DX registers.
All general registers are used for storing intermediate results. These registers can be accessed
as a byte (8-bits) or a word (16-bits). The upper halves of each of these registers are called AH,
BH, CH, and DH. Similarly the lower halves of these registers are labeled AL, BL, CL, and DL.
Bit positions are always numbered from right to left, starting with 0.
Bits: 7… …………………… 0 7...................................... 0
Instructions may address either 16-bit or 8-bit registers from the following list.
Janu lay the game.ose, it is how you phether you win or lIt is not wary 2001
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
January 2001 It is not whether you win or lose, it is how you play the game.
AX BX CX DX
AH AL BH BL CH CL DH DL
Although all the data registers can be used interchangeably for many operations, each of the
registers is used for specific purposes.
1. Accumulator (AX): AX register is also called the Accumulator. It possesses some
features that the other data registers don't have. Many operations are also slightly more efficient
when performed with AX.
2. Base Register (BX): Like other data registers, the BX register can perform logical,
arithmetic, data movement, and it has special addressing abilities. Like SI, DI, and BP it can
hold memory address that points to another variable.
3. Counter Register (CX): acts as a counter for repeating or looping instructions. These
instructions automatically repeat and decrement CX and quit when it equals 0.
4. Data Register (DX): has a special role in multiply and divide operations e.g., when
multiplying, DX holds the high 16-bits of the product.
Index Registers: -
The Index register SI, DI are 16-bit registers (you cannot access the low or high bytes alone)
which can be used for temporary storage just like the general registers. However, their main
purpose is to hold the 'offset' of variables. The offset refers to the distance of a variable, label, or
instruction. These registers are used as 'Memory Pointers'. Each instruction must refer to an
index register when addressing locations in storage areas. Both the index registers can be used
for general storage but their real strength shows up when they are used during powerful string
handling functions.
1. Source Index (SI): is named after the 8088's string movement instructions, where the SI
register points to source string. SI usually contains an offset value from the DS register, but it
can address any variable.
2. Destination Index (DI): acts as the destination for 8088's string movement instructions. DI
usually contains an offset value from the ES register, but it can address any variable.
Pointer Registers: -
Any location used to hold the address of another locations said to act as a pointer to that
location. Pointer Registers are 16-bit registers as follows:
1. Base Pointer (BP): contains the offset from the SS register. It is used to access data
in the stack segment.
2. Stack Pointer (SP): The 'Stack' is a set of contiguous memory locations where items are
added or removed such that the latest arrival is processed first and the earliest arrival is
processed last, for which it is called a Last-In-First-Out (LIFO) stack. A stack is different from
any other memory location in that data are put on and taken from the top of the stack and is
reserved to store operand and instructions. The SP points to the top of the stack. In other words,
it holds the address of the item currently occupying the top. So the SP contains the offset address
of the top of the stack. The SS and SP registers combine to form the complete top-of-stack (actual)
address. 8088 can handle an unlimited number of stacks. Each one can be upto 64K in size and
located anywhere in the 8088’s one mega address space. The only restriction is that their 64K-
size limit and they must start at an address boundary that is an even multiple of 16 bytes.
3. Instruction Pointer (IP): essentially plays the role of a PC and its only one function is
containing the address of the next instruction to be executed. When an instruction is executed,
the IP is automatically incremented the number of times needed to point the next instruction.
However, its contents don't specify a physical memory address but an offset. CS and IP combine
to form the address of the next instruction to be executed. IP is physically part of the BIU and
not under direct control of the programmer as are the other pointer registers.
Flag Register: -
is a special 16-bit register in which individual bit positions are used as flags (a bit used to mark
the occurrence of a specific event) to show the status of the CPU or the results of
microoperations. Each relative bit position is labeled; other positions are undefined. A flag or
bit is set when it equals 1; it is clear/reset when it equals 0. There are two basic types of flags:
1. Control Flags
2. Status Flags
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
January 2001 It is not whether you win or lose, it is how you play the game.
Control Flags can be set or reset directly by the programmer and are used to control the
operation of the processor. These are Trap (TF), Interrupt-enable (IF), and Direction (DF) flags.
While Status flags are the status indicators that reflect the outcome of microoperations
performed by the CPU. These are the Overflow (OF), Sign (SF), Zero (ZF), Auxiliary (AF),
Parity (PF), and Carry (CF) flags. The instruction set of a computer includes instructions, which
test these flags.
Bit Positions
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
- - - - O D I T S Z - A - P - C
N.B: Bits marked” – “are undefined.
Although it is a 16-bit register but only 9-bits are used. Others were left for future use.
Segment Registers: -
The 8086/88 divides its 1MB of memory address space into four segments registers which are
used as base locations for program instructions, data, and the stack. In fact, all references to
memory on the IBM-PC involve a segment register used as a base location. This means that at
any instant four different 64-Kbyte segments are defined. These four segments may partially or
completely overlap. The four segment registers are:
1. Code Segment (CS): contains the executable instructions.
2. Stack Segment (SS): contains the base location for the current program stack.
3. Data Segment (DS): is the default base location for memory variables. It contains the data
used by the program
4. Extra Segment (ES): is an additional base location for the memory variables and is used for
a variety of useful purposes.
In general segment registers keep every thing nicely organized. This is a big help in creating
software. The advantage of using internal registers for the temporary storage of data is that,
since the data is already in the EU, it can be accessed much more quickly than it could be
accessed in external memory.
COMMUNICATION PATH IN CPU: -
A channel along which signals travel from one of several sources to one of several destinations
is called a "Bus, Highway or Trunk". So bus is a collection of electronic signal lines all
dedicated to a particular task. In 8088/86 there are three buses:
1. Address bus.
2. Data bus.
3. Control bus.
1. Address Bus: is a one-way road over which the microprocessor sends an address to memory
or other external device. The size/width of the address bus is specified by the number of bits it
can handle. Early microprocessors had 4-bit address lines. This number has increased to 8, 16,
20, 24, and 32 as microprocessor technology has advanced. The number of address lines
determines the number of memory location lines that can be addressed. If the CPU has N
address lines, then it can directly address 2N
memory locations. The lowest address is 0 and the
highest 2N
-1. For the 8088/8086 address bus is 20 bits wide and it allows the microprocessor to
output 220
=1,048,576 unique addresses. Each memory location contains 1byte=8bits of data.
Thus 8088/86 can address 1 Mbytes of memory. The wider the address bus, the more memory
locations a microprocessor can access.
2. Data Bus: indicated by the double-ended arrows is “a double way road or bi-directional”
i.e., the CPU can read in from memory or I/O device or it can write data to memory or I/O
device. A bi-directional data bus is used to save pins in the IC package. The width of the data
bus in bits is usually used to categorize the microprocessors as it determines how much data the
microprocessor can read or write in one memory or I/O cycle. Depending upon the particular
microprocessor, the data bus can handle 8, 16, 32 or 64 bits.
3. Control Bus: Each time the CPU outputs an address it also activates one of four control bus
signals: MEMORY READ, MEMORY WRITE, I/O READ, I/O WRITE.
The control bus also identifies the direction of data flow on the data bus. In short, the control
bus coordinates CPU’s operations. When MEMORY READ or I/O READ is active, data is input
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
January 2001 It is not whether you win or lose, it is how you play the game.
to the CPU. When MEMORY WRITE or I/O WRITE is active, data is output by the CPU i.e., the
control bus signals are defined from the CPU's point of view.
In a nutshell, the CPU manages the flow of data between itself, memory, and the I/O ports via
the address, data, and control buses. The control and address buses are output lines only (uni-
directional), but the data bus is bi-directional. This “Three-bus Architecture” is commonly
present in all microcomputer systems.
SEGMENTED ADDRESSING METHOD: -
Now we will see how the 8088/86 microprocessors manage to address up to 1MB of memory. An
“Address” is a part of instruction that specifies the location of an operand. Each stored
word/byte is allocated a number. By specifying this number of the particular word as a part of
instruction access is obtained to the operand stored within the word.
When the EU decodes an instruction, it determines the applicable addressing modes. Then it
manipulates each operand field. Since internal data bus is 16-bits wide, the EU handles
quantities up to 16-bits long. A 16-bit address allows unique identification of 216
=65,536 or
64K-bytes locations so 4-digit hexadecimal number in the range 0000H can represent the 16-bit
address to FFFFH. An address within a segment is called a 'Segment/Base address'. So a
segment address, located within one of the segment registers (a unique feature of 8088), defines
the base address of any 64K-byte memory segment. The offset address selects a location within
the 64K-byte memory segment.
But since the 8088/86 can address 1MB of memory, the 16-bit must be augmented somehow to
make possible unique identification of 1million=106
byte locations. Here the BIU plays its role
in address computations. The BIU takes the relative/offset address derived by the EU and adds it
to the segment address. Before the addition, the contents of a segment register are shifted four
positions in the direction of the Most Significant Bit (MSB) i.e., to left (adding four zeros on the
right). Then the adder adds this new number to the second number (offset) to give a 20-bit
address, which is termed as the "Absolute/Real/Physical Address". This is the actual address of
location expressed in terms of machine code numbering system, and it is obtained by adding the
segment/base address to the offset/relative address. Addresses presented over the external buses
are always physical addresses.
The lowest possible physical address corresponds to an all-zero offset and thus coincides with
the segment address itself. Note that due to the 4-bit shift, segment addresses are always multiple
of 16. The highest possible physical address corresponds to the maximum possible value of the
offset i.e., segment address+64K. By loading different offset addresses in the segment registers,
any location in the 1MB address space may be accessed. Such an approach to administering a
large address space is known as "Relative Addressing or Segmented Addressing". In this
technique instruction are written so that they do not refer directly to absolute addresses in
memory; instead a base address is added to the address component (Offset address) of each
instruction when the program is loaded in order to create numbers of absolute locations. The
advantages of segmented addressing are as follows:
1. The greatest advantage is that reference offset/logical address only can be loaded and run
anywhere in memory i.e., it allows programs and data to be relocated in memory without
changing. A “relocatable program/data” coded in such a way that it can be stored and executed
in any part of the memory. This is because the segment addresses always range from 0000H to
FFFFH, independent of the offset addresses. Similarly a program can access large data
structures by setting the current segment address to a new block of memory. This enables a
programmer to write a program in several independent segments without having to consider the
absolute addresses required.
2. Secondly, one program can work on several sets of data. In a time-sharing system, several
users share a CPU. Because segmentation keeps data and programs separate from one another,
so it is easy to switch from one user's program to another user's program i.e., the program
segments can be written independently by different programmers each using relative addresses.
3. This scheme requires only a 16-bit number to represent the contents of a segment
register and only a 16-bit offset to access any memory location. This means that the CPU has to
handle and store only 16-bit numbers instead of 20-bit numbers.
COMPARISON OF iAPX 8088 & iAPX8086: -
The Intel 8008 is considered as the first microprocessor, which had an address space of
16Kbytes and only two addressing modes. 8080, 8085, 8088, and 8086 microprocessors followed
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
January 2001 It is not whether you win or lose, it is how you play the game.
it. In 1978, Intel released the 8086 and a year later, the 8088. Both can address a 1-M bytes (8-
bit wide) or a 512-K word (16-bit wide) memory. The 8086 is more powerful than 8088, with
exactly the same 16-bit instruction set and memory addressing, but with greater processing
speed. However, the differences between 8088 and 8086 are:
1. Firstly in 8088, the BIU data bus path size is 8-bit data bus versus the 16-bit of 8086. So the
8088 requires two memory read cycles to input the same information that the 8086 inputs in
one memory read cycle. A 'Memory Cycle' is defined, as the time required accessing the
memory read or writing a byte. These additional cycles slow down 8088 (as they consume a
huge amount of processing time), making it less efficient than 8086.
2. Because of its wider external data bus 8086 (16-bit microprocessor) has higher processing
speed than the corresponding 8088 (8/16-bit microprocessor). Although the cost difference
between two devices is not very large.
3. One more difference is that the 8088-instruction queue (IQ) is 4-bytes long while 8086-
instruction queue is 6-bytes long.
4. Another difference is that as 8086 was introduced after 8088 so both are not pin compatible.
Their pin assignments are not the same.
The important point to note, however, is that programs written for the 8086 can be run on the
8088 without any changes. Because the EU is the same for each processor, the instruction sets
are exactly the same for each. More advanced microprocessors seem to appear each year, but
the manufacturers such as Motorola and Intel have made a conscious effort to make the new
chips downwardly compatible. This makes the new CPU’s much more attractive to the system
designers. This means that programs written for the older processors (such as 8088/86) will run
on the newer ones, such as 80286, 80386, 80486, and so on but not necessarily the other way
around.
COMPUTER INSTRUCTIONS: -
Computer instructions are made up of two parts. The first part is called the “Operation Code or
op-code” for short, which specifies the operation to be performed. The second part called the
“Operand” is the item in an operation from which the result is obtained by means of defined
actions i.e., it indicates the source and/or destination of the data acted on by the op-code. As an
example, the instruction INC AX is made up of the op-code INC (increment) and the operand AX
(accumulator register). In this case AX is the source and destination of the data. These are the
limitations on the types of operands:
1. CS and IP may never be destination operands.
2. Immediate data and segment registers may not be moved to segment registers.
3. The source and destination operands must be the same size.
4. If the source is immediate data, it must not exceed 255 (FFH) for an 8-bit destination or
65,535 (FFFFH) for a 16-bit destination. The list of the all op-codes the computer can
execute is called “Instruction Set or Order Code”. Generally it is the set of symbols and
characters forming the rules of a particular computer code or programming language.
The instruction set of a particular microprocessor specifies the register-transfer operations and
control decisions that are available in the microcomputer system. When an instruction is stored
in memory it is the binary code representing (that instruction) that is actually stored. For the
instruction INC AX the single byte (8-bits) 01000000 (40H or 64D) is stored. Anyhow, most 8086
instructions require more than one byte. Some instructions will require as many as seven bytes.
The best way to appreciate the instruction set is to write programs that perform meaningful data
processing tasks. The power of an instruction set is usually judged from the number of
instructions needed to perform a specific complex task. Fewer instructions mean generally less
memory space for the program and shorter task execution times. Hence, the instruction set is
considered more powerful. Instruction sets may not only differ on the type of operations, but also
the data types on which instruction are performed. Generally, the instruction sets are different
for different microprocessors, but there are certain basic instructions that are included in all
microprocessors.
SOFTWARE: THE Intel 8086/88 INSTRUCTIONS SET: -
Writing software means telling the CPU what operations to perform as well as specifying the
order of execution. Even though external data bus of 8088 is only 8-bits wide but it is only for
wiring support chips and laying out the PC board. But the instruction set of the 8088 has all the
features of the older 8-bit CPU’s as well as whole collection of powerful new 16-bits instructions.
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
January 2001 It is not whether you win or lose, it is how you play the game.
The 8088 can understand over 95 separate instructions and have 24 ways to generate an address.
Generally microprocessor instructions may be classified into three distinct types.
1. Data Transfer Instructions are concerned with operations which entail the movement of data
between registers in the processor and between registers and memory locations (words)
without changing the binary information content.
2. Data Manipulation Instructions perform arithmetic, logical, and shift operations on data
stored in registers or memory locations. They also set, clear, or complement status or flag
bits.
3. Control Instructions provide means for controlling the program and the state of the CPU.
These instructions provide decision-making capabilities and change the path taken by the
program while execution.
Last two types may be classified further into categories as follows:
1. Data Manipulation Instructions.
A: Arithmetic Instructions. B: Logical Instructions.
C: Shift/Rotate Instructions. D: Bit manipulation Instructions.
E: String processing Instructions.
2. Control Instructions.
A: Program control Instructions. B: Processor/Machine control Instructions.
1. Data Transfer Instructions:-
Microprocessors spend most of their time accessing memory locations and moving data from
place to place. So these instructions transfer one byte/word of data from one location to another.
e.g., MOV LOC1, LOC2 move data form LOC2 to LOC1
Data transfer instructions include XCHG, XLAT, PUSH, POP, IN, OUT, LDS, LES, LEA,
PUSHF, POPF, LAHF, SAHF etc.
2. Data Manipulation Instructions:-
A: Arithmetic Instructions: give the 8088 its computational capabilities. The 8088 can directly
do ASCII arithmetic. Decimal data can be coded into hex in two ways-either as packed (standard
BCD) or unpacked (ASCII) numbers. Secondly 8088 can do multiplication and division of 8- or
16-bit numbers with a single instruction. And can handle signed or unsigned numbers. Unsigned
numbers are scalar quantities. An 8-bit unsigned number can be as large as 255 and a 16-bit
unsigned number can go upto 65,535. These numbers only represent magnitudes; they are not
positive or negative. While signed numbers (also called integers) are vector quantities. Because
in these MSB is used to indicate the sign (direction). If the sign bit is clear (0) the number is
positive and if it is set (1) the number is negative. So for 8-bit numbers range is –128 to +127
and for 16-bit numbers range is –32,768 to +32767.Examples are
ADD LOC2, LOC1 add contents of LOC1 and LOC2
INC LOC increment the contents of location LOC by 1
Other arithmetic instructions are ADC, AAA, DAA, SUB, SBB, DEC, NEG, CMP, AAS, DAS,
MUL, IMUL, AAM, DIV, IDIV, AAD, CBW, CWD etc.
B: Logical Instructions: are used for doing logical operations e.g.,
AND LOC2, LOC1 AND each bit in both bytes/words
NOT LOC Invert each bit of a byte/word
There are five logic instructions available with the 8086/88 microprocessor; NOT, AND, OR,
XOR, TEST. TEST is the most useful instruction. Each function is performed bit by bit between
the source and destination operands. These instructions are all performed in the ALU and affect
all the flags.
C: Shift and Rotate Instructions: shifts or rotate the bits of an operand in either direction. The
rotated quantity can be an 8/16-bit CPU register or memory location. The main difference
between a shift and rotate is that the shifted bits 'fall off' the end of the register, whereas the
rotated bits 'wrap around' i.e., in rotate instructions, bits shifted are not lost, instead, they
reenter from the other side. Within the shift group of instructions there are both arithmetic (SAL
and SAR) and logical (SHL and SHR) shift instructions. In shift right operations, there are two
types:
1. Logical, where 0s enter from the left.
2. Arithmetic, where the sign bit preserves it by reentering.
In all these instructions the carry flag is involved. These are also used in doing multiplication
and division. Fig shows ROL, ROR, RCL, RCR are the rotate instructions.
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
January 2001 It is not whether you win or lose, it is how you play the game.
D: Bit Manipulation Instructions: are used for testing, setting, or clearing a bit within a byte/
word). Such instructions specify both the addresses of the location and the desired bit position.
Logical, shift and rotate instructions are sometimes referred to as “Bit manipulation
instructions”.
E: String Processing Instructions: 8086/88 has several instructions for moving large blocks of
data or strings (a set of consecutive characters or digits). These instructions have a special
addressing mode of their own, for all these instructions the source is DS: SI and the destination
is ES: DI. Nothing like these instructions had ever been available before e.g.,
MOVS LOC2, LOC1 move string form LOC1 to LOC2.
MOVSB/MOVSW move byte or word from one string to another.
CMPS, LODS, STOS, SCAS, REP, REPE, PEPZ, REPNE, REPNZ are important string
instructions.
3. Control Instructions: -
The stored program computer repeatedly follows the sequence: fetches the instruction whose
address is in IP, increments IP, and executes the instruction i.e., all programs are executed
sequentially. However, sometimes it is necessary to transfer control to an address that is not the
next instruction in sequence.
Examples are instructions that must be executed repeatedly, groups of instructions that are
shared through out a program, conditional transfer based on the state of the flags, and software
interrupts. Control instructions may be conditional or unconditional. A 'Conditional Control
Instruction' causes a jump/branch out if normal program sequence only when a specified
condition is detected. Whereas, an 'Unconditional control Instruction' causes a branch
unconditionally. In short, these instructions allow program control to be transferred to a new
non-sequential address.
A: Program Control Instructions: The branch out of normal program sequence is
accomplished by changing the program counter (PC) since it contains the address of the next
instruction to be executed. Therefore, program control instructions change the contents of the
PC which in turn transfers control to another part of a program e.g.,
JMP LOC Go to specified address
The 8088 has a wide range of JUMP commands based on various conditional tests e.g.,
Jcond LOC Jump if condition is satisfied
One common programming problem is to setup a group of instructions that must be executed
several times. One of the CPU registers is loaded with the loop count and this register is
decremented by 1 at the end of each loop. A JNZ (jump if not zero) instruction transfers control
back to the start of the loop if the counter register is not zero. The 8088 instructions are
designed exactly for this application e.g.,
LOOP LOC Loop until CX=0
JCXZ LOC Jump to LOC if CX=0
Important instructions are CALL, RET, LOOP, LOOPE/LOOPZ, LOOPNE/LOOPNZ etc. All
loop instructions repeat until CX = 0. This means that the loop will be repeated 65,536 times if
CX= 0 initially.
B: Processor/Machine Control Instructions: affect the operation of the processor itself and
include instructions concerned with setting and clearing flags that are used during normal
program operations. e.g., STC set the carry flag.
WAIT wait until TEST pin active.
NOP do absolutely nothing (no operation).
Other significant instructions are CMC, CLI, STI, CLD, STD, CLC, INT, INTR, INTO, ESC,
LOCK, HLT etc. The instructions HLT, WAIT, LOCK, ESC are specifically designed to use with
external devices like coprocessors.
ADDRESSING MODES: -
Computer instructions are made up of an op-code and zero, one, or two operands. Sometimes
instructions with no operands are called 'zero-address instructions'. Those with one operand are
called 'one-address instructions', and so on. Usually, microprocessors specify one or two
operands. The valid operands depend on the internal organization of the microprocessor and the
different ways in which the microprocessor generates these operand addresses are called the
'Addressing Modes' which may be one of three basic types: register, immediate, or memory. The
8086 has nine different addressing modes.
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
January 2001 It is not whether you win or lose, it is how you play the game.
Intel addressing modes, in fact, are some of the most complex available in any assembly
language. However, these modes give the experienced programmer flexibility for writing
programs that are more efficient with respect to the number of instructions and execution time.
The data addressing modes are:
N.B : Because MOV instruction is common and flexible, it provides a basis for explanation of the
data addressing modes.
Immediate Addressing Mode: Instructions that use this mode get their data as part of the
instruction and it is commonly used to load a register or memory location with some initial data.
In this mode the operand is specified in the instruction itself as the term 'immediate' implies that
the data immediately follow the hexadecimal op-code in the memory. An immediate operand is a
constant expression, such as a number, a character, or an arithmetic expression. It transfers the
source-immediate byte/word into the destination register or memory location e.g.,
MOV AX, 1000H
Register Addressing Mode: In this mode the operands are the CPU registers which reside within
the CPU. In general, this mode is the most efficient because register are part of the CPU and no
memory access is required. The microprocessor contains the following 16-bit registers; AX, BX,
CX, DX, SP, BP, SP, and DI and 8-bit registers AH, AL, BH, BL, CH, CL, DH, and DL. Any
registers may be used as source operand, and any registers except CS and IP may be used
destination operands. For example,
MOV AX, BX
Another point must be again remembered that registers being used must be of the same size.
Because mixing is not allowed by the microprocessor and results in an error when assembled.
These instructions are wrong:
MOV BL, DX Not allowed (mixed sizes)
MOV ES, DS Not allowed (segment to segment)
MOV CS, AX Not allowed (CS cannot be the destination register)
Direct Addressing Mode: In this mode the memory address is supplied directly as part of the
instruction. A direct operand refers to the contents of memory at an address implied by the name
of a variable. In 8-bit microprocessors as 8088 with 16-bit addresses, a direct instruction
consists of 3 bytes. e.g.,
MOV AH, MEMBDS copies the 8-bits of data segment location MEMBDS into AH
MOV AX, NUMBER copies the 16-bits of data segment location NUMBER into AX
Register Indirect Addressing Mode: allows data to be addressed at any memory location
through an offset address held in any of the following registers: BP, BX, SI, DI. In this mode
memory address (EA) is supplied in a pointer or index register e.g.,
MOV AX,[SI]
MOV AX,[BX]
Indirect Memory Access Addressing Modes: -
The direct addressing mode is useful for infrequent memory accesses. Anyhow, when a memory
location must be read/written to several times, the repeated fetching of the two- byte logical
addresses makes this mode inefficient.
The Relative/Indirect Memory Access Addressing Modes solve this problem by storing the
memory addresses in a pointer or index registers. A relative-mode instruction is a 2-byte
instruction, with the second byte specifying a signed number in the range between –128 and
+127. It is accomplished by representing the number in sign-2's complement form. This 2's
complement displacement can be added to the pointer or index registers to offset the location
pointed at.
Hence indirect addressing is a technique in which the address part of an instruction refers to
another location which contains another address. This further address may specify an operand
or yet another address. This technique is also called “Multi-level Addressing”
Indexed Addressing Mode: In it memory address (EA) is the sum of the index register plus a
displacement within instruction e.g., MOV AX,[SI+6]
In general, a displacement can be added to a base register and the result added to an index
register. The resulting address is often referred to as the 'Direct/Effective Address' (EA). This
address is computed by the information provided in the instruction i.e., the computation has to
take place before the instruction can be executed. It is the address of the operand or the address
where control branches in response to a control instruction. In a direct-mode instruction the
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
January 2001 It is not whether you win or lose, it is how you play the game.
effective address is equal to the address part of the instruction. The displacement is limited to a
single byte, allowing the EA to be varied +127 bytes (7FH) to –128 (80H) from the base pointer.
Based Addressing Mode: In it memory address (EA) is the sum of the BX or BP registers plus a
displacement within instruction e.g., MOV AX, [BP+6]
Based and Indexed Mode: In it memory address (EA) is the sum of the index register and a base
register e.g., MOV DX, [BX+SI]
Based and Indexed with displacement Mode: In it memory address (EA) is the sum of an index
register, a base register, and displacement within instruction e.g., MOV AX, [BX+SI+6]
String Addressing Mode: Because of their importance, 8086/88 has several instructions
designed specifically for handling strings of characters. These instructions have a special
addressing mode of their own, for all these instructions the memory source is DS: SI and the
memory destination is ES: DI. For example
MOVSB/MOVSW move byte or word from one string to another.
Remember that two base registers or index registers cannot be combined. Finally, note that the
default memory segments for all the indirect addressing modes are the stack segment when BP is
involved, and the data segment when register BX, SI, or DI is involved. The most powerful
feature of the indirect addressing modes is that the memory address can be changed based on
program conditions.
8088 CPU PIN DESCRIPTION: -
The 8088 microprocessor is a VLSI (Very Large Scale Integration) device that contains
thousands of gates in a single chip. It is housed in a 600-mil wide, 40-pin dual-in-line package
(abbreviated DIP, an IC packaged so that external connections can be made through two
parallel rows at right angles to the edges of the package). Many of these pins are time
multiplexed, providing two separate processor functions. Some pins are devoted to support
coprocessors. It was difficult to provide access to all the functions of the microprocessor with in
a single chip. Actually the 8088 microprocessor has a 20-bit address bus, an 8-bit data bus,
three power pins, and seventeen pins devoted to miscellaneous control and timing functions.
The Intel (the leading microprocessor manufacturer) employed a design technique called “Time
Division/Sharing Multiplexing”, a system whereby a number of terminal devices are connected
to the same communication channel and each occupying the channel for the data transmission
for short periods at regular intervals. Each unit transmits data by the use of timesharing
techniques such that all units appear to transmit simultaneously over one channel. In this way
one circuit pin has more than one function e.g., the 8088’s pins, labeled A16/S3 to A19/S6 are
the address lines during the state T1 clock state, and become status indicators during the T2-T4
states. A special de-multiplexing circuit (circuit used to separate the signals that were combined
for transmission by a compatible multi-plexer) is required to separate these lines.
Another attractive feature of the 8088 is its ability to operate in two modes, named the
“Minimum Mode” and the “Maximum Mode. The minimum mode is designed for simple single
processor systems on one printed circuit board (PCB). Whereas the maximum mode is designed
for more complex systems with separate I/O (short for input/output) and memory boards. This
mode also supports coprocessors such as the 8087 NDP (Numeric Data Processor) and 8089
IOP (Input Output Processor).
ADDRESS BUS (AD0-AD7, A8-A15, A16/S3-A19/S6:-)
These 20 pins correspond to the microprocessor’s 20-bit address bus and allow accessing
220
=1,048,576 unique memory locations. Because the 8088 have an 8-bit external data bus,
there is no need to multiplex the A8-A15 address lines. Thus these pins carry information
throughout the bus cycle and need not be latched.
The address pins on the 8088 are functionally divided into three groups; AD0-AD7, A8-A15,
A16-A19. The reason for this breaking is that not all of them carry the address all the time.
The first group, AD0-AD7, is the most versatile. During the first part of an instruction cycle, the
8088 puts the lower 8-bits on these pins. During the second part of the instruction cycle, CPU
removes the address from these lines and floats them (tri-stated) to get them ready for their next
job. When the 8088 reaches the third part of its instruction cycle, it uses these pins as the data
lines. During this stage of the instruction cycle these pins become bi-directional.
The second group of the address pins, A8-A15, area set of plain vanilla address pins and the
potion of the address they carry stays valid for the entire instruction cycle.
The final address pins, A16-A19 make the 8088 a 16-bit CPU since they are the addresses from
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
January 2001 It is not whether you win or lose, it is how you play the game.
10000H (65,536D), to FFFFFH (1,048,575D). These lines carry valid address data at the same
time as the first group of address lines. Then carry status signals which indicate the address
segment currently in use (S3 & S4), the state of the interrupt enable flag (S5), and a flag to
indicate that the 8088 has control of the bus, (S6).
DATA BUS (AD0-AD7): -
These eight pins form the microprocessor’s bi-directional data buses. So these pins and A16/S3-
A19/S6 only need to be multiplexed. Data is transferred only on the AD0-AD7 address/data lines.
ADDRESS LATCH ENABLE (ALE): -
This output signal separates the low order address and data. Since these signals are multiplexed
on the same pins, an external signal is required to determine what kind of information is
currently on the pins. When ALE becomes active (goes HIGH), the 8088 is telling you that the
entire 20-bit address is on the bus. So this output is used to de-multiplex the address, data, and
status lines on AD0-AD7 and A16/S-A19/S6.
INPUT/OUTPUT MEMORY (IO/M): -
The 8086 microprocessor’s M/IO becomes IO/M on the 8088. The 8088/86 does not output
separate memory and I/O read and write signals. Instead, this pin indicates that the address bus
contains either a memory or an I/O port address. This line goes to HIGH to indicate that the
CPU is talking to an I/O port and LOW when the CPU wants to deal with system memory.
READ (RD): -
Read is to obtain data from one form of store (e.g., magnetic disk) and transfer it to another (e.g.,
memory of the microprocessor). It is an active low output that indicates the 8088 wants to read
data either from memory or an I/O port. It can be combined with IO/M to form MEMR and IOR
control signals. RD will remain high until the address is removed from the bus. AD0-AD7 first
carry the address, then float, and then function as the data bus. So the RD does not become
active until the bus floats. Consequently, when the RD is active, data appears on the bus.
WRITE (WR): -
Write is to transcribe (retype) data on to a form of store from another form of store (e.g.,
transcribing data on to a magnetic disk from the microprocessor’s main memory). This signal is
the counterpart of RD and indicates that data is to flow from the microprocessor to memory or
to an I/O device.
CLOCK (CLK): -
The CPU’s heartbeat is the system clock and it is fed to the CLK input. Clock provides
accurately timed pulses at fixed intervals to monitor, measure, or synchronize other units
operating within the system. It supervises operations to detect looping and similar error
conditions, and also provides time in hours and minutes for maintaining an operation log (a
record of series of events). Without the clock signal, there would be chaos.
Secondly internal registers are made from dynamic memory cells (regenerative storage units in
which signals representing data has to be constantly regenerated so that information can be
retained as long as required) that require periodic refreshing or they will lose data. The clock
signal provides this refresh. Thus the clock must never be stopped. This means the minimum
clock speed for any 8088 is 2 MHz but the maximum rate depends on the version of the 8088
being used. The signal clock must be asymmetrical (33% duty cycle), with steep rise and fall
times. Intel makes the 8284; a clock generator circuit that generates clock pulses perfectly
tailored to the 8088. It also provides fully synchronized startup and manual reset as well.
STATUS (A16/S3-A19/S6): -
These five status signals designed primarily for diagnostic testing purposes, as their definitions
in the table given below indicate. It is possible to decode S3 and S4 to provide four separate
1MB-address spaces for the extra, data, code, and stack memory segments.
S3-S6 Bit Definitions
S4 S3 Bus Cycle Access To
0 0 Extra Segment
0 1 Stack Segment
1 0 Code Segment or None
1 1 Data Segment
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
January 2001 It is not whether you win or lose, it is how you play the game.
DATA TRANSMIT/RECEIVE (DT/R): -
This line is a companion to the DEN line. This signal is intended to control the direction of data
flow through the buffers (synonymous with buffer stores are temporary store areas used to
compensate for the different speeds at which the various units can handle data) connected to the
system data bus. When DEN lets the buffers know that the 8088 is not using the data bus, DT/R
tells them whether the CPU is expecting them to send (DT/R LOW) or receive (DT/R HIGH) data.
Both of these outputs were designed to use with Intel’s 8286 or 8287 data transceivers (terminal
units which can both transmit and receive data).
DATA ENABLE (DEN): -
This output is an active (LOW) signal that is most used to control the enabling of external data
buffers. When the line is active, the 8088 is telling all the system that the data bus is available
for use. By letting DEN control access to the data bus, we are guaranteed not to have any timing
hassles, not any caused by “Bus Contention” i.e., two circuits attempting to drive the same bus
line by disabling the data bus buffers until when the address/data lines no longer hold the
memory or I/O address.
MINIMUM/MAXINMUM MODE (MN/MX): -
This pin is used to set the 8088 in either the MINIMUM or MAXIMUM mode. In general when
designing a system with several microprocessors accessing the address and data buses the 8088
must be configured in the MAXIMUM mode, (MN/MX tied LOW). The 8288 “BUS Controller”
does this all. The redefined pins drive the 8288, which decodes them into an expanded set of
control signals. Consequently, we get 20 control lines in the MAXIMUM mode as opposed to 13
in MINIMUM mode. Single board systems can get along well with the control signals provided
by running the 8088 in the MINIMUM mode (MN/MX=1). The control lines that are altered by
the MN/MX setting show up on pin# 24 through pin#32 and pin#34.
RESET: -
Reset is defined as a hardware or software function, which causes a computer system to enter a
predefined initial status in which all variable hardware or software states restored to a set of
initial values. The RESET pin is an active HIGH signal that stops the 80888 dead in tracks.
There is a bit of failsafe on this line since the RESET signal has to stay HIGH for at least 4 clock
cycles before it will be taken seriously by the CPU. Once this time requirement is fulfilled, the
8088 will float the address and data lines and do absolutely nothing else until the line is brought
LOW again. When the RESET line is released, the CPU will jump to the instruction you have
stored at the power-up location of FFFF0H. When this pin is driven HIGH, most of the 8086/88
CPU registers are reset, as shown in the table given below: However, because CS register
contains FFFFH (segment address), the CPU will fetch its first instruction from the physical
address calculated as: CS: IP=FFFF0H + 0000H = FFFF0H.
CPU STATE FOLLOWING RESET
CPU CONTENT
FLAGS Clear
IP 0000H
CS FFFFH
DS 0000H
SS 0000H
ES 0000H
IQ Empty
Hence whenever the 8086/88 is reset, it begins executing instructions at memory locations
FFFF0H and disables interrupts by clearing the IF flag/bit. RESET is normally used when first
starting a computer or after a system crash (failure). It is also very handy when you are trying
out new code, since software in the development stage produces crashes more often than results.
TEST: -
The TEST input is a way of stopping the 8088 until it is started up again by some external event.
This input is used together with the WAIT instruction. If the TEST input is HIGH when the WAIT
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
January 2001 It is not whether you win or lose, it is how you play the game.
instruction is encountered, this WAIT instruction functions as NOP instruction; execution of the
program is suspended and the computer enters an “Idle Mode”, the mode during which the
system remains inactive even though switched on and otherwise in an operable condition. Only
when the TEST returns LOW will execution resume (with the instruction following WAIT
instruction). Normally, this input is driven by 8087 coprocessor. This prevents the CPU from
accessing a memory result before the coprocessor has finished its calculations.
READY: -
The READY input signal is used by either memory or I/O to let the 8088 know when the
requested data operation is finished. When the data transfer is completed, the external device
can let the 8088 know it is done by putting a high on the READY line. The most common use for
the READY line is to slow the 8088 down when it is dealing with slow-memory external devices
that can not handle data at CPU speed. It is employed to insert wait states into the machine
cycle. If it is found LOW (not ready), the microprocessor enters a wait state and remains idle.
INTERRUPTS (INTR, NMI, INTA): -
The INTR pin, the Interrupt Request input gives you way to the 8088’s powerful external
interrupt servicing routines. The 8088 can handle 256 vectored, prioritized levels of interrupt
and it looks at INTR at the end of each instruction cycle. If the CPU sees that the line has been
made active (HIGH) by an external device it will jump/vector to the subroutine whose address
has been stored in memory in a lookup table.
INTR and NMI are hard-wired interrupt requests, which function exactly as software interrupts.
The INTR input can be masked (Masking is the technique of devising a bit pattern called a Mask
to alter or isolate specific bit positions present in another bit pattern) by resetting the IF control
flag (CLI) i.e., clearing this bit blocks all interrupts on INTR effectively masking this input.
The INTA (Interrupt Acknowledge) line is an output that becomes active (LOW) when an
external device makes an interrupt request by putting a HIGH on the INTR pin. Whenever the
8088 receives this request, it waits until the current instruction cycle is ended and then puts a
LOW pulse on the INTA line for two consecutive cycles referred to as “interrupt acknowledge
cycles”.
NMI is the “Non-Maskable Interrupt” also known as the “disaster Line” that will always be
serviced. It is called this because, since there is no way for it to be disabled by software, most
systems reserve it to indicate that some sort of catastrophic events such as power failure or
memory errors, is going to happen. To make the input more responsive, the NMI input is edge,
rather than level-triggered. This means that the 8088 will react during the low to high transition
of the NMI line instead of waiting for it to reach a high. Once the line has been activated, the
8088 will finish executing the current instruction and then jump to the NMI handling routine
whose address has been stored in the appropriate place in the lookup table.
HOLD, HOLD ACKNOWLEDGE (HOLD, HLDA): -
HOLD is useful for multiprocessor systems since it is a perfect signal for avoiding bus
contention. The most common use for HOLD is doing DMA, (Direct Memory Access). DMA is a
powerful way to get things done without having to involve the 8088. One of the best examples of
DMA is dynamic refresh. If we let the 8088 handle it, the processor’s built-in overhead (due to
instruction fetch and execute times) will really stretch out the operation. HOLD is an active high
input that causes the microprocessor to open circuit all of its bus lines. This effectively
disconnects the CPU from its memory and I/O, allowing a second processor to access these units.
HLDA is the output used by the 8088 to let external devices that it has removed itself from the
bus and has floated all the lines. If a device like Intel’s 8237 DMA Controller is used, then
HLDA acknowledges the DMA request to the DMA Controller.
POWER & GROUND (VCC & GND): -
A 5MHz 8088 microprocessor requires +5.0-V +/-10% and draws 340-mA maximum and its
power dissipation are a 1.7-W. The 8088/86 require a single +5.0-V power supply and have two
ground pins (#1 & #20). The GND connection is the return for the power supply (VCC ). Both
GND pins must be connected to ground for proper operation. Remember both GND pins are not
electrically connected in the IC. Making the assumption that they are tied together and letting
one float will guarantee flakey (erroneous) operation at best and foul smelling smoke at worst.
STATUS SIGNAL OUTPUT (SSO): -
This is the only new signal on the 8088, which takes place of BHE/S7 on the 8086. This signal
will give an up to minute report of what the 8088 is currently doing on the bus. This signal can
Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect)
January 2001 It is not whether you win or lose, it is how you play the game.
be combined with DT/R and IO/M to encode the current bus cycle. As fig below shows this
information can be used for diagnostic testing purposes.
8088 STATUS DECODING
IO/M DT/R SSO FUNCTION
0 0 0 Interrupt acknowledge
0 0 1 Memory Read
0 1 0 Memory Write
0 1 1 Halt
b1 0 0 Codes access (op-code fetch)
1 0 1 I/O Read
1 1 0 I/O Write
1 1 1 Passive (No Activity)
Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect)
December 2000 A fault confessed is half redressed.
PROGRAM: -
All computers must be programmed to perform even the most elementary tasks. A set of
instructions (statements) given to the computer to perform a certain job is called a
“Computer Program”. These computer programs guide the computer, through orderly
set of actions specified by the people called “Computer Programmers”.
Since a computer cannot reason, but is entirely dependent on instructions supplied to it
by its all too users. So it cannot perform any task adequately unless the problem it is
required to solve has been specified correctly in every detail and the instructions it is
asked to obey define in complete detail each step of the solution.
PROGRAM STATEMENT: -
Program statement is a single complete meaningful instruction containing some
constants, operators, variables, and keywords (informative words which have special
meanings to a compiler and cannot be used as data names).
PROGRAMMING LANGUAGES: -
In order to communicate with each other, men use language; in the same way, languages
are used to communicate instructions and commands to a computer i.e., languages are
the medium by which man communicates problems to the computer. So language is a set
of words, symbols, characters etc., for communication. Languages used for writing
computer programs are called ”Programming Languages”.
The choice of programming languages will depend upon the complexity of the problem,
and the capacity and resources of the computer to be used.
There are three levels of programming languages:
1. Low-level Languages (Machine Languages).
2. Symbolic Languages (Assembly Languages).
3. High-level Languages.
1. LOW-LEVEL LANGUAGES (MACHINE LANGUAGES): -
Low-level languages (Machine languages) are the only languages that a computer can
understand. These instructions are written in the form of binary strings of 1’s and 0’s
which can be immediately obeyed by a computer without translation. In a strict sense, in
a low-level language each instruction has a single corresponding machine code
equivalent.
The programs written in these languages are fast in execution. On the other hand it is
difficult to learn machine languages because it requires detailed knowledge of hardware
(all the electronic and mechanical units which together form a computer system).
Machine language programming is very tedious because you must determine the hex
code for each instruction used. With over 100 mnemonics and 3800 different forms of the
8086 instructions, this process is time consuming and error prone. There is no single
machine language because each computer can understand only its own machine
language. So machine languages are machine (computer) dependent i.e., a particular
machine language can be used only on one type of computer.
2. SYMBOLIC LANGUAGES (ASSEMBLY LANGUAGES): -
Assembly language is a set of instructions for a particular microprocessor. It was
developed in 1950s. It provides a direct correspondence between symbolic operation
codes and machine language, for which it is termed “Symbolic language”. Like machine
languages each microprocessor or microprocessor family has a different Assembly
language, because the design of the microprocessor influences the instructions it can
execute.
Assembly language uses two-, three-, or four letters “mnemonics” to represent each
instruction type. A mnemonic is a short alphabetic code that helps us to remember a CPU
instruction. The letters in mnemonics are usually initials or shortened forms of the
English words for the operation performed by the instruction, e.g., the mnemonics for
subtract is SUB, the mnemonic for multiply is MUL etc.
Assembly language statements are usually written in standard form consisting of four
fields as shown below:
Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect)
December 2000 A fault confessed is half redressed.
LABEL
FIELD
OP-CODE
FIELD
OPERAND
FIELD
COMMENT
FIELD
NEXT: ADD AL, 07H ; add 07H to register AL
Label field is the first in each Assembly language statement (i.e., the left-hand column of
the statement) and it is not essential to have an entry in this field for each instruction.
Labels are followed by a colon (:). An entry here is treated as a name, which can used to
identify the specific line of the program and hence its memory address. Usually labels are
used as addresses within program control instructions (JUMP, BRANCH etc.) to cause
control to pass to an instruction bearing a specific label.
Op-code field contains the mnemonics for the instructions to be performed. Op-code is an
acronym for “Operation Code”.
The Operand field contains data, memory address (A binary numeric code given to a
memory location in order that location can be selected for reading or writing under
program control), port address, or the registers (special storage locations of the
microprocessor concerned) on which operations are to be performed. An instruction may
contain zero, one, or two operands. The choice of the operand is usually determined by
the “Addressing Mode”. The addressing mode tells the Assembler where to find the data
in each operand e.g.,
PUSH AX ; one register
MOV AX, BX ; two registers
ADD BX, 1000H ; register, immediate value
The final field the Comment field starts with a semicolon (;). Comments, annotation or
narrative are written notes which are included in the coding of a program in order to
clarify operations but have no effect on the program itself, i.e., are not translated into
machine language.
3. HIGH-LEVEL LANGUAGES: -
In contrast to a low-level language in a high-level language each instruction has several
corresponding machine code instructions. These languages are very close to human
languages, i.e.; these languages provide us more familiar notation rather than machine
codes of the computer e.g., mathematical notation in FORTRAN and English in COBOL
etc. Each language has its own rules (which govern the structure of the language
statements) for writing source programs/codes. These rules are called “Syntax” of the
language.
Features which high-level languages have in common are the fact that they are
“problem-oriented” rather than “machine-oriented” and also myriad of compilers are
available for converting the high-level language programs into the machine codes of
different types of computers. Programs can be written faster in high-level languages than
their counterparts (either low-level languages or Assembly languages), because they
work with larger building blocks. Whereas these program always almost execute more
slowly and require more memory than programs written in their counterparts. Unlike
Assembly and machine languages high-level languages are designed to keep them as
much computer independent as possible. A high-level language program is generally
“portable”, i.e.; it may be executed on any computer with some minor amendment to
cater for any differences of configuration or idiosyncrasies of translators. Obviously
high-level languages are more desirable from programmer’s standpoint than either
machine languages or Assembly languages. The important high-level languages are:
FORTRAN: is an acronym for FORmula TRANslation. It is a high-level language for
scientific and mathematical use; introduced in 1957.
COBOL: is an acronym for COmmon Business Oriented Language was developed in
1959. It is primarily used for commercial applications that require precise and efficient
manipulations of large amount of data. Today more than half of all business software (in
contrast to hardware, software are programs which can be used on a particular
computer) is still programmed in COBOL.
BASIC: is an abbreviation for Beginners All-purpose Symbolic Instruction Code. It was
introduced in 1965 and originally designed for developing programs in
Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect)
December 2000 A fault confessed is half redressed.
“Conversational/Interactive Mode” (An operational method in which the user is in direct
communication with the computer and obtains immediate response to his input messages),
in an on-line programming environment. Because of its simplicity and comparative
power it is much used on personal computers.
PASCAL: was named after Blaise Pascal (seventeenth century mathematician);
introduced in 1971 as derivative of ALGOL.
C: was introduced after the language B in 1972. It was developed for system
programming.
C++: an extension of C was developed in the early 1980s. It provided the capabilities for
“object-oriented programming”.
Today most operating systems (are programs which supervises the running of other
programs) are written in C and /or C++. C and C++ are among the most powerful and
most widely used high-level languages.
Programs that involve a lot of hardware such as robots and control systems or programs
that must run quickly are usually best written in low-level or Assembly languages.
Complex data processing problems that manipulate massive amount of data employ high-
level languages. Now-a-days Assembly languages are also interspersed (intermix) with
C/C++ and Pascal to perform machine control functions efficiently.
TRANSLATORS: -
Translators are complex programs, which convert instructions written in one
programming language to the format of another programming language without
changing the meaning of the information and this process is called “Translation”.
A program written in any programming language other than machine language requires
conversion to machine language before it can be executed. Translators convert “Source
program/code” (written by the programmer) into a known as “Object program/code”
(binary machine code equivalent). Translators as well as providing a way for
communicating the instructions, also allow the programmer to perform additional
functions e.g., storage areas used by the particular program can be defined and allocated,
and the programmer can define and store any constants etc. There are three types of
translators:
1. Assemblers
2. Compilers
3. Interpreters
1. ASSEMBLERS: -
Assemblers convert Assembly language programs into equivalent machine code. These
are similar to compilers but are specifically developed for Assembly language. These
programs perform the tedious “bookwork” of all the instructions. Since the Assembler
allocates actual numerical values to addresses referred to by labels in the source
program, the programmer does not have to remember the addresses of locations or
instructions. Further, if he alters his source program, when it is assembled again
addresses will be automatically adjusted wherever they occur. They come with some form
of editor or wordprocessor (a text-editing device) that allows easy creation of the source
code.
2. COMPILERS: -
Compiler converts high-level language programs into equivalent machine code. A
compiler normally generates several low-level instructions for each high-level (source)
language instruction, whereas an Assembly language is one-for-one with machine code.
The compilation of a high-level language program can take a considerable amount of
computer time. During compilation a compiler:
A: translates each high-level language statement into its machine code equivalent.
B: incorporates into the object program any library subroutines used. Routnes /
Subroutines are programs that carry out a well-defined function, and a collection of
proven routines/subroutines developed by the software manufacturer/user is called a
“Program Library or Standard Library”.
C: supplies the interconnecting links between parts of the program.
Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect)
December 2000 A fault confessed is half redressed.
Since a translator (compiler/interpreter) can translate only particular language for
which it is designed, one will need to use a separate translator for each programming
language.
3. INTERPRETER: -
Interpreter is synonymous with “Conversational compiler or Interpretive routine”, which
uses the conversational/interactive mode of computer operation in which the user enters
each high-level (source) language statement in turn to the computer, which immediately
checks its validity and informs the user if he can proceed or must correct a mistake.
Hence an interpreter is identical to a compiler, except that an interpreter translates and
then executes a program line by line. Interpreters are popular in program development
environments in which programs are frequently recompiled as new features are added
and errors are corrected. Once a program is developed, a compiled version can be
produced to run most efficiently.
The compiler has several advantages over the interpreter: -
1. First, the source code does not have to be recompiled/reinterpreted again and again
when loops/control loops (series of instructions are repeated until some specified
condition is satisfied) are encountered.
2. Second, the object code will run by itself without the need for the interpreter to be
resident in the memory. This saves memory and allows larger programs to be written.
The main disadvantage of using a compiler is that errors will require reinvoking the
editor, correcting the errors and recompiling the program. This can be frustrating when
simple “Syntax Errors” appear.
Hardly any computer program could avoid performing arithmetic. The ADD instruction
adds and 8- or 16-bit source operand to a destination operand of the same size. The
syntax of ADD instruction is:
ADD destination, source
The source operand will remain unchanged by the operation e.g., in the given instruction
ADD AX, BX
This ADD instruction adds AX, a 16-bit Accumulator register to BX, 16-bit Base register.
Assembly Language Operation
ADD AX, BX AX=AX+BX
OPERATIONS AND RESULTS: -
MOV is a Data Transfer instruction. It copies data from one operand to another operand
of the identical size (word size). The syntax of MOV instruction is: -
MOV destination, source
Data is merely copied from the source to the destination, so the source operand is not
altered. This source operand may be a register, a memory operand or an immediate
numeric value. This destination operand may be a register, or a memory operand. The
following types of data transfers are possible:
immediate data to register/ memory
register to register
register to memory
memory to register
(a) MOV BX, 03FFH
This MOV instruction will put the 16-bit immediate value (03FFH) into the 16-bit BX
register. It is a common error to make the source operand greater than the destination
operand.
(b) MOV AL, 0DBH
This MOV instruction will put 12-bit immediate value (0DBH) into the 8-bit AL register.
In this case say only the hex value DB will be stored.
(c) MOV DH, CL
A MOV instruction involving only registers is the fastest type taking only two clock
cycles (of the clock signal generator, which synchronizes all the operations of the
computer). Registers should be used when an instruction must execute quickly. This MOV
instruction will move the contents of 8-bit register DH into the 8-bit CL register.
(d) MOV BX, AX
Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect)
December 2000 A fault confessed is half redressed.
This MOV instruction will copy the contents (data) of 16-bit AX register to the 16-bit BX
register.
ASSEMBLY LANGUAGE STATEMENTS: -
Adding integer 5 to integer 2.
MOV AH, O5H
ADD AH, O2H
INSTRUCTION CLASSIFICATION: -
As we have discussed major types of instructions in Chapter#02 (Microprocessor
Architecture), so now will confine our discussion only to classify the instructions
mentioned in our curriculum (course):
DATA TRANSFER INSTRUCTIONS: - MOV, XCHG, PUSH, POP
ARITHMETIC INSTRUCTIONS: - ADD, SUB, INC, DEC, CMP
LOGICAL INSTRUCTIONS: - NOT, AND, OR, XOR, TEST
SHIFT/ROTATE INSTRUCTIONS: - ROL, SAL
PROGRAM CONTROL INSTRUCTIONS: - JMP, JNC
STRING INSTRUCTIONS: - REP
PROCESSOR/MACHINE CONTROL INSTRUCTIONS: - ESC, HLT, STD, CLC
PROGRAMMING: -
Programming is the process by which a set of instructions (program) is produced for a
computer to make it perform a specified activity. Before writing a program for a
particular problem, it is essential to have a thorough understanding of the problem and a
carefully planned approach to solving the problem. It is of paramount importance to
clearly isolate every single step and every single condition that can possibly occur during
the solving the problem. For writing a program the main steps are:
1_ Understand the problem, and plan the solution.
2_ Prepare a flowchart, Pseudocode, or Decision Table of the problem.
3_ Prepare the instructions in coded form.
4_ Test the program until it is performing
5_ Prepare detailed documentation of the program and instructions on its operation.
Understanding the problem is of fundamental importance. Mostly the programmer works
from a detailed program specification (algorithm). This algorithm includes descriptions
of all input to the program, the processing required, and details of all output from the
program. i.e., once a problem is properly analyzed, the next step is to write a sequence of
actions involved in the solution of the problem, called an “Algorithm”.
Therefore an algorithm is a procedure for solving a problem in terms of the actions to be
executed, and the order in which these actions are to be executed. Specifying the order in
which statements are to be executed in a program is called “Program Control”.
“Pseudocode” is an artificial and informal language that helps programmers develops
algorithms. Pseudocode is similar to everyday English language; it is convenient and
user-friendly although it is not an actual programming language. Pseudocode helps the
programmer think out a program before writing it in a programming language.
Pseudocode instruction consists purely of characters arranged in symbolic form. Then a
carefully prepared pseudocode program may be easily converted to a corresponding
programming language simply by replacing pseudocode instructions with their source
language equivalents.
The next step is “Flowcharting” the problem A “Flowchart” or “Flow-diagram or Logic
diagram“ is a graphical representation of an algorithm and “Flowcharting” is the
technique of drawing the flowcharts.
The object of flowcharting is to show the logical relationship between the various parts
of the program. The flowchart is very useful in understanding the flow of logic (program
control). It is particularly important to maintain an overall flowchart when
“Segmentation” (programming technique in which a lengthy and complex problem is
divided into a series of shorter units called “Segments, or Chapters”) takes place to
ensure that all parts of the problem are taken careof.
In a nutshell, a flowchart is very useful in planning and designing a complex problem. A
flowchart is then used as the basis for writing a program. A flowchart is normally
Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect)
December 2000 A fault confessed is half redressed.
independent of the type of the computer as well as the programming language to be
employed.
In a Flowchart all the operations are shown by the various conventional symbols which
are connected with each other by the arrows s (flow lines) to indicate the flow of logic.
The important symbols are:
FLOWLINES: (Arrows) show the transfer of program control from one operation to
another.
TERMINAL: symbol (an Oval) represents a terminal point in a flowchart e.g., start,
stop, halt, or interrupt.
INPUT/OUTPUT: symbol (a Trapezoid) is used for input/output operation.
PROCESS/ACTION: symbol (a Rectangle) indicates any type of calculation or logical
manipulation.
DECISION: symbol (a diamond) shows a decision point at which different alternative
paths may be selected. It is normally entered from the top and have at least two exists
although a third may be added if desired.
CONNECTOR: symbol (a Circle) represents any entry to or exit from another point of
the flowchart. It is used to indicate a transfer of program control that cannot be
conveniently shown by a flow line e.g., because the flowchart continues on another page.
Whenever, broken/segmented parts are to be connected, the circles connecting them must
have the same numbers.
Like pseudocode, flowcharts are very useful in developing and representing algorithms,
although most programmers strongly prefer pseudocode.
N.B: For more exercise, consult the class lectures in which pseudocode, algorithms and
flowcharts for various programs had been developed.
MAJOR STEPS IN DEVELOPING AN ASSEMBLY LANGUAGE PROGRAM: -
Coding the program follows the completion of flowcharts. The logical steps described in
the flowchart are translated into instructions. The programmer’s ultimate goal is to
reproduce the logic of the program shown in the flowchart as simply, economically, and
efficiently as possible. Assembly programs typically go through these phases:
1.EDITING STEP: -
The first step is creating a source file. Source files are created using an “Editor” (a
program that assists us to prepare text or data entry to or output from a computer or to
retrieve and rearrange data previously stored in a file) that comes with an assembler.
Any word processor or editor can be used that is capable of generating a text (ASCII) file.
The programmer types an Assembly program with the editor and makes corrections if
necessary. The program is then stored on a secondary storage device such as a disk. The
source program file you generate must use the extension “.ASM“ that is required for the
assembler to properly identify your source program.
2. ASSEMBLY STEP: -
During this step the Assembler or Assembly routine converts a symbolic source module
(file) into a hexadecimal object file/code. This object code is the machine language
version of the source program but it lacks certain information needed by the operating
system (DOS) before it may be executed. This is designed as an input file to the linker.
Object file names end with the “.OBJ“ extensions.
3. LINKING STEP: -
Linking step is the next step. Assembly programs contain references to functions defined
elsewhere, e.g., in the “Standard/Program Libraries”. The object code produced by the
Assembler typically contains “holes” due to these missing references. A Linker provided
with the Assembler links the object code for the missing functions and produces an
executable file with the extension “.EXE”. Execution files are executed just by typing the
file name at the DOS prompt.
EDITOR COMPILER LINKER
SAMPLE.ASM SAMPLE.OBJ SAMPLE.EXE
Typically programs are written by combining new functions with “pre-packaged”
functions available in the standard libraries. These standard libraries provide a rich
Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect)
December 2000 A fault confessed is half redressed.
collection of functions for performing common mathematical calculations, character
manipulations, input/output, and many other handy operations. These standard libraries
are provided as part of the programming environment. During programming always try
to use the available standard library functions instead if writing new ones (Avoid
reinventing the wheel). This will greatly reduce program development time. The linker
program links all these programming modules into a complete program.
DEBUGGING: -
It is most unusual for a computer program to work correctly for the first time. Any
mistake or malfunction of a computer program or system is called a ”Bug”. Therefore
the technique of detecting, diagnosing, and correcting errors/bugs that may occur in
programs (software) or systems (Hardware) is called “Debugging” or
“Troubleshooting”. The two main types of errors are:
1. Syntax errors
2. Logical errors
Syntax errors occur due to the incorrect use of programming language i.e., the coding of
the program is not impeccable. Logical errors occur due to the incorrect logic in the
solution of the problem i.e., the evaluation of the program is faulty.
Most compilers detect syntax errors and print some indication of the type (cause) of the
errors. Normally programs, which have compilation errors, cannot be run, and these
errors must be corrected before the program can be tested. While compilers cannot
usually detect logical errors, even if the instruction will cause the program to carry out
an illogical operation or perform an erroneous calculation.
Once an error has been detected, either through incorrect results from test data (Sample
data covering all likely and unlikely possibilities, prepared to test a program and the
expected results are compared with actual results) or simulated operating conditions, or
through an unexpected halt, or through compilation errors, the cause of the error must be
diagnosed. Once an error has been found, a correction must be applied to the source
code by editing. As far as Assembly language is concerned some known debugging
tools/techniques are:
DEBUGGER: -
Debugger is a program that allows looking at the contents of registers and memory
locations after program executes. Debugger loads object code into memory, executes it
and debugs it. It is used when learning about data storage and Assembly instructions and
when tracing executable programs. While debugging short programs, use single-step
command. Debugger will execute one instruction and then stop execution. If the
instruction is correct, you can proceed to next instruction. This operation is also termed
as “Step-by-step, Single-shot, or One-shot operation”.
For longer programs the single-step approach is cumbersome. “Breakpoints” are often a
faster technique to narrow down the error down to a small region. By inserting a
breakpoint to an instruction, the debugger will run the program upto the instruction
having breakpoint and stop execution. We can detect, and correct the error and then
proceed further.
In short, debugger quickly finds the source of error in a program. Once you find the
problem, you can correct it. A basic debugger comes with the DOS, but many
sophisticated and expensive debuggers are available: Code View, Periscope, Codesmith-
86, and Atron, to mention just a few.
MONITOR: -
Certain microprocessor boards contain a special debugger program stored permanently
in memory (ROM) called “Monitor”. Such routines (a software procedure that performs
a well-defined function in the operation of a program or a system) are used to provide
diagnostic information on the progress of a program for the purpose of debugging. Such
devices examine the status of the system to indicate any deviation from the prescribed
operational conditions e.g., the SDK-86 monitor lets us enter single-step commands
through programs, insert breakpoints, examine registers, and memory contents.
EMULATOR: -
Emulator is usually used to test and debug the hardware and software of a different and
external computer system, such as a microprocessor-based instrument, and this process
Lecture notes on microprocessor and microcomputer
Lecture notes on microprocessor and microcomputer
Lecture notes on microprocessor and microcomputer
Lecture notes on microprocessor and microcomputer
Lecture notes on microprocessor and microcomputer
Lecture notes on microprocessor and microcomputer
Lecture notes on microprocessor and microcomputer

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to-microprocessors
Introduction to-microprocessorsIntroduction to-microprocessors
Introduction to-microprocessors
mudulin
 
Chapter 4 Microprocessor CPU
Chapter 4 Microprocessor CPUChapter 4 Microprocessor CPU
Chapter 4 Microprocessor CPU
askme
 
Cpu speed, wordlength.8
Cpu speed, wordlength.8Cpu speed, wordlength.8
Cpu speed, wordlength.8
myrajendra
 

Was ist angesagt? (20)

Introduction to microcontroller
Introduction to microcontrollerIntroduction to microcontroller
Introduction to microcontroller
 
Introduction to-microprocessors
Introduction to-microprocessorsIntroduction to-microprocessors
Introduction to-microprocessors
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
Microprocessors
MicroprocessorsMicroprocessors
Microprocessors
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
MD JAHID HASAN
MD JAHID HASANMD JAHID HASAN
MD JAHID HASAN
 
Chapter 4 Microprocessor CPU
Chapter 4 Microprocessor CPUChapter 4 Microprocessor CPU
Chapter 4 Microprocessor CPU
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
Chapter 2: Microprocessors
Chapter 2: MicroprocessorsChapter 2: Microprocessors
Chapter 2: Microprocessors
 
Introduction to Microprocessor & Code
Introduction to Microprocessor & CodeIntroduction to Microprocessor & Code
Introduction to Microprocessor & Code
 
Microprocessors - Introduction
Microprocessors - IntroductionMicroprocessors - Introduction
Microprocessors - Introduction
 
Microprocessor & Micro-controller
Microprocessor & Micro-controllerMicroprocessor & Micro-controller
Microprocessor & Micro-controller
 
Report on evolution of processor by sandesh agrawal
Report on evolution of processor by sandesh agrawalReport on evolution of processor by sandesh agrawal
Report on evolution of processor by sandesh agrawal
 
CPU and memory
CPU and memoryCPU and memory
CPU and memory
 
Processors
ProcessorsProcessors
Processors
 
Microprocessor Systems
Microprocessor Systems Microprocessor Systems
Microprocessor Systems
 
Cpu
CpuCpu
Cpu
 
Introduction to Microprocessors
Introduction to MicroprocessorsIntroduction to Microprocessors
Introduction to Microprocessors
 
Cpu speed, wordlength.8
Cpu speed, wordlength.8Cpu speed, wordlength.8
Cpu speed, wordlength.8
 
Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to Microcontroller
 

Ähnlich wie Lecture notes on microprocessor and microcomputer

Project report on embedded system using 8051 microcontroller
Project  report on embedded system using 8051 microcontrollerProject  report on embedded system using 8051 microcontroller
Project report on embedded system using 8051 microcontroller
Vandna Sambyal
 
I. Introduction to Microprocessor System.ppt
I. Introduction to Microprocessor System.pptI. Introduction to Microprocessor System.ppt
I. Introduction to Microprocessor System.ppt
HAriesOa1
 
Microprocessor & microcontroller
Microprocessor & microcontroller Microprocessor & microcontroller
Microprocessor & microcontroller
Nitesh Kumar
 
microprocessor
microprocessormicroprocessor
microprocessor
illpa
 

Ähnlich wie Lecture notes on microprocessor and microcomputer (20)

Difference Between Microprocessors and Microcontrollers
Difference Between Microprocessors and MicrocontrollersDifference Between Microprocessors and Microcontrollers
Difference Between Microprocessors and Microcontrollers
 
MergeResult_2023_04_02_05_26_56.pptx
MergeResult_2023_04_02_05_26_56.pptxMergeResult_2023_04_02_05_26_56.pptx
MergeResult_2023_04_02_05_26_56.pptx
 
microprocessor-and-microcontroller
microprocessor-and-microcontrollermicroprocessor-and-microcontroller
microprocessor-and-microcontroller
 
4CS3-MPI-Unit-1.pptx
4CS3-MPI-Unit-1.pptx4CS3-MPI-Unit-1.pptx
4CS3-MPI-Unit-1.pptx
 
introduction to microprocessors
introduction to microprocessorsintroduction to microprocessors
introduction to microprocessors
 
Motorola 68hc11
Motorola 68hc11Motorola 68hc11
Motorola 68hc11
 
Project report on embedded system using 8051 microcontroller
Project  report on embedded system using 8051 microcontrollerProject  report on embedded system using 8051 microcontroller
Project report on embedded system using 8051 microcontroller
 
The 8051 microcontroler based embedded systems
The 8051 microcontroler based embedded systemsThe 8051 microcontroler based embedded systems
The 8051 microcontroler based embedded systems
 
I. Introduction to Microprocessor System.ppt
I. Introduction to Microprocessor System.pptI. Introduction to Microprocessor System.ppt
I. Introduction to Microprocessor System.ppt
 
Microcontroller presentation
Microcontroller presentationMicrocontroller presentation
Microcontroller presentation
 
Micro controller
Micro controllerMicro controller
Micro controller
 
microprocessormicrocontrollerbysanat-140107013112-phpapp02.pdf
microprocessormicrocontrollerbysanat-140107013112-phpapp02.pdfmicroprocessormicrocontrollerbysanat-140107013112-phpapp02.pdf
microprocessormicrocontrollerbysanat-140107013112-phpapp02.pdf
 
152-15-5588
152-15-5588152-15-5588
152-15-5588
 
Microprocessor & microcontroller
Microprocessor & microcontroller Microprocessor & microcontroller
Microprocessor & microcontroller
 
Microprocessors evolution introduction to microprocessor
Microprocessors  evolution introduction to microprocessorMicroprocessors  evolution introduction to microprocessor
Microprocessors evolution introduction to microprocessor
 
U proc ovw
U proc ovwU proc ovw
U proc ovw
 
microprocessor
microprocessormicroprocessor
microprocessor
 
Unit-1.pptx
Unit-1.pptxUnit-1.pptx
Unit-1.pptx
 
Project Report on Embedded Systems
Project Report on Embedded Systems Project Report on Embedded Systems
Project Report on Embedded Systems
 
Microprocessor note
Microprocessor noteMicroprocessor note
Microprocessor note
 

Mehr von EkeedaPvtLtd

Mehr von EkeedaPvtLtd (10)

Ekeeda - First Year Enginering - Basic Electrical Engineering
Ekeeda - First Year Enginering - Basic Electrical EngineeringEkeeda - First Year Enginering - Basic Electrical Engineering
Ekeeda - First Year Enginering - Basic Electrical Engineering
 
Ekeeda - Electronics & Telecommunication Syllabus
Ekeeda - Electronics & Telecommunication SyllabusEkeeda - Electronics & Telecommunication Syllabus
Ekeeda - Electronics & Telecommunication Syllabus
 
Ekeeda - Biomedical Engineering Syllabus
Ekeeda - Biomedical Engineering SyllabusEkeeda - Biomedical Engineering Syllabus
Ekeeda - Biomedical Engineering Syllabus
 
Ekeeda - Mechatronics Engineering - Introduction to Mechatronics
Ekeeda - Mechatronics Engineering - Introduction to MechatronicsEkeeda - Mechatronics Engineering - Introduction to Mechatronics
Ekeeda - Mechatronics Engineering - Introduction to Mechatronics
 
Ekeeda - Instrumentation Engineering
Ekeeda - Instrumentation EngineeringEkeeda - Instrumentation Engineering
Ekeeda - Instrumentation Engineering
 
Ekeeda - Applied Electronics and Instrumentation Engineering
Ekeeda - Applied Electronics and Instrumentation EngineeringEkeeda - Applied Electronics and Instrumentation Engineering
Ekeeda - Applied Electronics and Instrumentation Engineering
 
Ekeeda - Mechanical Engineering - Strength of Materials
Ekeeda - Mechanical Engineering - Strength of MaterialsEkeeda - Mechanical Engineering - Strength of Materials
Ekeeda - Mechanical Engineering - Strength of Materials
 
Production Engineering - Laplace Transformation
Production Engineering - Laplace TransformationProduction Engineering - Laplace Transformation
Production Engineering - Laplace Transformation
 
Civil engineering - strength of materials
Civil engineering - strength of materialsCivil engineering - strength of materials
Civil engineering - strength of materials
 
Computer engineering - overview of microprocessors
Computer engineering - overview of microprocessorsComputer engineering - overview of microprocessors
Computer engineering - overview of microprocessors
 

Kürzlich hochgeladen

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Kürzlich hochgeladen (20)

Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 

Lecture notes on microprocessor and microcomputer

  • 1. Lecture Notes on Microprocessor and Microcomputer Compiled by
  • 2. Sep 2019 Ekeeda INPUT MICROPROCESSOR & MICROCOMPUTER: - Microprocessor is an electronic device, which can perform basic arithmetic/logical functions such as and, or, add, subtract upon given input signals. The word 'micro' is used to indicate the physical size of the components involved. Microprocessor is a VLSI (Very Large Scale Integration) device that contains thousands of gates in a single chip. It constitutes the heart of a microcomputer and it fetches microinstructions from memory, decodes the instructions into a series of actions, and carries out these actions in a sequence of steps. All microprocessors contain microprograms, which impart basic logic given by their instruction set for which they are called “Microprogrammed devices”. The microprocessor is usually enclosed in one IC package called a 'Microprocessor chip'. The microprocessor and associated support chips make up the “Central Processor or Central Processing Unit (CPU)” which is also called the ”Micro Processing Unit” (MPU). The CPU is the nerve center of any digital computer, since it coordinates and, controls the activities of all the peripheral units and performs all the calculations. All instructions to be executed must be held within the CPU, and all data to be processed must be first loaded into it. In 1971, Intel corporation released the world’s first microprocessor-the 4004, a 4-bit microprocessor; it can address 4096 4-bit memory locations and its instruction set contained 45 different instructions. Prior to this all processor functions within computers were built of discrete logical devices. Sometimes the terms, microprocessor and microcomputer are used interchangeably, but actually microprocessor is the controlling element to which ROM, RAM and I/O ports are added to make a microcomputer. Microcomputers are defined as the first small desktop computers that were based upon an 8-bit microprocessor with upto 64Kbytes of memory, and input/output (I/O) ports for connecting peripheral units. Microcomputers are also termed as “Personal Computers”. The first microcomputers were intended for single users only, and this clearly distinguished them from “Minicomputers” however the later 16, 32 and 64-bit microcomputers have operating systems and peripheral connectivity to support many simultaneous users, and there is no clear distinction between them and so-called minicomputers. DATA BUS CONTROL BUS ADDRESS BUS Block diagram of a Microcomputer. APPLICATIONS OF MICROPROCESSORS (MICROCOMPUTERS): - While comparing microprocessors it is better to consider the application at hand. Generally, there are three types of microprocessor depending on the usage: 1. General or All-Purpose microprocessor. 2. Embedded or Dedicated microprocessor. 3. Peripheral Control microprocessor. A General-Purpose microprocessor is capable of executing various instructions and can be instructed as to what specific sequence of operations it must perform. It has myriad of applications as personal computer in education, business, and home. On the other hand, Embedded or Dedicated microprocessors are special purpose microprocessors, the sequence of micro-operations is fixed and the computer performs the same specific task over and over again. These used to control 'smart machines' such as microwave ovens, food blenders, washing machines, and driers. These are also termed as 'Microcontrollers'. Basically, a microcontroller is a single chip computer. Contained in one integrated circuit (IC) package are the CPU, ROM, RAM, and several I/O lines. The advantage of using a microcontroller is that many logic devices can be condensed into a single IC. It greatly improves MEMORY (RAM/ ROM) CPUI/O PortOUTPUT
  • 3. Sep 2019 Ekeeda reliability. Also, by changing the control program in ROM, new control functions can be added or modified without any rewiring. One of the fastest growing applications of microcontrollers is in the automotive industry. Peripheral Control microprocessors are attached to main microprocessors. So they are also referred as 'Attach/ Slave microprocessors/Coprocessors'. These are used in many computer systems for video graphics, data communication, sound synthesis, floating-point math, and direct memory accesses (DMA). Their main objective is to offload the main microprocessor, thus saving time and improving speeds. As a result, the main processor is able to concentrate on higher-level tasks resulting in improved system performance. The concept of 'Distributed Computing or Processing' is evolving, and future microcomputers systems will be designed with separate processors for each I/O device in the system. Distributed processing is the organization of processing in such away that a number of machines (microprocessors) can cooperate in exchanging data over a network. Local processing is carried out locally and the exchanged data affects the system as a whole. CLASSIFICATION OF COMPUTER SYSTEMS: - The real power of a computer is the titanic speed with which it performs calculations. A computer sequentially performs one operation at a time. The time required to perform operations is called the 'Processing Speed' of the computer. This rate is expressed in millions of instruction per second (MIPS). Computers are classified according to their processing speed. It depends not only on the hardware characteristics of the system but also on the efficiency of its software components. Some hardware characteristics of importance in achieving high processing speed are as follows: Word Length/Size: is the number of bits treated by the computer as a unit. It can be 4-, 8-, 16-, 32-bits and so on e .g., a 16-bit word will be able to hold numbers in the range from -215 through +215 -1. The number of different types of instructions is directly related to the word length/size. So it can be concluded that larger the word length, the greater the processing speed. Data Path Size: depends on the width of the internal CPU buses. Wider data paths speed up CPU operations, since more information is transmitted in a single transfer. Other important hardware functions are the logic family, overlapping of CPU instructions, memory bandwidth, I/O bandwidth etc. THE Intel 8088/86 MICROPROCESSOR FAMILY: - The width of the data bus in bits is usually used to categorize the microprocessors. On this basis of word length they are categorized into: 1. 8-bit microprocessor. 2. 16-bit microprocessor. 3. 32-bit microprocessor and so on. The width of data bus determines how much data the microprocessor can read or write in one memory or I/O cycle. The term 16-bit means that its ALU, its internal registers, and most of its instructions are designed to work with 16-bits (also called 'word'). Some microprocessors have an internal data bus wider than the external one, e.g. in the Intel 8088 the widths of the external and internal data buses are 8- and 16-bits respectively, for which it is also referred to as “8/16- bit microprocessor”. Another example of 8/16-bit microprocessor is Motorola’s 68008. Anyhow, it is the external data bus that determines the bits transferred during a memory or I/O machine cycle. Consequently, a device like the 8088 is still considered an 8-bit microprocessor. The 8088 is one of the pioneer members of the third generation microprocessors, a direct descendent of the 4004, the world’s first CPU and the heart of the earliest personal computers. VLSI techniques have given it a lot of muscle- the ability to manipulate 16-bit data, directly address a MB of memory, a hefty operating speed and a versatile 16-bit instruction set. FUNDAMENTAL STEPS OF A MICROPROCESSOR CYCLE: - Execution of an instruction starts from the program counter (PC), which contains the address of the instruction and ends with the placement of the result in the appropriate location. The sequence of steps during execution of instructions is: 1. Fetch Instruction: Every instruction cycle begins with an op-code fetch bus cycle i.e., a memory read of the op-code. 2. Determine Operand: The operand is required to execute the instructions. 3. Execute Instruction: Control signal from the control unit activates the operation, so the instructions are executed.
  • 4. Sep 2019 Ekeeda 4. Store the Result: The memory stores the result in the specified location, and the execution/microprocessor cycle ends. After completing one instruction, the CPU moves on to the next one. This fetch and execute process is repeated until all of the instruction s in a specific program have been executed. The CPU’s lifeblood, its heartbeat is the system clock, which synchronizes all activities within the computer. Each step in the microprocessor cycle takes at least one tick of the system clock called a 'Clock Cycle or T Cycle' e.g., one T cycle for 8088 5MHz is 200 nanoseconds. We measure the speed of an instruction by the number of clock cycles required to execute it. A clock cycle is the microprocessor's smallest unit of time measurement. Each instruction takes a determined number of clock cycles to execute, depending on the types of operands. The manufacturer and the computer designer determine the speed of the clock itself. 8088/8086 CPU ARCHITECTURE: - The term architecture in relation to microprocessor refers to the internal design and organization of the device. Every microprocessor does two basic things over and over again- fetching instructions and then executing them. The older microprocessors could only do one thing at a time, if it is busy fetching an instruction it could not execute one. Whenever CPU finished executing one instruction, it had to wait for the next one to be gotten from system memory. This waiting meant a lot of lost and potentially usable microprocessor time. One of the features introduced with the 8088 is the idea of instruction queue. This feature is a regular part of mainframes, but had never appeared in a single chip CPU unit until it was designed into the 8088. The entire process of reading memory, incrementing the IP, and decoding the instruction is known as the 'Fetch and Execute principle' of the stored program computer. A stored program computer that works mainly instructions held in store (ROM/RAM) and these can be altered. One way of increasing the processing speed of a microprocessor is to clock at a higher frequency. Another way is to employ the 'Pipelining Technique'. A computer performs sequentially one operation at a time i.e., CPU performs all the tasks involved in processing an instruction such as fetching, decoding, determining operands, and executing instructions serially on a one-at-a-time basis. It is termed as 'Serial or Sequential Fetch/Execute Cycle'. On the other hand, 8088/8086 incorporates 'Overlap Fetch/Execute Cycle', which is also known as 'Pipelining Technique'. This technique is based on the overlapping of the execution of several instructions simultaneously. Each instruction is executed as a number of cycles that must be performed in sequentially. Thus we enable several instructions to be done by the execution of different cycles on different instructions concurrently. Fig shows that a model of 8088/86 CPU, which consists of two separate processors, called the Bus Interface Unit (BIU) and the Execution Unit (EU). Since these tow units are entirely independent of each other, the 8088 can do two things at the same time. Together they form a two-stage pipeline. Each unit performs certain tasks associated with the instruction processing simultaneously and this allows the 8088/86 to achieve a higher execution rate. 1.Bus Interface Unit (BIU): fetches instructions, calculates addresses, fetches operands and writes results in memory as requested by the EU. However, if no such requests are outstanding and the bus is free, the BIU proceeds to fill any vacancies created in the Instruction Queue (IQ). 2. Execution Unit (EU): receives program instructions and data from the BIU, executes these instructions, and stores the result in the general registers. When the EU completes the execution of an instruction, it passes to the BIU any results (destined for memory or I/O) and proceeds to the next instruction. The BIU, of course, very likely to be already waiting in the IQ. So the EU is completely isolated inside the 8088 and is totally dependent on the BIU for communicating with the real world. This technique makes recent microprocessors different from previous ones as in it the BIU does not have to wait to pass the EU a fetched instruction before reading from memory another one. Instead, it builds a reserve of 4-6 bytes into First-in-First-Out (FIFO) buffer called an 'Instruction Queue or Pre-fetch Queue' (IQ). FIFO is the processing of items in a list such that the earliest arrival is processed first and the latest arrival is processed last. The main advantage of the Pipelining is that the EU can execute instructions almost continually instead of having to wait for the BIU to fetch a new instruction. The IQ has increased the processing speed also called “Throughput” (productivity of any machine, system or procedure measured in some term meaningful to the process under consideration) by storing four pre-
  • 5. Sep 2019 Ekeeda fetched instructions (six in the 8086). This is obvious from the model of 8088/86. Another subtle advantage to the Pipelined Architecture is that as the next several instructions are in the IQ, the BIU can access memory at a 'leisurely' pace. This means that slow-memory parts such as printers can be used without affecting overall system performance. There are three conditions that will cause the EU to enter in a 'wait' mode. 1. Firstly when an instruction requires access to a memory location not in the queue. 2. The second condition occurs when the instruction to be executed is a “Branch/Jump” instruction. In this case control is to be transferred to a new (non-sequential) address. 3. The last condition occurs during execution of instructions that are slow to execute. This can cause the BIU to suspend fetching instructions. CONSTRUCTION OF BIU AND EU: - Firstly, the main parts of the Bus Interface Unit (BIU) are: 1. The instruction Queue 2. The register array 3. An adder 4. A control section Secondly, the main parts of the Execution Unit (EU) are: 1. The register array 2. The main ALU 3. A flag register 4. A control section The register array serves addressing purposes. For BIU it includes four segment registers and instruction pointer, all of which are 16-bits long. This particular adder is used only for address calculations. It does not possess the full arithmetic/logic capabilities of ALU of the EU. Each unit of the 8088 has its own independent control section. The control sections generate the basic timing pulses to control the activities of the circuits operating within the system to ensure that each instruction occupies a predetermined period, referred to as “Instruction Time”. Here the control section of the BIU is responsible for all data transfers over the external CPU bus. The flag register shows the status of the CPU or the results of microoperations. CPU ORGANIZATION: - The basic principles of operation of a microprocessor are similar to those of minicomputer and mainframe central processors. Although many microprocessors are equipped with advanced features, their basic organization still consists of three main sections. 1. Arithmetic Logic Unit (ALU) 2. Control Unit (CU) 3. Registers 1. Arithmetic Logic Unit (ALU): An ALU is a multioperation, combinational logic digital function. To perform a microoperation, the control routes the source information from registers into the inputs of the ALU. The ALU receives the information from the registers and performs a given operation as specified by the control. The result is then transferred to destination register. By definition, the ALU is a combinational circuit; thus the inter-register operation can be performed during one clock cycle. In some microprocessors the result is placed in a specific register called an 'Accumulator or Accumulator register', abbreviated AC or A register. The accumulator register in a processor unit is a multipurpose register capable of performing many microoperations. The operations performed on the data stored in registers are called 'Microoperations'. A microoperation is an elementary operation that can be performed in parallel during one clock pulse period. Examples of microoperations are shift, count, add, clear, and load etc. In fact, the gates associated with an accumulator register provide all the digital functions found in an ALU. 2. Control unit (CU): The CU generates prefetched signal sequences timed by pulses derived from a clock. The type of the signal sequence depends on the op-code (operation code) and inputs fed from source external to the CPU. Such external inputs may be a request to interrupt the program (an interrupt request) or a request to surrender the external bus (bus request). The CU generates two types of signals: A: Internal activation of the ALU and the opening/closing of data paths between registers. B: External control signals for the memory and the I/O. These are sent either for activation of data transfer or as response to interrupt or bus requests.
  • 6. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) ALAH Very often the CUs of microprocessors employ 'Micro-coding'. Micro-codes or microinstructions are instructions at machine code level, which directly control the functioning of hardware independently of operating system or application software. A sequence of microinstructions is called a ' Micro-program', which is stored entirely within the CU of a microprocessor, and usually created by the designer of the microprocessor and not normally alterable by users. The main advantage of micro-program control is that, once the hardware configuration is established there should be no need for further hardware or wiring changes. Hence a micro- program stored in the memory implements the CU in the CPU. 3. Registers: are special store locations generally having a capacity equivalent to the word size of the computer concerned and having specific properties for use during arithmetic and/or logical operations. The registers in a computer may be classified as either operational or storage type. An 'Operational register' is capable of storing binary information in its flip-flops and, in addition, has combinational gates capable of data processing tasks. A 'Storage register' is used solely for temporary storage of binary information. This information cannot be altered when transferred in and out of the register. The bulk of the registers in a digital computer are storage registers, to which information is transferred for storage and form which information is available when needed for processing. Comparatively few operational registers are found in the processors. Registers exchange information through internal buses. Multiple internal buses allow overlapping of certain operations and therefore increase processing speed. The word length of each register is usually equal to the width of internal data buses. The number of registers in a processor may vary from just 1 to 64 registers or more. Some special purpose registers are as: A. Program Counter (PC): is also called “Control Counter” stores the address of the next instruction to be performed. Prior to the execution of a program, the PC is loaded with the starting address of that program. Thereafter it is incremented every time a new instruction is fetched such that, since the instructions of a program occupy adjacent ascending addresses, it always points to the location of the next instruction. B. Instruction Register (IR): holds the address of the current instruction. Program instruction consists of two parts; op-code and address field. The IR extracts only the opcode part from the data buffer. Subsequently the CU decides this opcode and generates the control signals. C. Buffer Register: holds addresses, data and isolate the external data buses of the CPU from its internal buses. D. Status Register: stores the program status word, consisting of status and control bits, which contain information about the condition of a peripheral unit. This information includes, e.g., warning when a peripheral unit needs attention such as there is no paper on a printer and is entered into the status word automatically. E. Stack Pointer: holds the addresses of the instructions. We will discuss all registers in detail below. INTERNAL 8086/88 REGISTERS: - While programming 8086/88 we must have adequate knowledge of the various registers in the EU and BIU. Fig shows these registers into logical groups to form a “Programming Model”. The 8086 microprocessor has several internal registers that can store binary data. Registers are special work areas inside the 8086, designed to be accessed at high speed and all these registers are 16-bits long. Now we will take a closer look at each of these registers in this section. General/Data Registers: - Four registers named “Data or General registers” consist of the AX, BX, CX, and DX registers. All general registers are used for storing intermediate results. These registers can be accessed as a byte (8-bits) or a word (16-bits). The upper halves of each of these registers are called AH, BH, CH, and DH. Similarly the lower halves of these registers are labeled AL, BL, CL, and DL. Bit positions are always numbered from right to left, starting with 0. Bits: 7… …………………… 0 7...................................... 0 Instructions may address either 16-bit or 8-bit registers from the following list. Janu lay the game.ose, it is how you phether you win or lIt is not wary 2001
  • 7. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) January 2001 It is not whether you win or lose, it is how you play the game. AX BX CX DX AH AL BH BL CH CL DH DL Although all the data registers can be used interchangeably for many operations, each of the registers is used for specific purposes. 1. Accumulator (AX): AX register is also called the Accumulator. It possesses some features that the other data registers don't have. Many operations are also slightly more efficient when performed with AX. 2. Base Register (BX): Like other data registers, the BX register can perform logical, arithmetic, data movement, and it has special addressing abilities. Like SI, DI, and BP it can hold memory address that points to another variable. 3. Counter Register (CX): acts as a counter for repeating or looping instructions. These instructions automatically repeat and decrement CX and quit when it equals 0. 4. Data Register (DX): has a special role in multiply and divide operations e.g., when multiplying, DX holds the high 16-bits of the product. Index Registers: - The Index register SI, DI are 16-bit registers (you cannot access the low or high bytes alone) which can be used for temporary storage just like the general registers. However, their main purpose is to hold the 'offset' of variables. The offset refers to the distance of a variable, label, or instruction. These registers are used as 'Memory Pointers'. Each instruction must refer to an index register when addressing locations in storage areas. Both the index registers can be used for general storage but their real strength shows up when they are used during powerful string handling functions. 1. Source Index (SI): is named after the 8088's string movement instructions, where the SI register points to source string. SI usually contains an offset value from the DS register, but it can address any variable. 2. Destination Index (DI): acts as the destination for 8088's string movement instructions. DI usually contains an offset value from the ES register, but it can address any variable. Pointer Registers: - Any location used to hold the address of another locations said to act as a pointer to that location. Pointer Registers are 16-bit registers as follows: 1. Base Pointer (BP): contains the offset from the SS register. It is used to access data in the stack segment. 2. Stack Pointer (SP): The 'Stack' is a set of contiguous memory locations where items are added or removed such that the latest arrival is processed first and the earliest arrival is processed last, for which it is called a Last-In-First-Out (LIFO) stack. A stack is different from any other memory location in that data are put on and taken from the top of the stack and is reserved to store operand and instructions. The SP points to the top of the stack. In other words, it holds the address of the item currently occupying the top. So the SP contains the offset address of the top of the stack. The SS and SP registers combine to form the complete top-of-stack (actual) address. 8088 can handle an unlimited number of stacks. Each one can be upto 64K in size and located anywhere in the 8088’s one mega address space. The only restriction is that their 64K- size limit and they must start at an address boundary that is an even multiple of 16 bytes. 3. Instruction Pointer (IP): essentially plays the role of a PC and its only one function is containing the address of the next instruction to be executed. When an instruction is executed, the IP is automatically incremented the number of times needed to point the next instruction. However, its contents don't specify a physical memory address but an offset. CS and IP combine to form the address of the next instruction to be executed. IP is physically part of the BIU and not under direct control of the programmer as are the other pointer registers. Flag Register: - is a special 16-bit register in which individual bit positions are used as flags (a bit used to mark the occurrence of a specific event) to show the status of the CPU or the results of microoperations. Each relative bit position is labeled; other positions are undefined. A flag or bit is set when it equals 1; it is clear/reset when it equals 0. There are two basic types of flags: 1. Control Flags 2. Status Flags
  • 8. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) January 2001 It is not whether you win or lose, it is how you play the game. Control Flags can be set or reset directly by the programmer and are used to control the operation of the processor. These are Trap (TF), Interrupt-enable (IF), and Direction (DF) flags. While Status flags are the status indicators that reflect the outcome of microoperations performed by the CPU. These are the Overflow (OF), Sign (SF), Zero (ZF), Auxiliary (AF), Parity (PF), and Carry (CF) flags. The instruction set of a computer includes instructions, which test these flags. Bit Positions 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - - - - O D I T S Z - A - P - C N.B: Bits marked” – “are undefined. Although it is a 16-bit register but only 9-bits are used. Others were left for future use. Segment Registers: - The 8086/88 divides its 1MB of memory address space into four segments registers which are used as base locations for program instructions, data, and the stack. In fact, all references to memory on the IBM-PC involve a segment register used as a base location. This means that at any instant four different 64-Kbyte segments are defined. These four segments may partially or completely overlap. The four segment registers are: 1. Code Segment (CS): contains the executable instructions. 2. Stack Segment (SS): contains the base location for the current program stack. 3. Data Segment (DS): is the default base location for memory variables. It contains the data used by the program 4. Extra Segment (ES): is an additional base location for the memory variables and is used for a variety of useful purposes. In general segment registers keep every thing nicely organized. This is a big help in creating software. The advantage of using internal registers for the temporary storage of data is that, since the data is already in the EU, it can be accessed much more quickly than it could be accessed in external memory. COMMUNICATION PATH IN CPU: - A channel along which signals travel from one of several sources to one of several destinations is called a "Bus, Highway or Trunk". So bus is a collection of electronic signal lines all dedicated to a particular task. In 8088/86 there are three buses: 1. Address bus. 2. Data bus. 3. Control bus. 1. Address Bus: is a one-way road over which the microprocessor sends an address to memory or other external device. The size/width of the address bus is specified by the number of bits it can handle. Early microprocessors had 4-bit address lines. This number has increased to 8, 16, 20, 24, and 32 as microprocessor technology has advanced. The number of address lines determines the number of memory location lines that can be addressed. If the CPU has N address lines, then it can directly address 2N memory locations. The lowest address is 0 and the highest 2N -1. For the 8088/8086 address bus is 20 bits wide and it allows the microprocessor to output 220 =1,048,576 unique addresses. Each memory location contains 1byte=8bits of data. Thus 8088/86 can address 1 Mbytes of memory. The wider the address bus, the more memory locations a microprocessor can access. 2. Data Bus: indicated by the double-ended arrows is “a double way road or bi-directional” i.e., the CPU can read in from memory or I/O device or it can write data to memory or I/O device. A bi-directional data bus is used to save pins in the IC package. The width of the data bus in bits is usually used to categorize the microprocessors as it determines how much data the microprocessor can read or write in one memory or I/O cycle. Depending upon the particular microprocessor, the data bus can handle 8, 16, 32 or 64 bits. 3. Control Bus: Each time the CPU outputs an address it also activates one of four control bus signals: MEMORY READ, MEMORY WRITE, I/O READ, I/O WRITE. The control bus also identifies the direction of data flow on the data bus. In short, the control bus coordinates CPU’s operations. When MEMORY READ or I/O READ is active, data is input
  • 9. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) January 2001 It is not whether you win or lose, it is how you play the game. to the CPU. When MEMORY WRITE or I/O WRITE is active, data is output by the CPU i.e., the control bus signals are defined from the CPU's point of view. In a nutshell, the CPU manages the flow of data between itself, memory, and the I/O ports via the address, data, and control buses. The control and address buses are output lines only (uni- directional), but the data bus is bi-directional. This “Three-bus Architecture” is commonly present in all microcomputer systems. SEGMENTED ADDRESSING METHOD: - Now we will see how the 8088/86 microprocessors manage to address up to 1MB of memory. An “Address” is a part of instruction that specifies the location of an operand. Each stored word/byte is allocated a number. By specifying this number of the particular word as a part of instruction access is obtained to the operand stored within the word. When the EU decodes an instruction, it determines the applicable addressing modes. Then it manipulates each operand field. Since internal data bus is 16-bits wide, the EU handles quantities up to 16-bits long. A 16-bit address allows unique identification of 216 =65,536 or 64K-bytes locations so 4-digit hexadecimal number in the range 0000H can represent the 16-bit address to FFFFH. An address within a segment is called a 'Segment/Base address'. So a segment address, located within one of the segment registers (a unique feature of 8088), defines the base address of any 64K-byte memory segment. The offset address selects a location within the 64K-byte memory segment. But since the 8088/86 can address 1MB of memory, the 16-bit must be augmented somehow to make possible unique identification of 1million=106 byte locations. Here the BIU plays its role in address computations. The BIU takes the relative/offset address derived by the EU and adds it to the segment address. Before the addition, the contents of a segment register are shifted four positions in the direction of the Most Significant Bit (MSB) i.e., to left (adding four zeros on the right). Then the adder adds this new number to the second number (offset) to give a 20-bit address, which is termed as the "Absolute/Real/Physical Address". This is the actual address of location expressed in terms of machine code numbering system, and it is obtained by adding the segment/base address to the offset/relative address. Addresses presented over the external buses are always physical addresses. The lowest possible physical address corresponds to an all-zero offset and thus coincides with the segment address itself. Note that due to the 4-bit shift, segment addresses are always multiple of 16. The highest possible physical address corresponds to the maximum possible value of the offset i.e., segment address+64K. By loading different offset addresses in the segment registers, any location in the 1MB address space may be accessed. Such an approach to administering a large address space is known as "Relative Addressing or Segmented Addressing". In this technique instruction are written so that they do not refer directly to absolute addresses in memory; instead a base address is added to the address component (Offset address) of each instruction when the program is loaded in order to create numbers of absolute locations. The advantages of segmented addressing are as follows: 1. The greatest advantage is that reference offset/logical address only can be loaded and run anywhere in memory i.e., it allows programs and data to be relocated in memory without changing. A “relocatable program/data” coded in such a way that it can be stored and executed in any part of the memory. This is because the segment addresses always range from 0000H to FFFFH, independent of the offset addresses. Similarly a program can access large data structures by setting the current segment address to a new block of memory. This enables a programmer to write a program in several independent segments without having to consider the absolute addresses required. 2. Secondly, one program can work on several sets of data. In a time-sharing system, several users share a CPU. Because segmentation keeps data and programs separate from one another, so it is easy to switch from one user's program to another user's program i.e., the program segments can be written independently by different programmers each using relative addresses. 3. This scheme requires only a 16-bit number to represent the contents of a segment register and only a 16-bit offset to access any memory location. This means that the CPU has to handle and store only 16-bit numbers instead of 20-bit numbers. COMPARISON OF iAPX 8088 & iAPX8086: - The Intel 8008 is considered as the first microprocessor, which had an address space of 16Kbytes and only two addressing modes. 8080, 8085, 8088, and 8086 microprocessors followed
  • 10. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) January 2001 It is not whether you win or lose, it is how you play the game. it. In 1978, Intel released the 8086 and a year later, the 8088. Both can address a 1-M bytes (8- bit wide) or a 512-K word (16-bit wide) memory. The 8086 is more powerful than 8088, with exactly the same 16-bit instruction set and memory addressing, but with greater processing speed. However, the differences between 8088 and 8086 are: 1. Firstly in 8088, the BIU data bus path size is 8-bit data bus versus the 16-bit of 8086. So the 8088 requires two memory read cycles to input the same information that the 8086 inputs in one memory read cycle. A 'Memory Cycle' is defined, as the time required accessing the memory read or writing a byte. These additional cycles slow down 8088 (as they consume a huge amount of processing time), making it less efficient than 8086. 2. Because of its wider external data bus 8086 (16-bit microprocessor) has higher processing speed than the corresponding 8088 (8/16-bit microprocessor). Although the cost difference between two devices is not very large. 3. One more difference is that the 8088-instruction queue (IQ) is 4-bytes long while 8086- instruction queue is 6-bytes long. 4. Another difference is that as 8086 was introduced after 8088 so both are not pin compatible. Their pin assignments are not the same. The important point to note, however, is that programs written for the 8086 can be run on the 8088 without any changes. Because the EU is the same for each processor, the instruction sets are exactly the same for each. More advanced microprocessors seem to appear each year, but the manufacturers such as Motorola and Intel have made a conscious effort to make the new chips downwardly compatible. This makes the new CPU’s much more attractive to the system designers. This means that programs written for the older processors (such as 8088/86) will run on the newer ones, such as 80286, 80386, 80486, and so on but not necessarily the other way around. COMPUTER INSTRUCTIONS: - Computer instructions are made up of two parts. The first part is called the “Operation Code or op-code” for short, which specifies the operation to be performed. The second part called the “Operand” is the item in an operation from which the result is obtained by means of defined actions i.e., it indicates the source and/or destination of the data acted on by the op-code. As an example, the instruction INC AX is made up of the op-code INC (increment) and the operand AX (accumulator register). In this case AX is the source and destination of the data. These are the limitations on the types of operands: 1. CS and IP may never be destination operands. 2. Immediate data and segment registers may not be moved to segment registers. 3. The source and destination operands must be the same size. 4. If the source is immediate data, it must not exceed 255 (FFH) for an 8-bit destination or 65,535 (FFFFH) for a 16-bit destination. The list of the all op-codes the computer can execute is called “Instruction Set or Order Code”. Generally it is the set of symbols and characters forming the rules of a particular computer code or programming language. The instruction set of a particular microprocessor specifies the register-transfer operations and control decisions that are available in the microcomputer system. When an instruction is stored in memory it is the binary code representing (that instruction) that is actually stored. For the instruction INC AX the single byte (8-bits) 01000000 (40H or 64D) is stored. Anyhow, most 8086 instructions require more than one byte. Some instructions will require as many as seven bytes. The best way to appreciate the instruction set is to write programs that perform meaningful data processing tasks. The power of an instruction set is usually judged from the number of instructions needed to perform a specific complex task. Fewer instructions mean generally less memory space for the program and shorter task execution times. Hence, the instruction set is considered more powerful. Instruction sets may not only differ on the type of operations, but also the data types on which instruction are performed. Generally, the instruction sets are different for different microprocessors, but there are certain basic instructions that are included in all microprocessors. SOFTWARE: THE Intel 8086/88 INSTRUCTIONS SET: - Writing software means telling the CPU what operations to perform as well as specifying the order of execution. Even though external data bus of 8088 is only 8-bits wide but it is only for wiring support chips and laying out the PC board. But the instruction set of the 8088 has all the features of the older 8-bit CPU’s as well as whole collection of powerful new 16-bits instructions.
  • 11. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) January 2001 It is not whether you win or lose, it is how you play the game. The 8088 can understand over 95 separate instructions and have 24 ways to generate an address. Generally microprocessor instructions may be classified into three distinct types. 1. Data Transfer Instructions are concerned with operations which entail the movement of data between registers in the processor and between registers and memory locations (words) without changing the binary information content. 2. Data Manipulation Instructions perform arithmetic, logical, and shift operations on data stored in registers or memory locations. They also set, clear, or complement status or flag bits. 3. Control Instructions provide means for controlling the program and the state of the CPU. These instructions provide decision-making capabilities and change the path taken by the program while execution. Last two types may be classified further into categories as follows: 1. Data Manipulation Instructions. A: Arithmetic Instructions. B: Logical Instructions. C: Shift/Rotate Instructions. D: Bit manipulation Instructions. E: String processing Instructions. 2. Control Instructions. A: Program control Instructions. B: Processor/Machine control Instructions. 1. Data Transfer Instructions:- Microprocessors spend most of their time accessing memory locations and moving data from place to place. So these instructions transfer one byte/word of data from one location to another. e.g., MOV LOC1, LOC2 move data form LOC2 to LOC1 Data transfer instructions include XCHG, XLAT, PUSH, POP, IN, OUT, LDS, LES, LEA, PUSHF, POPF, LAHF, SAHF etc. 2. Data Manipulation Instructions:- A: Arithmetic Instructions: give the 8088 its computational capabilities. The 8088 can directly do ASCII arithmetic. Decimal data can be coded into hex in two ways-either as packed (standard BCD) or unpacked (ASCII) numbers. Secondly 8088 can do multiplication and division of 8- or 16-bit numbers with a single instruction. And can handle signed or unsigned numbers. Unsigned numbers are scalar quantities. An 8-bit unsigned number can be as large as 255 and a 16-bit unsigned number can go upto 65,535. These numbers only represent magnitudes; they are not positive or negative. While signed numbers (also called integers) are vector quantities. Because in these MSB is used to indicate the sign (direction). If the sign bit is clear (0) the number is positive and if it is set (1) the number is negative. So for 8-bit numbers range is –128 to +127 and for 16-bit numbers range is –32,768 to +32767.Examples are ADD LOC2, LOC1 add contents of LOC1 and LOC2 INC LOC increment the contents of location LOC by 1 Other arithmetic instructions are ADC, AAA, DAA, SUB, SBB, DEC, NEG, CMP, AAS, DAS, MUL, IMUL, AAM, DIV, IDIV, AAD, CBW, CWD etc. B: Logical Instructions: are used for doing logical operations e.g., AND LOC2, LOC1 AND each bit in both bytes/words NOT LOC Invert each bit of a byte/word There are five logic instructions available with the 8086/88 microprocessor; NOT, AND, OR, XOR, TEST. TEST is the most useful instruction. Each function is performed bit by bit between the source and destination operands. These instructions are all performed in the ALU and affect all the flags. C: Shift and Rotate Instructions: shifts or rotate the bits of an operand in either direction. The rotated quantity can be an 8/16-bit CPU register or memory location. The main difference between a shift and rotate is that the shifted bits 'fall off' the end of the register, whereas the rotated bits 'wrap around' i.e., in rotate instructions, bits shifted are not lost, instead, they reenter from the other side. Within the shift group of instructions there are both arithmetic (SAL and SAR) and logical (SHL and SHR) shift instructions. In shift right operations, there are two types: 1. Logical, where 0s enter from the left. 2. Arithmetic, where the sign bit preserves it by reentering. In all these instructions the carry flag is involved. These are also used in doing multiplication and division. Fig shows ROL, ROR, RCL, RCR are the rotate instructions.
  • 12. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) January 2001 It is not whether you win or lose, it is how you play the game. D: Bit Manipulation Instructions: are used for testing, setting, or clearing a bit within a byte/ word). Such instructions specify both the addresses of the location and the desired bit position. Logical, shift and rotate instructions are sometimes referred to as “Bit manipulation instructions”. E: String Processing Instructions: 8086/88 has several instructions for moving large blocks of data or strings (a set of consecutive characters or digits). These instructions have a special addressing mode of their own, for all these instructions the source is DS: SI and the destination is ES: DI. Nothing like these instructions had ever been available before e.g., MOVS LOC2, LOC1 move string form LOC1 to LOC2. MOVSB/MOVSW move byte or word from one string to another. CMPS, LODS, STOS, SCAS, REP, REPE, PEPZ, REPNE, REPNZ are important string instructions. 3. Control Instructions: - The stored program computer repeatedly follows the sequence: fetches the instruction whose address is in IP, increments IP, and executes the instruction i.e., all programs are executed sequentially. However, sometimes it is necessary to transfer control to an address that is not the next instruction in sequence. Examples are instructions that must be executed repeatedly, groups of instructions that are shared through out a program, conditional transfer based on the state of the flags, and software interrupts. Control instructions may be conditional or unconditional. A 'Conditional Control Instruction' causes a jump/branch out if normal program sequence only when a specified condition is detected. Whereas, an 'Unconditional control Instruction' causes a branch unconditionally. In short, these instructions allow program control to be transferred to a new non-sequential address. A: Program Control Instructions: The branch out of normal program sequence is accomplished by changing the program counter (PC) since it contains the address of the next instruction to be executed. Therefore, program control instructions change the contents of the PC which in turn transfers control to another part of a program e.g., JMP LOC Go to specified address The 8088 has a wide range of JUMP commands based on various conditional tests e.g., Jcond LOC Jump if condition is satisfied One common programming problem is to setup a group of instructions that must be executed several times. One of the CPU registers is loaded with the loop count and this register is decremented by 1 at the end of each loop. A JNZ (jump if not zero) instruction transfers control back to the start of the loop if the counter register is not zero. The 8088 instructions are designed exactly for this application e.g., LOOP LOC Loop until CX=0 JCXZ LOC Jump to LOC if CX=0 Important instructions are CALL, RET, LOOP, LOOPE/LOOPZ, LOOPNE/LOOPNZ etc. All loop instructions repeat until CX = 0. This means that the loop will be repeated 65,536 times if CX= 0 initially. B: Processor/Machine Control Instructions: affect the operation of the processor itself and include instructions concerned with setting and clearing flags that are used during normal program operations. e.g., STC set the carry flag. WAIT wait until TEST pin active. NOP do absolutely nothing (no operation). Other significant instructions are CMC, CLI, STI, CLD, STD, CLC, INT, INTR, INTO, ESC, LOCK, HLT etc. The instructions HLT, WAIT, LOCK, ESC are specifically designed to use with external devices like coprocessors. ADDRESSING MODES: - Computer instructions are made up of an op-code and zero, one, or two operands. Sometimes instructions with no operands are called 'zero-address instructions'. Those with one operand are called 'one-address instructions', and so on. Usually, microprocessors specify one or two operands. The valid operands depend on the internal organization of the microprocessor and the different ways in which the microprocessor generates these operand addresses are called the 'Addressing Modes' which may be one of three basic types: register, immediate, or memory. The 8086 has nine different addressing modes.
  • 13. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) January 2001 It is not whether you win or lose, it is how you play the game. Intel addressing modes, in fact, are some of the most complex available in any assembly language. However, these modes give the experienced programmer flexibility for writing programs that are more efficient with respect to the number of instructions and execution time. The data addressing modes are: N.B : Because MOV instruction is common and flexible, it provides a basis for explanation of the data addressing modes. Immediate Addressing Mode: Instructions that use this mode get their data as part of the instruction and it is commonly used to load a register or memory location with some initial data. In this mode the operand is specified in the instruction itself as the term 'immediate' implies that the data immediately follow the hexadecimal op-code in the memory. An immediate operand is a constant expression, such as a number, a character, or an arithmetic expression. It transfers the source-immediate byte/word into the destination register or memory location e.g., MOV AX, 1000H Register Addressing Mode: In this mode the operands are the CPU registers which reside within the CPU. In general, this mode is the most efficient because register are part of the CPU and no memory access is required. The microprocessor contains the following 16-bit registers; AX, BX, CX, DX, SP, BP, SP, and DI and 8-bit registers AH, AL, BH, BL, CH, CL, DH, and DL. Any registers may be used as source operand, and any registers except CS and IP may be used destination operands. For example, MOV AX, BX Another point must be again remembered that registers being used must be of the same size. Because mixing is not allowed by the microprocessor and results in an error when assembled. These instructions are wrong: MOV BL, DX Not allowed (mixed sizes) MOV ES, DS Not allowed (segment to segment) MOV CS, AX Not allowed (CS cannot be the destination register) Direct Addressing Mode: In this mode the memory address is supplied directly as part of the instruction. A direct operand refers to the contents of memory at an address implied by the name of a variable. In 8-bit microprocessors as 8088 with 16-bit addresses, a direct instruction consists of 3 bytes. e.g., MOV AH, MEMBDS copies the 8-bits of data segment location MEMBDS into AH MOV AX, NUMBER copies the 16-bits of data segment location NUMBER into AX Register Indirect Addressing Mode: allows data to be addressed at any memory location through an offset address held in any of the following registers: BP, BX, SI, DI. In this mode memory address (EA) is supplied in a pointer or index register e.g., MOV AX,[SI] MOV AX,[BX] Indirect Memory Access Addressing Modes: - The direct addressing mode is useful for infrequent memory accesses. Anyhow, when a memory location must be read/written to several times, the repeated fetching of the two- byte logical addresses makes this mode inefficient. The Relative/Indirect Memory Access Addressing Modes solve this problem by storing the memory addresses in a pointer or index registers. A relative-mode instruction is a 2-byte instruction, with the second byte specifying a signed number in the range between –128 and +127. It is accomplished by representing the number in sign-2's complement form. This 2's complement displacement can be added to the pointer or index registers to offset the location pointed at. Hence indirect addressing is a technique in which the address part of an instruction refers to another location which contains another address. This further address may specify an operand or yet another address. This technique is also called “Multi-level Addressing” Indexed Addressing Mode: In it memory address (EA) is the sum of the index register plus a displacement within instruction e.g., MOV AX,[SI+6] In general, a displacement can be added to a base register and the result added to an index register. The resulting address is often referred to as the 'Direct/Effective Address' (EA). This address is computed by the information provided in the instruction i.e., the computation has to take place before the instruction can be executed. It is the address of the operand or the address where control branches in response to a control instruction. In a direct-mode instruction the
  • 14. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) January 2001 It is not whether you win or lose, it is how you play the game. effective address is equal to the address part of the instruction. The displacement is limited to a single byte, allowing the EA to be varied +127 bytes (7FH) to –128 (80H) from the base pointer. Based Addressing Mode: In it memory address (EA) is the sum of the BX or BP registers plus a displacement within instruction e.g., MOV AX, [BP+6] Based and Indexed Mode: In it memory address (EA) is the sum of the index register and a base register e.g., MOV DX, [BX+SI] Based and Indexed with displacement Mode: In it memory address (EA) is the sum of an index register, a base register, and displacement within instruction e.g., MOV AX, [BX+SI+6] String Addressing Mode: Because of their importance, 8086/88 has several instructions designed specifically for handling strings of characters. These instructions have a special addressing mode of their own, for all these instructions the memory source is DS: SI and the memory destination is ES: DI. For example MOVSB/MOVSW move byte or word from one string to another. Remember that two base registers or index registers cannot be combined. Finally, note that the default memory segments for all the indirect addressing modes are the stack segment when BP is involved, and the data segment when register BX, SI, or DI is involved. The most powerful feature of the indirect addressing modes is that the memory address can be changed based on program conditions. 8088 CPU PIN DESCRIPTION: - The 8088 microprocessor is a VLSI (Very Large Scale Integration) device that contains thousands of gates in a single chip. It is housed in a 600-mil wide, 40-pin dual-in-line package (abbreviated DIP, an IC packaged so that external connections can be made through two parallel rows at right angles to the edges of the package). Many of these pins are time multiplexed, providing two separate processor functions. Some pins are devoted to support coprocessors. It was difficult to provide access to all the functions of the microprocessor with in a single chip. Actually the 8088 microprocessor has a 20-bit address bus, an 8-bit data bus, three power pins, and seventeen pins devoted to miscellaneous control and timing functions. The Intel (the leading microprocessor manufacturer) employed a design technique called “Time Division/Sharing Multiplexing”, a system whereby a number of terminal devices are connected to the same communication channel and each occupying the channel for the data transmission for short periods at regular intervals. Each unit transmits data by the use of timesharing techniques such that all units appear to transmit simultaneously over one channel. In this way one circuit pin has more than one function e.g., the 8088’s pins, labeled A16/S3 to A19/S6 are the address lines during the state T1 clock state, and become status indicators during the T2-T4 states. A special de-multiplexing circuit (circuit used to separate the signals that were combined for transmission by a compatible multi-plexer) is required to separate these lines. Another attractive feature of the 8088 is its ability to operate in two modes, named the “Minimum Mode” and the “Maximum Mode. The minimum mode is designed for simple single processor systems on one printed circuit board (PCB). Whereas the maximum mode is designed for more complex systems with separate I/O (short for input/output) and memory boards. This mode also supports coprocessors such as the 8087 NDP (Numeric Data Processor) and 8089 IOP (Input Output Processor). ADDRESS BUS (AD0-AD7, A8-A15, A16/S3-A19/S6:-) These 20 pins correspond to the microprocessor’s 20-bit address bus and allow accessing 220 =1,048,576 unique memory locations. Because the 8088 have an 8-bit external data bus, there is no need to multiplex the A8-A15 address lines. Thus these pins carry information throughout the bus cycle and need not be latched. The address pins on the 8088 are functionally divided into three groups; AD0-AD7, A8-A15, A16-A19. The reason for this breaking is that not all of them carry the address all the time. The first group, AD0-AD7, is the most versatile. During the first part of an instruction cycle, the 8088 puts the lower 8-bits on these pins. During the second part of the instruction cycle, CPU removes the address from these lines and floats them (tri-stated) to get them ready for their next job. When the 8088 reaches the third part of its instruction cycle, it uses these pins as the data lines. During this stage of the instruction cycle these pins become bi-directional. The second group of the address pins, A8-A15, area set of plain vanilla address pins and the potion of the address they carry stays valid for the entire instruction cycle. The final address pins, A16-A19 make the 8088 a 16-bit CPU since they are the addresses from
  • 15. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) January 2001 It is not whether you win or lose, it is how you play the game. 10000H (65,536D), to FFFFFH (1,048,575D). These lines carry valid address data at the same time as the first group of address lines. Then carry status signals which indicate the address segment currently in use (S3 & S4), the state of the interrupt enable flag (S5), and a flag to indicate that the 8088 has control of the bus, (S6). DATA BUS (AD0-AD7): - These eight pins form the microprocessor’s bi-directional data buses. So these pins and A16/S3- A19/S6 only need to be multiplexed. Data is transferred only on the AD0-AD7 address/data lines. ADDRESS LATCH ENABLE (ALE): - This output signal separates the low order address and data. Since these signals are multiplexed on the same pins, an external signal is required to determine what kind of information is currently on the pins. When ALE becomes active (goes HIGH), the 8088 is telling you that the entire 20-bit address is on the bus. So this output is used to de-multiplex the address, data, and status lines on AD0-AD7 and A16/S-A19/S6. INPUT/OUTPUT MEMORY (IO/M): - The 8086 microprocessor’s M/IO becomes IO/M on the 8088. The 8088/86 does not output separate memory and I/O read and write signals. Instead, this pin indicates that the address bus contains either a memory or an I/O port address. This line goes to HIGH to indicate that the CPU is talking to an I/O port and LOW when the CPU wants to deal with system memory. READ (RD): - Read is to obtain data from one form of store (e.g., magnetic disk) and transfer it to another (e.g., memory of the microprocessor). It is an active low output that indicates the 8088 wants to read data either from memory or an I/O port. It can be combined with IO/M to form MEMR and IOR control signals. RD will remain high until the address is removed from the bus. AD0-AD7 first carry the address, then float, and then function as the data bus. So the RD does not become active until the bus floats. Consequently, when the RD is active, data appears on the bus. WRITE (WR): - Write is to transcribe (retype) data on to a form of store from another form of store (e.g., transcribing data on to a magnetic disk from the microprocessor’s main memory). This signal is the counterpart of RD and indicates that data is to flow from the microprocessor to memory or to an I/O device. CLOCK (CLK): - The CPU’s heartbeat is the system clock and it is fed to the CLK input. Clock provides accurately timed pulses at fixed intervals to monitor, measure, or synchronize other units operating within the system. It supervises operations to detect looping and similar error conditions, and also provides time in hours and minutes for maintaining an operation log (a record of series of events). Without the clock signal, there would be chaos. Secondly internal registers are made from dynamic memory cells (regenerative storage units in which signals representing data has to be constantly regenerated so that information can be retained as long as required) that require periodic refreshing or they will lose data. The clock signal provides this refresh. Thus the clock must never be stopped. This means the minimum clock speed for any 8088 is 2 MHz but the maximum rate depends on the version of the 8088 being used. The signal clock must be asymmetrical (33% duty cycle), with steep rise and fall times. Intel makes the 8284; a clock generator circuit that generates clock pulses perfectly tailored to the 8088. It also provides fully synchronized startup and manual reset as well. STATUS (A16/S3-A19/S6): - These five status signals designed primarily for diagnostic testing purposes, as their definitions in the table given below indicate. It is possible to decode S3 and S4 to provide four separate 1MB-address spaces for the extra, data, code, and stack memory segments. S3-S6 Bit Definitions S4 S3 Bus Cycle Access To 0 0 Extra Segment 0 1 Stack Segment 1 0 Code Segment or None 1 1 Data Segment
  • 16. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) January 2001 It is not whether you win or lose, it is how you play the game. DATA TRANSMIT/RECEIVE (DT/R): - This line is a companion to the DEN line. This signal is intended to control the direction of data flow through the buffers (synonymous with buffer stores are temporary store areas used to compensate for the different speeds at which the various units can handle data) connected to the system data bus. When DEN lets the buffers know that the 8088 is not using the data bus, DT/R tells them whether the CPU is expecting them to send (DT/R LOW) or receive (DT/R HIGH) data. Both of these outputs were designed to use with Intel’s 8286 or 8287 data transceivers (terminal units which can both transmit and receive data). DATA ENABLE (DEN): - This output is an active (LOW) signal that is most used to control the enabling of external data buffers. When the line is active, the 8088 is telling all the system that the data bus is available for use. By letting DEN control access to the data bus, we are guaranteed not to have any timing hassles, not any caused by “Bus Contention” i.e., two circuits attempting to drive the same bus line by disabling the data bus buffers until when the address/data lines no longer hold the memory or I/O address. MINIMUM/MAXINMUM MODE (MN/MX): - This pin is used to set the 8088 in either the MINIMUM or MAXIMUM mode. In general when designing a system with several microprocessors accessing the address and data buses the 8088 must be configured in the MAXIMUM mode, (MN/MX tied LOW). The 8288 “BUS Controller” does this all. The redefined pins drive the 8288, which decodes them into an expanded set of control signals. Consequently, we get 20 control lines in the MAXIMUM mode as opposed to 13 in MINIMUM mode. Single board systems can get along well with the control signals provided by running the 8088 in the MINIMUM mode (MN/MX=1). The control lines that are altered by the MN/MX setting show up on pin# 24 through pin#32 and pin#34. RESET: - Reset is defined as a hardware or software function, which causes a computer system to enter a predefined initial status in which all variable hardware or software states restored to a set of initial values. The RESET pin is an active HIGH signal that stops the 80888 dead in tracks. There is a bit of failsafe on this line since the RESET signal has to stay HIGH for at least 4 clock cycles before it will be taken seriously by the CPU. Once this time requirement is fulfilled, the 8088 will float the address and data lines and do absolutely nothing else until the line is brought LOW again. When the RESET line is released, the CPU will jump to the instruction you have stored at the power-up location of FFFF0H. When this pin is driven HIGH, most of the 8086/88 CPU registers are reset, as shown in the table given below: However, because CS register contains FFFFH (segment address), the CPU will fetch its first instruction from the physical address calculated as: CS: IP=FFFF0H + 0000H = FFFF0H. CPU STATE FOLLOWING RESET CPU CONTENT FLAGS Clear IP 0000H CS FFFFH DS 0000H SS 0000H ES 0000H IQ Empty Hence whenever the 8086/88 is reset, it begins executing instructions at memory locations FFFF0H and disables interrupts by clearing the IF flag/bit. RESET is normally used when first starting a computer or after a system crash (failure). It is also very handy when you are trying out new code, since software in the development stage produces crashes more often than results. TEST: - The TEST input is a way of stopping the 8088 until it is started up again by some external event. This input is used together with the WAIT instruction. If the TEST input is HIGH when the WAIT
  • 17. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) January 2001 It is not whether you win or lose, it is how you play the game. instruction is encountered, this WAIT instruction functions as NOP instruction; execution of the program is suspended and the computer enters an “Idle Mode”, the mode during which the system remains inactive even though switched on and otherwise in an operable condition. Only when the TEST returns LOW will execution resume (with the instruction following WAIT instruction). Normally, this input is driven by 8087 coprocessor. This prevents the CPU from accessing a memory result before the coprocessor has finished its calculations. READY: - The READY input signal is used by either memory or I/O to let the 8088 know when the requested data operation is finished. When the data transfer is completed, the external device can let the 8088 know it is done by putting a high on the READY line. The most common use for the READY line is to slow the 8088 down when it is dealing with slow-memory external devices that can not handle data at CPU speed. It is employed to insert wait states into the machine cycle. If it is found LOW (not ready), the microprocessor enters a wait state and remains idle. INTERRUPTS (INTR, NMI, INTA): - The INTR pin, the Interrupt Request input gives you way to the 8088’s powerful external interrupt servicing routines. The 8088 can handle 256 vectored, prioritized levels of interrupt and it looks at INTR at the end of each instruction cycle. If the CPU sees that the line has been made active (HIGH) by an external device it will jump/vector to the subroutine whose address has been stored in memory in a lookup table. INTR and NMI are hard-wired interrupt requests, which function exactly as software interrupts. The INTR input can be masked (Masking is the technique of devising a bit pattern called a Mask to alter or isolate specific bit positions present in another bit pattern) by resetting the IF control flag (CLI) i.e., clearing this bit blocks all interrupts on INTR effectively masking this input. The INTA (Interrupt Acknowledge) line is an output that becomes active (LOW) when an external device makes an interrupt request by putting a HIGH on the INTR pin. Whenever the 8088 receives this request, it waits until the current instruction cycle is ended and then puts a LOW pulse on the INTA line for two consecutive cycles referred to as “interrupt acknowledge cycles”. NMI is the “Non-Maskable Interrupt” also known as the “disaster Line” that will always be serviced. It is called this because, since there is no way for it to be disabled by software, most systems reserve it to indicate that some sort of catastrophic events such as power failure or memory errors, is going to happen. To make the input more responsive, the NMI input is edge, rather than level-triggered. This means that the 8088 will react during the low to high transition of the NMI line instead of waiting for it to reach a high. Once the line has been activated, the 8088 will finish executing the current instruction and then jump to the NMI handling routine whose address has been stored in the appropriate place in the lookup table. HOLD, HOLD ACKNOWLEDGE (HOLD, HLDA): - HOLD is useful for multiprocessor systems since it is a perfect signal for avoiding bus contention. The most common use for HOLD is doing DMA, (Direct Memory Access). DMA is a powerful way to get things done without having to involve the 8088. One of the best examples of DMA is dynamic refresh. If we let the 8088 handle it, the processor’s built-in overhead (due to instruction fetch and execute times) will really stretch out the operation. HOLD is an active high input that causes the microprocessor to open circuit all of its bus lines. This effectively disconnects the CPU from its memory and I/O, allowing a second processor to access these units. HLDA is the output used by the 8088 to let external devices that it has removed itself from the bus and has floated all the lines. If a device like Intel’s 8237 DMA Controller is used, then HLDA acknowledges the DMA request to the DMA Controller. POWER & GROUND (VCC & GND): - A 5MHz 8088 microprocessor requires +5.0-V +/-10% and draws 340-mA maximum and its power dissipation are a 1.7-W. The 8088/86 require a single +5.0-V power supply and have two ground pins (#1 & #20). The GND connection is the return for the power supply (VCC ). Both GND pins must be connected to ground for proper operation. Remember both GND pins are not electrically connected in the IC. Making the assumption that they are tied together and letting one float will guarantee flakey (erroneous) operation at best and foul smelling smoke at worst. STATUS SIGNAL OUTPUT (SSO): - This is the only new signal on the 8088, which takes place of BHE/S7 on the 8086. This signal will give an up to minute report of what the 8088 is currently doing on the bus. This signal can
  • 18. Chap#02 Microprocessor Architecture Compiled by Sajid Iqbal (B.Sc. Elect) January 2001 It is not whether you win or lose, it is how you play the game. be combined with DT/R and IO/M to encode the current bus cycle. As fig below shows this information can be used for diagnostic testing purposes. 8088 STATUS DECODING IO/M DT/R SSO FUNCTION 0 0 0 Interrupt acknowledge 0 0 1 Memory Read 0 1 0 Memory Write 0 1 1 Halt b1 0 0 Codes access (op-code fetch) 1 0 1 I/O Read 1 1 0 I/O Write 1 1 1 Passive (No Activity)
  • 19. Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect) December 2000 A fault confessed is half redressed. PROGRAM: - All computers must be programmed to perform even the most elementary tasks. A set of instructions (statements) given to the computer to perform a certain job is called a “Computer Program”. These computer programs guide the computer, through orderly set of actions specified by the people called “Computer Programmers”. Since a computer cannot reason, but is entirely dependent on instructions supplied to it by its all too users. So it cannot perform any task adequately unless the problem it is required to solve has been specified correctly in every detail and the instructions it is asked to obey define in complete detail each step of the solution. PROGRAM STATEMENT: - Program statement is a single complete meaningful instruction containing some constants, operators, variables, and keywords (informative words which have special meanings to a compiler and cannot be used as data names). PROGRAMMING LANGUAGES: - In order to communicate with each other, men use language; in the same way, languages are used to communicate instructions and commands to a computer i.e., languages are the medium by which man communicates problems to the computer. So language is a set of words, symbols, characters etc., for communication. Languages used for writing computer programs are called ”Programming Languages”. The choice of programming languages will depend upon the complexity of the problem, and the capacity and resources of the computer to be used. There are three levels of programming languages: 1. Low-level Languages (Machine Languages). 2. Symbolic Languages (Assembly Languages). 3. High-level Languages. 1. LOW-LEVEL LANGUAGES (MACHINE LANGUAGES): - Low-level languages (Machine languages) are the only languages that a computer can understand. These instructions are written in the form of binary strings of 1’s and 0’s which can be immediately obeyed by a computer without translation. In a strict sense, in a low-level language each instruction has a single corresponding machine code equivalent. The programs written in these languages are fast in execution. On the other hand it is difficult to learn machine languages because it requires detailed knowledge of hardware (all the electronic and mechanical units which together form a computer system). Machine language programming is very tedious because you must determine the hex code for each instruction used. With over 100 mnemonics and 3800 different forms of the 8086 instructions, this process is time consuming and error prone. There is no single machine language because each computer can understand only its own machine language. So machine languages are machine (computer) dependent i.e., a particular machine language can be used only on one type of computer. 2. SYMBOLIC LANGUAGES (ASSEMBLY LANGUAGES): - Assembly language is a set of instructions for a particular microprocessor. It was developed in 1950s. It provides a direct correspondence between symbolic operation codes and machine language, for which it is termed “Symbolic language”. Like machine languages each microprocessor or microprocessor family has a different Assembly language, because the design of the microprocessor influences the instructions it can execute. Assembly language uses two-, three-, or four letters “mnemonics” to represent each instruction type. A mnemonic is a short alphabetic code that helps us to remember a CPU instruction. The letters in mnemonics are usually initials or shortened forms of the English words for the operation performed by the instruction, e.g., the mnemonics for subtract is SUB, the mnemonic for multiply is MUL etc. Assembly language statements are usually written in standard form consisting of four fields as shown below:
  • 20. Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect) December 2000 A fault confessed is half redressed. LABEL FIELD OP-CODE FIELD OPERAND FIELD COMMENT FIELD NEXT: ADD AL, 07H ; add 07H to register AL Label field is the first in each Assembly language statement (i.e., the left-hand column of the statement) and it is not essential to have an entry in this field for each instruction. Labels are followed by a colon (:). An entry here is treated as a name, which can used to identify the specific line of the program and hence its memory address. Usually labels are used as addresses within program control instructions (JUMP, BRANCH etc.) to cause control to pass to an instruction bearing a specific label. Op-code field contains the mnemonics for the instructions to be performed. Op-code is an acronym for “Operation Code”. The Operand field contains data, memory address (A binary numeric code given to a memory location in order that location can be selected for reading or writing under program control), port address, or the registers (special storage locations of the microprocessor concerned) on which operations are to be performed. An instruction may contain zero, one, or two operands. The choice of the operand is usually determined by the “Addressing Mode”. The addressing mode tells the Assembler where to find the data in each operand e.g., PUSH AX ; one register MOV AX, BX ; two registers ADD BX, 1000H ; register, immediate value The final field the Comment field starts with a semicolon (;). Comments, annotation or narrative are written notes which are included in the coding of a program in order to clarify operations but have no effect on the program itself, i.e., are not translated into machine language. 3. HIGH-LEVEL LANGUAGES: - In contrast to a low-level language in a high-level language each instruction has several corresponding machine code instructions. These languages are very close to human languages, i.e.; these languages provide us more familiar notation rather than machine codes of the computer e.g., mathematical notation in FORTRAN and English in COBOL etc. Each language has its own rules (which govern the structure of the language statements) for writing source programs/codes. These rules are called “Syntax” of the language. Features which high-level languages have in common are the fact that they are “problem-oriented” rather than “machine-oriented” and also myriad of compilers are available for converting the high-level language programs into the machine codes of different types of computers. Programs can be written faster in high-level languages than their counterparts (either low-level languages or Assembly languages), because they work with larger building blocks. Whereas these program always almost execute more slowly and require more memory than programs written in their counterparts. Unlike Assembly and machine languages high-level languages are designed to keep them as much computer independent as possible. A high-level language program is generally “portable”, i.e.; it may be executed on any computer with some minor amendment to cater for any differences of configuration or idiosyncrasies of translators. Obviously high-level languages are more desirable from programmer’s standpoint than either machine languages or Assembly languages. The important high-level languages are: FORTRAN: is an acronym for FORmula TRANslation. It is a high-level language for scientific and mathematical use; introduced in 1957. COBOL: is an acronym for COmmon Business Oriented Language was developed in 1959. It is primarily used for commercial applications that require precise and efficient manipulations of large amount of data. Today more than half of all business software (in contrast to hardware, software are programs which can be used on a particular computer) is still programmed in COBOL. BASIC: is an abbreviation for Beginners All-purpose Symbolic Instruction Code. It was introduced in 1965 and originally designed for developing programs in
  • 21. Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect) December 2000 A fault confessed is half redressed. “Conversational/Interactive Mode” (An operational method in which the user is in direct communication with the computer and obtains immediate response to his input messages), in an on-line programming environment. Because of its simplicity and comparative power it is much used on personal computers. PASCAL: was named after Blaise Pascal (seventeenth century mathematician); introduced in 1971 as derivative of ALGOL. C: was introduced after the language B in 1972. It was developed for system programming. C++: an extension of C was developed in the early 1980s. It provided the capabilities for “object-oriented programming”. Today most operating systems (are programs which supervises the running of other programs) are written in C and /or C++. C and C++ are among the most powerful and most widely used high-level languages. Programs that involve a lot of hardware such as robots and control systems or programs that must run quickly are usually best written in low-level or Assembly languages. Complex data processing problems that manipulate massive amount of data employ high- level languages. Now-a-days Assembly languages are also interspersed (intermix) with C/C++ and Pascal to perform machine control functions efficiently. TRANSLATORS: - Translators are complex programs, which convert instructions written in one programming language to the format of another programming language without changing the meaning of the information and this process is called “Translation”. A program written in any programming language other than machine language requires conversion to machine language before it can be executed. Translators convert “Source program/code” (written by the programmer) into a known as “Object program/code” (binary machine code equivalent). Translators as well as providing a way for communicating the instructions, also allow the programmer to perform additional functions e.g., storage areas used by the particular program can be defined and allocated, and the programmer can define and store any constants etc. There are three types of translators: 1. Assemblers 2. Compilers 3. Interpreters 1. ASSEMBLERS: - Assemblers convert Assembly language programs into equivalent machine code. These are similar to compilers but are specifically developed for Assembly language. These programs perform the tedious “bookwork” of all the instructions. Since the Assembler allocates actual numerical values to addresses referred to by labels in the source program, the programmer does not have to remember the addresses of locations or instructions. Further, if he alters his source program, when it is assembled again addresses will be automatically adjusted wherever they occur. They come with some form of editor or wordprocessor (a text-editing device) that allows easy creation of the source code. 2. COMPILERS: - Compiler converts high-level language programs into equivalent machine code. A compiler normally generates several low-level instructions for each high-level (source) language instruction, whereas an Assembly language is one-for-one with machine code. The compilation of a high-level language program can take a considerable amount of computer time. During compilation a compiler: A: translates each high-level language statement into its machine code equivalent. B: incorporates into the object program any library subroutines used. Routnes / Subroutines are programs that carry out a well-defined function, and a collection of proven routines/subroutines developed by the software manufacturer/user is called a “Program Library or Standard Library”. C: supplies the interconnecting links between parts of the program.
  • 22. Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect) December 2000 A fault confessed is half redressed. Since a translator (compiler/interpreter) can translate only particular language for which it is designed, one will need to use a separate translator for each programming language. 3. INTERPRETER: - Interpreter is synonymous with “Conversational compiler or Interpretive routine”, which uses the conversational/interactive mode of computer operation in which the user enters each high-level (source) language statement in turn to the computer, which immediately checks its validity and informs the user if he can proceed or must correct a mistake. Hence an interpreter is identical to a compiler, except that an interpreter translates and then executes a program line by line. Interpreters are popular in program development environments in which programs are frequently recompiled as new features are added and errors are corrected. Once a program is developed, a compiled version can be produced to run most efficiently. The compiler has several advantages over the interpreter: - 1. First, the source code does not have to be recompiled/reinterpreted again and again when loops/control loops (series of instructions are repeated until some specified condition is satisfied) are encountered. 2. Second, the object code will run by itself without the need for the interpreter to be resident in the memory. This saves memory and allows larger programs to be written. The main disadvantage of using a compiler is that errors will require reinvoking the editor, correcting the errors and recompiling the program. This can be frustrating when simple “Syntax Errors” appear. Hardly any computer program could avoid performing arithmetic. The ADD instruction adds and 8- or 16-bit source operand to a destination operand of the same size. The syntax of ADD instruction is: ADD destination, source The source operand will remain unchanged by the operation e.g., in the given instruction ADD AX, BX This ADD instruction adds AX, a 16-bit Accumulator register to BX, 16-bit Base register. Assembly Language Operation ADD AX, BX AX=AX+BX OPERATIONS AND RESULTS: - MOV is a Data Transfer instruction. It copies data from one operand to another operand of the identical size (word size). The syntax of MOV instruction is: - MOV destination, source Data is merely copied from the source to the destination, so the source operand is not altered. This source operand may be a register, a memory operand or an immediate numeric value. This destination operand may be a register, or a memory operand. The following types of data transfers are possible: immediate data to register/ memory register to register register to memory memory to register (a) MOV BX, 03FFH This MOV instruction will put the 16-bit immediate value (03FFH) into the 16-bit BX register. It is a common error to make the source operand greater than the destination operand. (b) MOV AL, 0DBH This MOV instruction will put 12-bit immediate value (0DBH) into the 8-bit AL register. In this case say only the hex value DB will be stored. (c) MOV DH, CL A MOV instruction involving only registers is the fastest type taking only two clock cycles (of the clock signal generator, which synchronizes all the operations of the computer). Registers should be used when an instruction must execute quickly. This MOV instruction will move the contents of 8-bit register DH into the 8-bit CL register. (d) MOV BX, AX
  • 23. Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect) December 2000 A fault confessed is half redressed. This MOV instruction will copy the contents (data) of 16-bit AX register to the 16-bit BX register. ASSEMBLY LANGUAGE STATEMENTS: - Adding integer 5 to integer 2. MOV AH, O5H ADD AH, O2H INSTRUCTION CLASSIFICATION: - As we have discussed major types of instructions in Chapter#02 (Microprocessor Architecture), so now will confine our discussion only to classify the instructions mentioned in our curriculum (course): DATA TRANSFER INSTRUCTIONS: - MOV, XCHG, PUSH, POP ARITHMETIC INSTRUCTIONS: - ADD, SUB, INC, DEC, CMP LOGICAL INSTRUCTIONS: - NOT, AND, OR, XOR, TEST SHIFT/ROTATE INSTRUCTIONS: - ROL, SAL PROGRAM CONTROL INSTRUCTIONS: - JMP, JNC STRING INSTRUCTIONS: - REP PROCESSOR/MACHINE CONTROL INSTRUCTIONS: - ESC, HLT, STD, CLC PROGRAMMING: - Programming is the process by which a set of instructions (program) is produced for a computer to make it perform a specified activity. Before writing a program for a particular problem, it is essential to have a thorough understanding of the problem and a carefully planned approach to solving the problem. It is of paramount importance to clearly isolate every single step and every single condition that can possibly occur during the solving the problem. For writing a program the main steps are: 1_ Understand the problem, and plan the solution. 2_ Prepare a flowchart, Pseudocode, or Decision Table of the problem. 3_ Prepare the instructions in coded form. 4_ Test the program until it is performing 5_ Prepare detailed documentation of the program and instructions on its operation. Understanding the problem is of fundamental importance. Mostly the programmer works from a detailed program specification (algorithm). This algorithm includes descriptions of all input to the program, the processing required, and details of all output from the program. i.e., once a problem is properly analyzed, the next step is to write a sequence of actions involved in the solution of the problem, called an “Algorithm”. Therefore an algorithm is a procedure for solving a problem in terms of the actions to be executed, and the order in which these actions are to be executed. Specifying the order in which statements are to be executed in a program is called “Program Control”. “Pseudocode” is an artificial and informal language that helps programmers develops algorithms. Pseudocode is similar to everyday English language; it is convenient and user-friendly although it is not an actual programming language. Pseudocode helps the programmer think out a program before writing it in a programming language. Pseudocode instruction consists purely of characters arranged in symbolic form. Then a carefully prepared pseudocode program may be easily converted to a corresponding programming language simply by replacing pseudocode instructions with their source language equivalents. The next step is “Flowcharting” the problem A “Flowchart” or “Flow-diagram or Logic diagram“ is a graphical representation of an algorithm and “Flowcharting” is the technique of drawing the flowcharts. The object of flowcharting is to show the logical relationship between the various parts of the program. The flowchart is very useful in understanding the flow of logic (program control). It is particularly important to maintain an overall flowchart when “Segmentation” (programming technique in which a lengthy and complex problem is divided into a series of shorter units called “Segments, or Chapters”) takes place to ensure that all parts of the problem are taken careof. In a nutshell, a flowchart is very useful in planning and designing a complex problem. A flowchart is then used as the basis for writing a program. A flowchart is normally
  • 24. Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect) December 2000 A fault confessed is half redressed. independent of the type of the computer as well as the programming language to be employed. In a Flowchart all the operations are shown by the various conventional symbols which are connected with each other by the arrows s (flow lines) to indicate the flow of logic. The important symbols are: FLOWLINES: (Arrows) show the transfer of program control from one operation to another. TERMINAL: symbol (an Oval) represents a terminal point in a flowchart e.g., start, stop, halt, or interrupt. INPUT/OUTPUT: symbol (a Trapezoid) is used for input/output operation. PROCESS/ACTION: symbol (a Rectangle) indicates any type of calculation or logical manipulation. DECISION: symbol (a diamond) shows a decision point at which different alternative paths may be selected. It is normally entered from the top and have at least two exists although a third may be added if desired. CONNECTOR: symbol (a Circle) represents any entry to or exit from another point of the flowchart. It is used to indicate a transfer of program control that cannot be conveniently shown by a flow line e.g., because the flowchart continues on another page. Whenever, broken/segmented parts are to be connected, the circles connecting them must have the same numbers. Like pseudocode, flowcharts are very useful in developing and representing algorithms, although most programmers strongly prefer pseudocode. N.B: For more exercise, consult the class lectures in which pseudocode, algorithms and flowcharts for various programs had been developed. MAJOR STEPS IN DEVELOPING AN ASSEMBLY LANGUAGE PROGRAM: - Coding the program follows the completion of flowcharts. The logical steps described in the flowchart are translated into instructions. The programmer’s ultimate goal is to reproduce the logic of the program shown in the flowchart as simply, economically, and efficiently as possible. Assembly programs typically go through these phases: 1.EDITING STEP: - The first step is creating a source file. Source files are created using an “Editor” (a program that assists us to prepare text or data entry to or output from a computer or to retrieve and rearrange data previously stored in a file) that comes with an assembler. Any word processor or editor can be used that is capable of generating a text (ASCII) file. The programmer types an Assembly program with the editor and makes corrections if necessary. The program is then stored on a secondary storage device such as a disk. The source program file you generate must use the extension “.ASM“ that is required for the assembler to properly identify your source program. 2. ASSEMBLY STEP: - During this step the Assembler or Assembly routine converts a symbolic source module (file) into a hexadecimal object file/code. This object code is the machine language version of the source program but it lacks certain information needed by the operating system (DOS) before it may be executed. This is designed as an input file to the linker. Object file names end with the “.OBJ“ extensions. 3. LINKING STEP: - Linking step is the next step. Assembly programs contain references to functions defined elsewhere, e.g., in the “Standard/Program Libraries”. The object code produced by the Assembler typically contains “holes” due to these missing references. A Linker provided with the Assembler links the object code for the missing functions and produces an executable file with the extension “.EXE”. Execution files are executed just by typing the file name at the DOS prompt. EDITOR COMPILER LINKER SAMPLE.ASM SAMPLE.OBJ SAMPLE.EXE Typically programs are written by combining new functions with “pre-packaged” functions available in the standard libraries. These standard libraries provide a rich
  • 25. Chap#03 Microprocessor Programming Compiled By Sajid Iqbal (B.Sc. Elect) December 2000 A fault confessed is half redressed. collection of functions for performing common mathematical calculations, character manipulations, input/output, and many other handy operations. These standard libraries are provided as part of the programming environment. During programming always try to use the available standard library functions instead if writing new ones (Avoid reinventing the wheel). This will greatly reduce program development time. The linker program links all these programming modules into a complete program. DEBUGGING: - It is most unusual for a computer program to work correctly for the first time. Any mistake or malfunction of a computer program or system is called a ”Bug”. Therefore the technique of detecting, diagnosing, and correcting errors/bugs that may occur in programs (software) or systems (Hardware) is called “Debugging” or “Troubleshooting”. The two main types of errors are: 1. Syntax errors 2. Logical errors Syntax errors occur due to the incorrect use of programming language i.e., the coding of the program is not impeccable. Logical errors occur due to the incorrect logic in the solution of the problem i.e., the evaluation of the program is faulty. Most compilers detect syntax errors and print some indication of the type (cause) of the errors. Normally programs, which have compilation errors, cannot be run, and these errors must be corrected before the program can be tested. While compilers cannot usually detect logical errors, even if the instruction will cause the program to carry out an illogical operation or perform an erroneous calculation. Once an error has been detected, either through incorrect results from test data (Sample data covering all likely and unlikely possibilities, prepared to test a program and the expected results are compared with actual results) or simulated operating conditions, or through an unexpected halt, or through compilation errors, the cause of the error must be diagnosed. Once an error has been found, a correction must be applied to the source code by editing. As far as Assembly language is concerned some known debugging tools/techniques are: DEBUGGER: - Debugger is a program that allows looking at the contents of registers and memory locations after program executes. Debugger loads object code into memory, executes it and debugs it. It is used when learning about data storage and Assembly instructions and when tracing executable programs. While debugging short programs, use single-step command. Debugger will execute one instruction and then stop execution. If the instruction is correct, you can proceed to next instruction. This operation is also termed as “Step-by-step, Single-shot, or One-shot operation”. For longer programs the single-step approach is cumbersome. “Breakpoints” are often a faster technique to narrow down the error down to a small region. By inserting a breakpoint to an instruction, the debugger will run the program upto the instruction having breakpoint and stop execution. We can detect, and correct the error and then proceed further. In short, debugger quickly finds the source of error in a program. Once you find the problem, you can correct it. A basic debugger comes with the DOS, but many sophisticated and expensive debuggers are available: Code View, Periscope, Codesmith- 86, and Atron, to mention just a few. MONITOR: - Certain microprocessor boards contain a special debugger program stored permanently in memory (ROM) called “Monitor”. Such routines (a software procedure that performs a well-defined function in the operation of a program or a system) are used to provide diagnostic information on the progress of a program for the purpose of debugging. Such devices examine the status of the system to indicate any deviation from the prescribed operational conditions e.g., the SDK-86 monitor lets us enter single-step commands through programs, insert breakpoints, examine registers, and memory contents. EMULATOR: - Emulator is usually used to test and debug the hardware and software of a different and external computer system, such as a microprocessor-based instrument, and this process