Professional Documents
Culture Documents
5.7 Microprocessors: Basic Maintenance Training Manual Module 5 Digital Technology / EIS
5.7 Microprocessors: Basic Maintenance Training Manual Module 5 Digital Technology / EIS
5.7 Microprocessors
Input Port
The input port provides data to the microprocessor via the data bus. In this case,
it is an octal buffer with three-stated outputs. The input to the buffer will be provid-
ed by some input device like a keyboard or, as in this case, from eight HIGH-LOW
toggle switches. The input port will dump its information to the data bus when it
receives a Chip Enable (CE) from the address decoder and a Read command
(RD) from the control bus.
Output Port
The output port provides a way for the microprocessor to talk to the outside world.
It could be sending data to an output device like a printer or, as in this case, it could
send data to eight LED’s. An octal D flip-flop is used as the interface because, after
the microprocessor sends data to it, the flip-flop will latch on to the data, allowing
the microprocessor to continue with its other tasks.
To load the D flip-flop, the microprocessor must first set up the data bus with the
data to be output. Then it sets up the address of the output port so that the address
decoder will issue a LOW CE to it. Finally, it issues a pulse on its WR (write) line
that travels the control bus to the clock input of the D flip-flop. When the D flip-flop
receives the clock trigger pulse, it latches onto the data that are on the data bus at
that time and drives the LED’s.
Address Decoder
The address decoder is usually an octal decoder. Its function is to provide active-
LOW Chip Enables (CE) to the external IC’s based on information it receives from
the microprocessor via the control and address buses. Because there are multiple
IC’s on the data bus, the address decoder ensures that only one IC is active at a
time to avoid a bus conflict caused by two IC’s writing different data to the same
bus.
Software Control of Microprocessor Systems complished by applying the proper digital signal on one of the interrupt inputs:
INTR, RSTx.x, or TRAP. Serial communication capabilities are provided via the Sill
As a brief introduction to microprocessor software, let's refer back to Figure 1 and and SOD I/O pins (Serial Input Data, Serial Output Data).
learn the statements required to perform some basic input/output operations.
The register array contains the six general-purpose 8-bit registers and three 16-
To route the data from the input switches to the output LED’s, the data from the
bit registers. Sixteen-bit registers are required whenever you need to store ad-
input port must first be read into the microprocessor before they can be sent to the
dresses. The stack pointer stores the address of the last entry on the stack. The
output port. The microprocessor has an 8-bit internal register called the accumu- stack is a data storage area in RAM used by certain microprocessor operations.
lator that can be used for this purpose.
The program counter contains the 16-bit address of the next software instruction
The software used to drive microprocessor-based systems is called assembly lan- to be executed.
guage. The Intel 8080/8085 assembly language statement to load the contents of
The third 16-bit register is the address latch, which contains the current 16-bit ad-
the input port into the accumulator is LDA addr: LDA is called a mnemonic, an ab- dress that is being sent to the address bus.
breviation of the operation being performed, which in this case is "Load Accumu-
lator." The six general-purpose 8-bit registers can also be used in pairs (B-C, D-E, H-L)
to store addresses or 16-bit data.
The suffix addr will be replaced with a 16-bit address (4 hex digits) specifying the
address of the input port. After the execution of LDA addr; the accumulator will
contain the digital value that was on the input switches. Now, to write these data
to the output port, we use the command STA addr: STA is the mnemonic for "Store
Accumulator" and addr is the 16-bit address where you want the data stored.
Execution of those two statements is all that is necessary to load the value of the
switches into the accumulator and then transfer these data to the output LED’s.
The microprocessor takes care of the timing on the three buses, and the address
decoder takes care of providing chip enables to the appropriate IC’s.
If the system is based on Motorola or Zilog technology, the software in this case
will be almost the same.
Instruction Execution within a Microprocessor 5. The timing and control unit again issues a LOW pulse on the RD line. This
pulse will travel the control bus to the input port, causing the data at the input
Now, referring back to the basic I/0 system diagram of Figure 1, let's follow the flow port (4000H) to be put onto the external data bus.
of the LDA and STA instructions as they execute in the block diagram of the
8085A. Figure 2 shows the 8085A block diagram with numbers indicating the suc- 6. That data will travel across the external data bus in Figure 1, to the internal
cession of events that occurs when executing the LDA instruction. data bus in Figure 3, to the accumulator, where they are now stored.
Remember, LDA addr and STA addr are assembly language instructions, stored 7. The instruction is complete.
in an external memory IC, that tell the 8085A CPU what to do. LDA addr tells the
CPU to load its accumulator with the data value that is at address addr. STA addr
tells the CPU to store (or send) the 8-bit value that is in the accumulator to the out-
put port at address addr.
The mnemonics LDA and STA cannot be understood by the CPU as they are; they
have to be assembled, or converted, into a binary string called machine code. Bi-
nary or hexadecimal machine code is what is actually read by the CPU and passed
to the instruction register and decoder to be executed. The Intel 8085A Users Man-
ual gives the machine code translation for LDA as 3A16 (or 3AH) and STA as 32H.
Before studying the flow of execution in Figure 3, we need to make a few assump-
tions. Let's assume that the input port is at address 4000H and the output port is
at address 6000H. Let's also assume that the machine code program LDA 4000H,
STA 6000H is stored in RAM starting at address 2000H.
Load Accumulator
The sequence of execution of LDA 4000H in Figure 3 will be as follows:
1. The program counter will put the address 2000H on the address bus.
2. The timing and control unit will issue a LOW pulse on the RD line. This pulse
will travel the control bus to the RAM in Figure 1 and will cause the contents
at location 2000H to be put onto the external data bus. RAM (2000H) has the
machine code 3AH, which will travel across the internal data bus to the in-
struction register.
3. The instruction register passes the 3AH to the instruction decoder, which de-
termines that 3AH is the code for LDA and that a 16-bit (2-byte) address must
follow. Because the entire instruction is 3 bytes (one for the 3AH and two for
the address 4000H), the instruction decoder increments the program counter
two more times so that the address latch register can read and store bytes 2
and 3 of the instruction.
4. The address latch and address bus now have 4000H on them, which provides
the LOW for the input port in Figure 1.
Store Accumulator
Execution of the STA instruction within the 8085A.
1. After the execution of the 3-byte LDA 4000H instruction, the program counter
will have 2003H in it. (Instruction LDA 4000H resided in locations 2000H,
2001H, 2002H.)
2. The timing and control unit will issue a LOW pulse on the RD line. This will
cause the contents of RAM location 2003H to be put onto the external data
bus. RAM (2003H) has the machine code 32H, which will travel up the internal
data bus to the instruction register.
3. The instruction register passes the 32H to the instruction decoder, which de-
termines that 32H is the code for STA and that a 2-byte address must follow.
The program counter gets incremented two more times, reading and storing
bytes 2 and 3 of the instruction into the address latch.
4. The address latch and address bus now have 6000H on them, which is the
address of the output port in Figure 1.
5. The instruction decoder now issues the command to place the contents of the
accumulator onto the data bus.
6. The timing and control unit issues a LOW pulse on the WR line. Since the WR
line is used as a clock input to the D flip-flop of Figure 1, the data from the data
bus will be stored and displayed on the LED’s. (The WR line from the rnicro-
processor is part of the control bus in Figure 1.)
Programming a Microprocessor convert these program statements into assembly language. The assembler pro-
gram will then translate the assembly program further into machine code which
The microprocessor is driven by software instructions to perform specific tasks. can be "understood" by the microprocessor.
The instructions are first written in assembly language using mnemonic abbrevia-
tions and then converted to machine language so that they can be interpreted by Figure 5: Flowchart of the Down-Counter Program
the microprocessor. The conversion from assembly language to machine lan-
guage involves translating each mnemonic into the appropriate hexadecimal ma-
chine code and storing the codes in specific memory addresses. This can be done
by a software package called an assembler, provided by the microprocessor man-
ufacturer, or it can be done by the programmer by looking up the codes and mem-
ory addresses (called hand assembly).
Assembly language is classified as a low-level language because the programmer
has to take care of all the most minute details. High-level languages such as Pas-
cal, FORTRAN, BASIC and C, are much easier to write but are not as memory ef-
ficient or as fast as assembly language. All languages, whether Pascal, BASIC,
FORTRAN or C, get reduced to machine language code before they can be exe-
cuted by the microprocessor.
The conversion from high-level languages to machine code is done by a compiler.
The compiler makes memory assignments and converts the English-language-
type instructions into executable machine code.
On the other hand, assembly language translates directly into machine code. This
allows the programmer to write the most streamlined, memory-efficient, and fast-
est programs possible on the specific hardware configuration that is being used.
Assembly language and its corresponding machine code differ from processor to
processor. The fundamentals of the different assembly languages are the same.
Program Languages
The following example will show the different levels of microprocessor program-
ming. The comparison of each level of program language will help to understand
how software works. Therefore a simple program in assembly language will be
shown in Basic computer language and also in machine code.
Program Definition
The program that will be used as example will function as a down-counter, count-
ing 9 to 0 repeatedly. In a first step, a flowchart is drawn, shown in Figure 5, that
shows the program flow and makes it easier to understand what to program must
do and how this can be implemented as program code. The next step is to write
the program statements in a high level language like basic. The compiler will then
BASIC move the data value 09H into register A (register A and the accumulator are the
same).
BASIC uses the variable COUNT to hold the counter value. Line 30 checks the
count. If COUNT is equal to zero, then the program goes back to the beginning. The next instruction, DCR A, decrements register A by 1.
Otherwise, it goes back to subtract 1 from COUNT and checks COUNT again. The third instruction, JZ START, is called a conditional jump. The condition that it
The 8085A version of the program is first written in assembly language and then it is checking for is the zero condition. As the A register is decremented, if A reaches
is either hand assembled into machine language or it could be computer assem- 0, then a flag bit, called the zero flag, gets set (a set flag is equal to 1). The instruc-
bled using a personal computer with an assembler software package. tion JZ START is interpreted as "jump to statement label START if the zero flag is
set." If the condition is not met (zero flag not set), then control passes to the next
The same program in a more modern high level program language like C would
instruction,
look similar, but different instructions, specific to the program language would be
used. JMP LOOP, which is an unconditional jump. This instruction is interpreted as
"jump to label LOOP regardless of any condition flags." At this point you should
Assembly Language see how the assembly language program functions exactly like the BASIC lan-
guage program.
Assembly language is written using mnemonics: MVI, DCR, JZ, and the like. The
term mnemonics is defined as "abbreviations used to assist the memory." The first
mnemonic, MVI, stands for "Move Immediate." The instruction MVI A,09H will
Part No. Number of Bus Width Adressable Clock Cycle Rate Comments
Transistors Memory Space
4004 2’300 4bits 640 bytes 108 kHz 1971, First Microcomputer chip, Arithmetic manipulation
8088 29’000 8 bits 1 megabyte 5MHz, 8 MHz 1979, 10X the performance of the 8080
80286 134’000 16 bits 16 megabytes 6MHz, 8MHz, 1982, 8086 upgrade with extended addressing capability
10MHz, 12.5MHz
80386DX 275’000 32 bits 4 gigabytes 16MHz, 20MHz, 1985, First X86 chip to handle 32-bit data sets
25MHz, 33MHz
80486DX 1’200’000 32 bits 4 gigabytes 25MHz, 33MHz, 1989, Upgrade of the 386
50MHz
Pentium 3’100’000 64 bits 4 gigabytes 60MHz,66MHz 1993, Superscalar architecture brought 5x the performance of the 33-MHz Intel
486 DX processor
Pentium Pro 5’500’000 64 bits 64 gigabytes 150MHz, 166MHz, 1995, Dynamic execution architecture drives high-performing processor
180MHz, 200MHz
Pentium II 7’500’000 64 bits 64 gigabytes 200 MHz, 1997, Dual independent bus, dynamic execution, Intel MMX technology
233MHz, 266MHz,
300MHz
Pentium III 9’500’000 64 bits 64 gigabytes 450, 500, 550, and 1999, Advanced imaging, 3-D, streaming audio, video and speech recognition
600MHz applications. Enhance Internet experiences, allowing users to do such things
as browse through realistic online museums and stores and download high-
quality video.
Pentium 4 42’000’000 ? ? 1.8, 1.7, 1.6, 1.5, 2001, Possibility to create professional-quality movies; deliver TV-like video via
and 1.4 GHz the Internet; communicate with real-time video and voice; render 3D graphics
in real time; quickly encode music for MP3 players; and simultaneously run
several multimedia applications while connected to the Internet.