- Back to Home »
- Micro Processor
Posted by : Unknown
Friday, July 26, 2013
MICROPROCESSOR
Introduction:
Minicomputer is making a
great impact on every day activity of mankind and plays an important role in
day-to-day working of industrialized societies. Large computers were designed
to solve complex scientific and engineering problems and handle records of
large corporations and government agencies. Only large institutions and
organisations were able to purchase digital computers. A trend started in the
middle of 1960’s to design smaller computers for smaller organisations. In the
late 1960’s minicomputers were available for use in an office, small college,
medium-sized business organizations, small factory and laboratory. The smaller
organizations that were not able to afford large computer could now purchase a
minicomputer.
Definition:
With
the advent of Semiconductor technology, it became possible to fabricate the
whole CPU of a digital Computer on a single chip using VLSI technology. A
VLSI-IC contains more than 10,000 transistors. A CPU built into a single IC
called a microprocessor. A digital
Computer whose CPU is a microprocessor is called a microcomputer. A
microprocessor combined with memory and Input / Output devices form a
microcomputer.
Evolution
of Microprocessor:
In 1971 Intel Corporation, U.S.A introduced the
first microprocessor the Intel 4004, which was a 4-bit microprocessor. In 1972
Intel introduced the first 8-bit microprocessor, the Intel 8008. In 1973 a more
powerful and faster 8-bit microprocessor, the Intel 8008 was introduced.
In 1973 second generation 8-bit
microprocessors evolved. They were Intel 8080/8085, Fair Child, F-8, and
Motorola 6800.
After
1978, the third generation microprocessors were introduced. These Processors
are 16-bit wide and include typical processors such as Intel
8086/8088/80186/80286, Motorola 68000/68010.
Fourth
generation microprocessors evolved in the year 1981. Intel introduced the first
commercial 32-bit microprocessor in Intel 432. Since 1985, more 32-bit microprocessors
were been introduced. These include Motorola 68020, 68030 and Intel 80386. In
1989, Intel introduced the 32-bit microprocessor Intel 80486. Later Intel has
introduced 64-bit microprocessor Intel 80586(Pentium).
Microprocessor Operation:
The
CPU microprocessor was digital circuits for data handling and computation under program control. That is
microprocessor is a data processing unit. Data processing is the
microprocessors main function. Date processing includes both computation and data
handling. To do this, it must have logic, which tells the microprocessor how to
decode and execute the program, and also the control logic determines which
circuit to process the data. The Microprocessor operates in the following
steps. First the microprocessor fetches an instruction. Then the control logic
decodes what the instruction says to do. After de loading, the microprocessor
executes the instruction these steps are called fetch and execute cycle for
each instruction in memory the microprocessor goes through one fetch and
execute cycle.
The
control logic controls how the microprocessor works with all of the outside
circuits (memory, input, and output) Connected to the microprocessor.
Microprocessor can do nothing by itself. The microprocessor must have the aid
of other circuits. Some memory circuits are required to store the program
instructions and circuits are also needs to more data into and out of the
Microprocessor these circuits are called input / output circuits. The micro
process or also requires a power supply. The microprocessor is the heart of
many products, but the microprocessor is never a complete, working product
itself.
Microcomputer:
Frequently the words “microprocessor” and “microcomputer” are used to mean
the same thing, but infect these similar words have different meanings. The
microprocessor is an IC. It includes the circuits for two purposes, Data
processing and control. But the microcomputer is a complete computing system
built around a microprocessor. Some microcomputers are personnel computers and
some other microcomputer systems are dedicated computational systems based on a
microprocessor.
Power of a microprocessor:
Almost all
microprocessors are made on silicon die (often called ICs). These ICs are about
¼ inch or 0.64 cm, on side. The
measures of he power of a microprocessor are the length of a microprocessor’s
data word. The number of memory words that the microprocessor can address, and
the speed with which the microprocessor can execute an instruction.
Microprocessors are most often compared in terms of the lengths of their data
words. The microprocessor works on fixed length date word. Today the most
common word lengths are 4bits 8bits, 10bits and 32 bits. Soon, 64 bit
microprocessors will become common too.
Another
common measure of microprocessor power is the number of memory bytes that the
microprocessor can address. Here the length of data word in memory is same as
the length of the data word used by the microprocessor for example a 4-bit
microprocessor stores 4-bit words in memory. Each word in memory is assigned a
location number or address.
The third measure of
microprocessor executes an instruction. Speed is determined by the time it
takes the microprocessor to complete the fetch execute cycle for one program
step. This oscillator circuit is called the microprocessor’s clock slow
microprocessors may use a clock that runs at a few Kilo Hertz. Such microprocessor takes 10 to
20 microseconds to execute one instruction. On the other hand some
microprocessors use clocks that run at 10 to 100 MHz. These microprocessors may
execute an instruction in only a few tenths of a microsecond. The
microprocessor’s speed related to its maximum clock frequency.
Number System:
The
microprocessor is built with digital logic and therefore manipulates binary
data. We often ask the microprocessor to perform arithmetic functions often we
want output and input information in the familiar decimal numbers. Therefore to
use microprocessor number system plays an important role. Different number
systems are
- Binary
- Decimal
- Octal
- Hexadecimal
It is possible
to convert from one system to any another system.
Microprocessors Architectural Concepts:
Microprocessor's Architecture:
We know that there is no
precise definition of architecture; the following examples should help to
understand the architecture. We all know that the person who designs buildings
is an architect. We realize that while all buildings perform similar functions,
i.e. they keep whether out they do it in different ways. The same is true of
microprocessors. There are many different ones. Most try to do the same job,
but the internal structure that they use to do job is different. That is their
architecture is different.
For
some microprocessors, the architectural differences are small. For others, the
differences are large. For example, the Intel 8051 8-bit single chip
microprocessor and the Intel 486 32-bit microprocessor will both add two
numbers. The way of adding two numbers and the parts they use to add the two
numbers are quite similar. However, to compute the cosine of an angle, the way
they perform this task and the parts they use will be very different. Each of them
can do the job, one with great ease and another with extremely different. Since
they have different architectures.
The major architectural differences between
microprocessors are
- The length of the microprocessor's data word.
- The size of the memory, which the microprocessors can directly
address.
- The speed which the microprocessor can execute instructions.
Some additional architectural differences between
microprocessors are:
·
The number of registers available to the programmer.
·
The different types of registers available to the programmer.
·
The different types of instructions available to the programmer.
·
The different types of memory addressing modes available to the
programmer.
·
The different types of circuits available to the system designer.
·
Compatibility with readily available development, system and
applications software.
·
Compatibility with hardware development systems.
These
differences make some microprocessors better for some applications and some
other microprocessors better for other applications.
Word length:
The microprocessor started as a
4-bit device. It is progressed an 8-bit, a 16-bit, a 32-bit, and now a 64-bit
device. To know the performance the initial step is speed - how quickly the
microprocessor will perform its internal function. This tells us that a
microprocessor with a longer word length will solve more problems faster.
Therefore, a longer word length should give a better solution to all problems.
However, to solve a variety of problem like building a simple microprocessor
controlled toy, to calculate cosine of an angle, the real performance issue is
cost. The 4-bit microprocessors are very good for low cost applications.
Therefore, from the above reason the shorter- word length architecture is still
used.
Addressable Memory:
The amount of memory that a
particular microprocessor can address is also part of its architecture. Some
applications require less addressable space and others require more addressable
space. Depending on requirement we will select anyone from 4-bit, 8-bit,
16-bit, 32-bit, 64-bit. The 32-bit microprocessor architecture allow to address
4 GB memory.
The Microprocessor's Speed:
The speed of microprocessor to
execute an instruction is often used to compare the performance of two
microprocessors. Speed may be measured in two different ways. The first is the
microprocessors clock speed. This is the frequently at which the
microprocessor's clock oscillator operates. Typically this is expressed in
megahertz (MHz). The second method of rating a microprocessor's speed is the
number of instructions it can execute per second. Processing speed is usually
expressed in millions of instructions per second (MIPS).
The processing rate depends on both
the clock frequently and the word size. If two microprocessors perform a memory
access in the same amount of time the 16-bit microprocessors will be twice as
fast as the 8-bit microprocessor. The frequency at which the microprocessor's
clock operates depends largely on the semiconductor manufacturing technology
used to build the microprocessors. Microprocessors are constructed using one of
the two semiconductor technologies. These two technologies are NMOS (N-channel
metal-oxide semiconductor) and CMOS (complementary metal oxide semiconductor).
CMOS processors typically will operate over a greater range than the NMOS
devices.
Other Architectural Characteristics:
Some other microprocessor
architectural techniques being used to increase speed included
·
Parallel
processing
·
Co
processing
·
Cache
memory techniques
·
Pipelining
techniques
·
Wider
buses.
Parallel processing means just what
it says; this means that the microprocessor architecture permits two parts of
the computing process to occur at the same time. The implementation of the
parallel processing involves the use of the two microprocessors in the same
product. Parallel processing is used with in the microprocessor itself. The
parallel processing configuration using two microprocessors was shown below.
Advanced microprocessor
architecture may include multiple execution units with in the microprocessor
design. This form of parallel processing is called a super scalar architecture.
Co-processing is very much like parallel
processing. The coprocessor is a separate processor, which work with the mail
processor to perform special functions. Many conventional microprocessors are
supported with separate IC, which perform the co-processing function. For
example, the 386 are supported with the 80387 numeric data coprocessor. The 80387 are wired in parallel with the 386
processor. When combined these two processors the combined system has extra
high-level mathematical performance. A
386 system using an 80387 numeric date coprocessor is shown in the following
figure.
Microprocessor
architecture faces speed limitation from memory read or writes. There is a
technique to solve the problems is to use a very fast cache memory. This fast
cache memory may locate very close to the microprocessor or it may be included
with in the microprocessor on new microprocessor architectures. To offer a speed improvement the cache memory
has more hits than misses.
Pipelining is another architectural
technique that processes a number of instructions at one time. Each instruction
is processed a little a each station
just like a product is built a little at each station on an assembly line. The use of pipeline architecture allows the
designer to build faster, more dedicated logic at each station and therefore
the microprocessor completes the desired process quicker. When the
microprocessor has the ability to process wider data it is naturally faster.
Wider data buses
are used inside the microprocessor as well as in microcomputer design. We have
seen examples of this architectural technique when microprocessors used
doublewide accumulators. The doublewide accumulators allow processing certain
functions faster because it eliminates the need to perform an intermediate
storage in memory.
The Microprocessor's Registers:
The registers are temporary data
storage devices found inside the microprocessors. Some has special
single-purpose function and others are used for general-purpose data storage.
The number and type registers in any particular microprocessor will be
different from another microprocessor.
The number of registers in the microprocessor is important. If the microprocessor architecture does not
have enough registers to allow the programmer to assign register for a specific
task, the programmer must transfer the data in the register into temporary
memory locations. When the task was completed it retrieve data from temporary
location to registers. The data transfer from a register to memory or memory to
register is wasted instructions. The types of register available to the
programmer can also represent a performance issue.
The Microprocessor's Instructions:
Like the register,
the number and kind of microprocessor's instructions are a measure of the
microprocessor's power. More instructions means a bigger microprocessor and
bigger microprocessors are more complex.
Inside The Microprocessor:
The Microprocessor Block Diagram and
Programming Model:
The microprocessor block diagram and the
microprocessors programming model shows the user how the specific
microprocessor is constructed. The block diagram shows a microprocessor’s logic
function for data processing and data handling. It also shows how each logic
function is connected to all others. The programming model shows the parts of
the microprocessor that the programmer can change. The 8-bit microprocessor's
block diagram is as shown below.
0
07
0
Accumulator
|
Status Register
|
Reg B
|
Reg
C
|
Reg
D
|
Reg
E
|
Reg
H
|
Reg
L
|
SP
|
|
PC
|
15
The programming model only shows those
registers which the programmer can use to store data or which the programmer
must access to have right data for a program operation.
The ALU :
One of the microprocessors major logic
functions is the arithmetic logic
unit. It contains the microprocessors data processing logic. It has two input
ports and one output port.
An input port is made up of logic circuits used to get
a data word into a logic device. An output port is made up of logic circuits used to get out a data word out of
a logic device.
Both input ports are buffered by a temporary
registers. Each port has a register that temporarily stores one data word. The
microprocessors internal bus is connected to the ALU`s two input ports through
the temporary registers. This allows it to take data from any device on the
microprocessors internal data bus. Often, the ALU gets its data from a special
register called the accumulator. The ALU's single output port allows it to send
a data word over the bus to any device connected to the bus. The list of ALU
functions varies from one microprocessor to another.
The ALU’s of most microprocessors can perform all
functions as
Add, Subtract, AND, OR, Exclusive OR,
Complement,
Shift right, Shift left,
Increment, Decrement.
ALU’s have many functions and others have only a few.
The Microprocessor's Registers:
Registers
are an important part of the block diagram and the programming model of any
microprocessor. There are different registers. The basic registers found in
most microprocessors are the accumulator, the program counter, the stack
pointer, the status register, the general-purpose registers, the memory address
register, the instruction register and temporary data register.
Accumulator:
The accumulator is the microprocessor's major working register. For
example, the microprocessor's addition of two words is first word A is placed
in the accumulator. The addition is then executed by adding word B (the
contents of memory location) to word A (in the accumulator). The resulting sum
is placed in the accumulator, replacing word A. Another kind of operation using
the accumulator is the programmed data transfer. It moves data from one place
to other. Data movements between I/O port and a memory location or between
one-memory locations to other memory location. The data transfer takes place in
two stages i.e. the data is moved from source to accumulator and from
accumulator to destination. Some
microprocessors have multiple accumulators.
Program Counter:
The program counter is one of the most important registers in the
microprocessor. Before the microprocessor can start executing a program, the
program counter has to be loaded with a number. This number is the address of
the memory location containing the first program instruction. Usually this is a
simple number such as all zeros or all ones. Once the microprocessor fetches an
instruction from memory, the microprocessor automatically increments the
program counter. The program counter always point to the next instruction
throughout the time the current instruction is being executed.
Status Register:
The register that can make the difference between a simple calculator
and an arithmetic computer is the status register. The status register is used
to store the results of certain tests performed during execution of a program.
Some common status register bits are: carry/barrow, zero, negative,
intermediate, carry, interrupt, flags, overflow, parity. If two 8 bit numbers
are added and there sum is greater than 11111111 then a carry is generated.
When this carry is generated, the microprocessor sets the status registers
carry bit.
Stack Pointer:
The programmer require to pushes the information on to the stack in
order and pops the information from the stack in the reverse order. The kind of
operation on the stack is LIFO (last in first out). To do this the programmer
uses a special register called the stack pointer. Like the program counter, the
stack pointer automatically points to the next available pointer location. In
most microprocessors, the stack pointer decrement after it is used.
General-Purpose Registers:
In
addition to the size basic registers, most microprocessors have other registers
for general programming use. These other registers are called general-purpose
registers. The microprocessor used size general-purpose called the B, C, D, E,
H, and L registers.
Instruction Register:
The
instruction register holds the instruction the microprocessor is currently
executing. This is instruction register’s only job, and the instruction
register performs it automatically. Instruction register is important, because
its output always drives the part of the control logic known as instruction
decoder. During execution the instruction decoder decodes the instruction to
tell the microprocessor exactly what to do to carry out the instruction. The length of the instruction register is
varies from one microprocessor to another. In some microprocessors, the
instruction word is as long as the data word. In others, instruction word may
be as sort as 3 or 4 bits.
Temporary data registers:
The temporary
registers are required because the ALU has no data storage of its own. The ALU
must take data from the microprocessor’s internal data bus, change the data and
then placed the change data into accumulator. The ALU ’s temporary registers
cannot be used by the programmer and therefore, are not part of the programming
model. These temporary registers are very essential to the internal function of
the microprocessor.
Memory Address Register:
Every
time microprocessor addresses the microprocessor memory, the memory address
register points to the memory location the processor wants to use. During the
fetch cycle an instruction is taken from memory. The memory address register
points to the instruction word being fetched from memory. The memory address
register must have enough bits to address any location in the microprocessor’s
memory. A 16bit memory address register may be divided into two separate
registers each with an independent connection to the microprocessor’s data bus.
These registers are called High-byte and the Low-byte memory address registers.
Microprocessor’s Control Logic:
Another
major logic function of the microprocessor is its control logic. The control
logic takes instructions from the instruction register, figures out what to be
done to the data and then gives the commands necessary to get the job done. The
architecture of the control logic itself is much like the architecture of a
very special purpose microprocessor. The control logic is like a small
microprocessor with in the microprocessor. The control logic includes control
lines to each of the microprocessor’s logic functions. These lines include the
memory, I/O, and Read-write lines. These control lines send control signals to
the external devices telling them what to do and when to do it.
The
Microprocessor’s Internal Data Bus:
All
internal microprocessor data transfers take place on this bus. The
microprocessors internal data bus is made up of data signals. Almost all of the
microprocessor’s logic devices have bi-directional communication with the
internal data bus i.e. the devices can either place data on the bus or receive
from the bus. The internal data bus may be connected to an external data bus
when the microprocessor needs to send or receive data.
8086 FAMILY ASSEMBLY
LANGUAGE PROGRAMMING:
Introduction to programming the 8086:
There are three language levels that can be used to write a program for
microcomputer.
Machine language:
Programs as simply a sequence of the
binary codes for the instructions to execute on microcomputer. This binary form
of the program is referred to as the machine language, because it is the form
required by the machine. It is difficult for a programmer to memorise the
thousands of binary instruction codes for a CPU such as an 8086. Also it is
very easy for an error to occur when working with long series of 1’s and 0’s.
Using hexadecimal representation for the binary codes might help some, but still
there are thousands of instruction codes.
Assembly language:
To make programming
easier, many programmers write programs in assembly language. To convert the
assembly language program to machine language it can be loaded into memory and
run. Assembly language uses two, three, or four letter mnemonics to represent
each instruction. Assembly language statements are usually written in a
standard form that has four fields as shown below.
LABEL FIELD
|
OP CODE FIELD
|
OPERAND FIELD
|
COMMENT FIELD
|
NEXT:
|
ADD
|
AL, 07H
|
; ADD A FACTOR
|
The first field in
the assembly language is the LABEL FIELD. A LABEL FIELD is a symbol or group of
symbols used to represent an address, which is not specifically known at the time
the statement written labels are used followed by a colon. It is optional
field.
The
OPCODE field of instruction contains the mnemonic for the instruction to be
performed. Instruction mnemonics are some times called operation codes or
opcodes.
The
OPERAND FIELD of the statement contains the data, memory address, the port
address or the name of the register. In the above example the result of ADD
will put in the register or memory location specified before the comma in the
operand field.
The final
field in the assembly language statement is the COMMENT FILED, which is started
with semicolon.
High level languages:
Another way of writing a program
for a microcomputer is with a high-level language, such as BASIC, Pascal or C.
The high-level language statement may represent many machine code instructions.
An interpreter program or compiler program is used to translate higher language
statements to machine codes, which can be loaded into the memory and executed.
Writing programs in high level language is simple because the high level
language works with bigger building block programs written in high level
language and interpreted or compiled almost always execute more slowly and
require more memory than the same programs written in assembly language.
Programs that involve a lot of hard ware control, such as robots and factory
control systems, or programs that must run as quickly as possible are usually
best written in assembly language. Complex data processing programs that
manipulate more data such as insurance company records are usually written in
high-level language.
Assembly Language Program Development Tools:
The assembly language programs require some type of microcomputer
development system and development
tools to make easier. A typical system might consist of an IBM PC-type
microcomputer with at least several hundred kilobytes of RAM, a keyword and
video display, floppy and/or hard disk drives.
Editor:
An
editor is a program, which allows creating a file containing the assembly
language statements for a program. Writing programs on editor are called source
programs. The source programs are started with an extension ASM.
Assembler:
The assembler generates two files: the first file called object is given
the extension. OBJ. The object file contains the binary codes for the
instructions and information about the addresses of the instructions. After further processing,
the contents of this file will be loaded into memory and run. The second file
generated by the assembler is called the assembler list file and is given the
extension .LST.
Linker:
A
linker is a program used to join several object files into one large object
file. When writing large programs, it is usually much more efficient to divide
the large program into smaller modules. Each module can be individually
written, tested and debugged. Then, when all the modules work, their object
modules can be linked together to form a large functioning program.
The
linker produces a link file, which contains the binary codes for all the
combined modules. The linker also
produces a link map file, which contains the address information about the
linked files.
Locator is a program
called EXE2BIN comes with the IBM PC DOS. EXE2BIN converts a .EXE file to a
.BIN file which has physical address.
A debugger is a program,
which allows you to load your object code program into system memory, execute
the program and troubleshoot or “debug” it.
Another way to run program
is with an emulator. An emulator is a mixture of hardware and software. It is
usually used to test and debug the hardware and software of external system,
such as the prototype of microprocessor-based instrument.
Data Transfer Instructions:
General purpose byte or word
transfer instructions:
MOV Copy byte or word from specified
source to specified destination.
PUSH
Copy specified word to top of stack.
POP
Copy word from top of stack to specified location.
PUSHA
(80186/80188 only) Copy all registers to stack.
POPA
(80186/80188 only) Copy words from stack to all registers.
XCHG
Exchange bytes or words.
XLAT
Translate a byte in AL using a table in memory.
Simple input and output port transfer
instructions:
IN
Copy a byte or word from specified port to accumulator.
OUT Copy a byte or word from accumulator to
specified port.
Special address transfer instructions:
LEA
Load effective address of operand into specified register.
LDS
Load DS register and other specified register from memory.
Flag transfer instructions:
LAHF
Load AH with the low byte of the flag register.
PUSHF
Copy flag register to top of stack.
Arithmetic instructions:
ADD
Add specified byte-to-byte or specified word to word.
INC Increment specified byte or specified word by
1.
SUB
Subtract byte from byte or word from word.
DEC
Decrement specified byte or specified word by 1.
CMP
Compare two specified bytes or words.
MUL
Multiply unsigned byte-by-byte or word-by-word.
IMUL
Multiply signed byte-by-byte or word-by-word.
DIV
Divide unsigned word by byte or unsigned double word by
word.
IDIV
Divide signed word by byte or unsigned double word by word.
Bit manipulation instructions:
NOT
Invert each bit of a byte or word.
AND
AND each bit in a byte or word with the corresponding bit in
another
byte or word.
OR
OR each bit in a byte or word with the corresponding bit in
another
byte or word.
XOR Exclusive OR each bit in a byte or
word with the corresponding
bit in another byte or word.
another byte or word.
SHL
Shift bits of word or byte left, put zero in LSB.
SHR
Shift bits of word or byte right, put zero in MSB.
Program execution transfer instructions:
CALL
Call a procedure save return address on stack.
RET
Return from procedure to calling program.
JMP
Go to specified address to get next instruction.
LOOP
Loop through a sequence of instructions until CX=0.
INT
Interrupt program execution OF=1.
IRET
Return from interrupts service procedure to main program.
ENTER (80186/80188 only) Enter procedure.
LEAVE
(80186/80188 only) Leave procedure.
BOUND
(80186/80188 only) Check if effective address with in
specified array bounds.
TEST
Wait until signal on the TEST pin is slow.
Program Format:
To write the program in correct format, assembly language coding sheets
are available. The format is as follows.
ADDRESS
|
DATA (or)
CODE
|
LABELS
|
MNEM
|
OPERANDS
|
COMMENTS
|
|
|
|
|
|
|
The ADDRESS column is used for the address or offset of a code byte or
data byte. The actual code bytes or data bytes are put in the DATA/CODE column.
A label is a name which represents an address referred to in a jump or call
instruction; labels are put in the LABELS column. The MNEM column contains the
opcode mnemonics for the instructions. The OPERAND (S) column contains
registers, memory locations, or data acted upon by the instructions. A COMMENTS
column gives you space to describe the function of the instruction for future
reference.
The 8086 unconditional jump instruction:
The 8086 JMP instruction
always causes a jump to occur, so this is referred to as an unconditional jump.
Example:
CODE SEGMENT
ASSUME CS: CODE
BACK: ADD AL, 03H
NOP; Dummy instruction
NOP
JMP BACK
CODE ENDS
END
The 8086 Conditional Flags:
The 8086 have 6
conditional flags. They are the carry flag (CF), the parity flag (PF), the
auxiliary flag (AF), the zero flag (ZF), the sign flag (SF), and the overflow
flag (OF).
If the addition of two 8-bit numbers produces a sum greater than 8-bits,
the carry flag will be set to 1. Parity is a term used to indicate weather a
binary word has an even number of 1's or an odd number of 1's. A binary number
with an even number of 1's is said to have even parity. A binary number with an
even number of 1's is said to have even parity. A binary number with an odd
number of 1's is said to have odd parity. This flag has significance in BCD
addition or subtraction. As the name implies zero flag will be set to 1 if the
result of an arithmetic or logic operation is zero. The sign flag is used to
indicate the number sign. A 0 in this bit indicates positive and 1 indicates
negative. The overflow flag will be set if the result of a signed operation is
too large to fit in the number of bits available to represent it.
The 8086 Conditional Jump Instructions:
The
8086 conditional jump instructions are given below.
MNEMONIC CONDITION TESTED JUMP IF...
JA/JNBE
(CF or ZF)=0
above/not below nor equal
JAE/JNB
CF=0 above or equal/not below
JB/JNAE
CF=1 below/not above nor equal
JBE/JNA
(CF OF ZF)=1
below or equal/not above
JC CF=1 carry
JE/JZ
ZF=1 equal/zero
JG/JNLE
((SF xor OF) or ZF)=0
greater/not less nor equal
JGE/JNL
(SF xor OF)=0 greater or equal/not less
JL/JNGE (SF xor OF)=1 less/not greater nor equal
JLE/JNG
((SF xor OF) or ZF)=1 less
or equal/not greater
JNC
CF=0 not carry
JNE/JNZ
ZF=0
not equal/not zero
JNO OF=0 not overflow
JNP/JPO
PF=0 not parity/parity odd
JNS SF=0 not sign
JO OF=1
overflow
JP/JPE
PF=1
parity/parity equal
JS SF=1 sign
IF-THEN Structure:
The simple IF-THEN is
implemented with a conditional jump instruction.
Example: CMP
AX, BX; compare to set flags
JE
THREE ; if equals then
skip
ADD AX, 0002H ; add a factor
THREE: MOV CL, 07H
IF-THEN-ELSE Structure:
The IF-THEN-ELSE Structure is
used to indicate a choice between two alternative courses of action.
Example: 1.
CMP AL, 30 ;
compare AL, 30
JB YELLOW ; if AL < 30 then YELLOW
JMP
GREEN ; else GREEN
YELLOW: AL, 04H
--------
--------
GREEN: MOV AL, 03H
--------
--------
Example:
2 CMP AL, 30 ; compare AL, 30
JB YELLOW ; if AL < 30 then YELLOW
CMP AL, 40 ; else compare AL, 40
JB GREEN ; if AL<40 then GREEN
RED: MOV AL, 04H ; else AL
> 40
-------
-------
YELLOW: AL, 05H
--------
--------
GREEN : MOV AL, 03H
--------
--------
WHILE-DO LOOP:
In
this loop the condition is checked before any action is done.
Example: TEMP_IN: MOV DX, 0FFF8H
Example: TEMP_IN: MOV DX, 0FFF8H
IN AL, DX
CMP
AL, 100
JB HEATER_ON
JMP
HEATER_OFF
HEATER_ON:
MOV AL, 80H
MOV
DX, 0FFFAH
OUT
DX, AL
JMP
TEMP_IN ; while AL <
100 repeat once again
REPEAT-UNTIL Statement:
In
this statement the condition is checked after any action is done.
Example: LEA BX, PRICE ; initialise pointer
MOV CX, 0008H ; initialise counter
DO_NEXT:MOV AL, [BX]
ADD AL, 03H
MOV [BX], AL
INC BX ; point to next
price
DEC CX ; decrement
counter
JNZ
DO _NEXT ; if not
last repeat once
LOOP Statement:
The
LOOP statement is used to repeat the execution of instructions.
Example: MOV CX, 10
NEXT_TIME:
---------
---------
LOOP NEXT_TIME ; this loop execute 10 times
8086 STRING Instructions:
A
string is a series of bytes or words stored in successive memory locations.
8086 move a string using a MOVS instruction. To compare two strings we can use
CMPS instruction. The SCAS instruction can be used to search a string to see
weather it contains a specified character.
/* The
comparison of two strings password program is as follows.
DATA
SEGMENT
PASSWORD
DB
'FAILSAFE' ; password
STR_LEN EQU
($ - PASSWPRD) ; compute
length of string
INPUT_WORD DB 8 DUP (0) ;space for user password input */
PROCEDURES and MACROS:
When ever we need to use a group
of instructions several times through out a program, there are two ways we can
avoid having to write the group of instructions each time we want to use it.
One way is to write the group of instructions as a separate procedure we
can then just call a procedure whenever
we need to execute that group of instructions. The CALL instruction is used to
send to the starting address of the procedure in memory. A RET instruction at
the end of the procedure returns execution to the next instruction in the
mainline. A big advantage of using a procedure is that the machine codes for a
group of instructions in the procedure only have to be put in memory once.
Disadvantage of using a procedure are the need for a stack, and the overhead
time required to call the procedure and return to the calling program.
When
the repeated group of instructions is too short or not appropriate to be written
as a procedure, we use a macro. A macro is a group of instructions we bracket
and give a name to at the start of our program, the assembler will insert the
defined group of instructions in place of the “Call”. Replacing the macro with
the instructions it represents is commonly called “expanding” the macro.
Therefore using a macro avoids the overhead time involved in calling and
returning from a procedure. A disadvantage is generating in-line code each time
a macro is called will make the program take memory than using a procedure. A
macro to save all registers as follows.
PUSH_ALL MACRO
PUSHF
PUSH
AX
PUSH BX
PUSH
CX
PUSH DX
PUSH
BP
PUSH SI
PUSH
DI
PUSH DS
PUSH ES
PUSH
SS
ENDM
Applications of microprocessors:
We will frequently find
the 4-bit microprocessors are in
·
Toys:
robots, remote-controlled cars
·
Calculators:
financial, scientific, database.
·
Power
toll controllers: speed controls, sequencers, and measurement
devices.
·
Computer
peripherals: keyboard scanners, simple printers, and clocks.
·
Others:
refrigerator etc.
Some applications that use 8-bit
microprocessors are programmable robots, video displays, light-speed printers,
modems, plotters, disk controller etc. The 16-bit, 32-bit and 64-bit
microprocessors have found one high-volume application and a number of
low-volume applications. They are the heart of the personnel computers. The CAD
(computer aided design) and CAM (computer aided manufacturing) application
require 32-bit microprocessors. The microcomputer applications are slower down
by the time that the 32-bit microprocessors take to get data from external
devices, a 64-bit microprocessors becomes a real solution.
Conclusion:
Microprocessor is the
outcome of the trend towards computer era.
Now a days they play an
important role in many systems. They are used in many computer-based systems
and also in many homes need goods. The microprocessors are available with both
high and low speeds. Some systems require less speed and some others require
high-speed microprocessors. Thus microprocessor plays important role in
applications.
Assembly language plays an important
role for some applications. The applications that require execution in less
time are developed using Assembly language.