This is only a preview of the June 1988 issue of Silicon Chip. You can view 40 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Articles in this series:
Items relevant to "Studio 200 Stereo Control Unit":
Articles in this series:
Articles in this series:
Articles in this series:
|
DIGITAL
FUNDAMENTALS
We get into the heart of the microcomputer to
discover what makes it tick.
LESSON 8: INTRODUCTION TO MICROCOMPUTERS
By Louis E. Frenzel
AS YOU HAVE SEEN in previous lessons, digital circuits are a collection of gates and flipflops wired
together to accept binary inputs from some source,
process them, and generate one or more new outputs
that will perform some useful function. There is nearly
an infinite variety of ways that the various logic
elements can be interconnected to process the inputs.
The process itself may be nothing more than simple
decoding or multiplexing performed by a combinational circuit. Or the circuit may be the more complex
sequential type that performs various timing and sequencing operations. In either case, as shown in Fig.1,
we can represent the circuit with a "black box."
The inputs can come from a variety of sources: from
a keyboard, switches of one type or another,
transducers that sense various physical values, or
binary information from some other piece of equipment that may be under test, evaluation or analysis.
The outputs may operate displays such as LEDs, LCDs
or CRTs; or drive actuators such as relays, solenoids
or motors. Or they may simply be binary words that
will be transferred to another piece of equipment for
storage or further manipulation.
So far, we have assumed that the digital circuits
would be made up of individual integrated circuits:
gates, flipflops, functional MSI (medium scale integration) circuits, PLAs (programmable logic arrays), or
other LSI or VLSI circuits. The circuit may be combinational, sequential, or a mix of the two. However,
there is an option to using conventional logic circuits,
and that option is called a microcomputer.
In this lesson, we are going to discuss microcomputers and show how they can be used to replace
large collections of more conventional digital !Cs connected to form a custom circuit for some dedicated ap86
SILICON CHIP
plication. In subsequent lessons, we will cover
microcomputer input/output techniques and programming.
What is a Microcomputer?
A microcomputer is a miniature digital computer
made with an LSI (large scale integration) circuit,
which contains most of the circuitry ordinarily
associated with a digital computer. This special LSI
circuit is known as a microprocessor. We will speak
more about microprocessors in just a minute, but first
let's talk about digital computers in general.
A digital computer is an electronic device that processes data. Data, of course, refers to binary words or
numbers to be used in calculations, or information
that must be stored or retrieved, such as ASCII text.
Or the data may be simply random collections of
binary signals that represent input information that
must be processed in some way.
Processing refers to the way data is manipulated. In
its simplest form, processing may simply refer to the
storage and retrieval of the data. Other kinds of processing might be mathematical operations, like addition or subtraction, or logical operations such as AND,
OR, XOR and inversion. Processing may also mean
Fig.1: when we are interested primarily in input and
output signals, we can use a "black box" to represent
some kind of digital circuit, combinational or sequential,
that processes the inputs to generate new outputs.
operations such as searching, sorting, editing or pattern matching.
Digital circuits, as we have defined them in this
series, meet this definition because they process data,
and they may be designed to perform any of the abovementioned functions. Although a digital computer can
perform the same functions, it does so in a different
way. The key element in the definition of a digital computer is that the processing or manipulation takes
place automatically. The digital computer is set up by
programming, which specifies the way in which the
data is going to be processed. We can accomplish our
processing objective by replacing the black box in
Fig.1 with a digital computer. The processing is
automatic and preprogrammed.
Classifying Digital Computers
There are three basic types of digital computers:
mainframes, minicomputers and microcomputers.
Mainframes are the large computers used in business
and government for large data processing tasks: they
are used for financial and accounting systems,
storage, retrieval and manipulation of customer credit
files, airline reservations, and the like. Mainframes
are super fast in their processing and store enormous
amounts of data.
Minicomputers are smaller than mainframes but
are still very large and powerful. Because of their
very high speed, they are generally associated with
problem-solving in scientific and engineering applications. However, they are also used for business data
processing and other functions.
Microcomputers are the smallest classification of
digital computers. They are low in cost and small in
size. The most visible type is the personal computer
which is used for a wide variety of data processing
operations.
The type of microcomputer we are most interested
in, for the purpose of this series, is a special version usually ref erred to as a dedicated controller. This
type of microcomputer is designed to perform a
specific function. Unlike a personal computer, it is not
general purpose in nature and cannot be used with a
variety of software packages. Instead, this kind of
microcomputer is built into the piece of equipment and
is difficult to distinguish from the hardware itself. It is
simply the control circuitry for the equipment that
happens to be implemented by the microcomputer.
In other words, the microcomputer replaces conventional logic circuitry that otherwise would have been
implemented with individual gates, flipflops and MSI
circuits. Dedicated microcomputer controllers are
found in all kinds of equipment, such as TV sets, stereo
hifi systems, auto dashboards and emission control
systems, photocopiers, and so on.
In any case, the key distinguishing characteristic
of a microcomputer is that it is implemented with a
special LSI device known as a microprocessor.
Digital Computer Organisation
As shown in Fig.2, a digital computer is made up of
four basic sections: the memory, the control section,
r
CENTRAL PROCESSING UNIT (CPU~
I
_ _ _ _ _..;.,__
MEMORY
II
CONTROL
I.......,,._..,......
I
I
________
! _
.._
I
I
I
I
I
INPUT/OUTPUT
(l/0)
I
ARITHMETIC/LOGIC
SECTION
l... - - - - - - _.ll-----t'\.
"-r------,1'
I
I
_J
DATA
SIGNALS
TO EXTERNAL DEVICES
TO BE CONTROLLED OR
MONITORED
Fig.2: regardless of its type, a computer is made up of
four sections - the memory, a control section, an
arithmetic/logic unit, and an input/output unit. The
control section can be a central processing unit (CPU),
or a microprocessor.
the arithmetic logic unit, and the input/output unit.
Let's take a brief look at each of these sections.
Memory
The memory in a microcomputer is usually a combination of both RAM and ROM (see Lesson 7 in this
series). This memory is used to store two types of information: data and instructions.
Data represents those binary numbers or words
that are to be processed. They may be numerical
values, ASCII codes for the text of a written document,
or simply random collections of binary signals that
represent inputs or outputs that are collected and
organised as binary words. In any case, it is the data
words stored in the memory that will be manipulated
by the computer.
Instructions, which are stored in either RAM or
ROM, are unique to computers. They are special
binary codes that tell the computer how to manipulate
the data. For example, an instruction may be an 8-bit
binary number. With eight bits, 256 different instructions could be represented, which might specify
arithmetic operations such as addition and subtraction, a logical operation such as AND or XOR, or data
movement operations that cause binary words to be
moved into or out of memory or cause transfers between registers.
All computers have a special repertoire of these
special codes known as an instruction set. They define
the architecture of the computer and provide a wide
range of ways in which the data can be manipulated.
To process data, a number of instructions are written sequentially and stored in memory. Such a sequential list of instructions is called a program. A program
defines a specific sequence of operations that process
the data in some way. The purpose of the computer is
to sequentially interpret and execute these instructions stored in memory and this, in turn, accomplishes
the processing.
JUNE 1988
87
This approach to digital processing is generally
known as the stored program concept. It was invented
by mathematician John Von Neumann and is the basis
of operation for all digital computers.
Control
The control section of the digital computer fetches
the instructions stored in memory one at time, interprets them, and executes them in sequence. The control unit gets one instruction from memory, decodes it
and determines which function is to be performed
next. It then issues control signals to the other sections
of the computer so that the specified operations are
carried out.
Arithmetic-Logic
The arithmetic/logic section is the section of the
digital computer that generally carries out most processing operations. It is usually made up of a set of
registers where the data to be manipulated is temporarily stored. In turn, these registers drive an
arithmetic/logic unit (ALU), which is a collection of
logical circuits which perform mathematical and
logical operations. Serial shift and rotate operations
can also be performed. It is usually the ALU that
receives signals from the control unit to perform the
operation specified by the instruction.
As shown in Fig.2, the control section and ALU are
closely related and interconnected. For the most part,
they can be treated as a single block or section. The
combination is usually called a central processing unit,
or CPU. A microprocessor is simply a single-chip LSI
CPU, which is sometimes referred to as a
microprocessing unit, or CPU.
How a Microprocessor Works
Fig.3 shows a block diagram of a microprocessor.
This has has been divided into two primary sections:
the arithmetic/logic section and the control section.
The control section of the CPU contains the instruction register and the program counter. The program
counter holds the address of the memory location
where an instruction is stored. To execute a program,
the program counter is set to the address of the first
instruction in the program. The content of the program
counter (ie, the instruction address) is then transferred to an address register in memory. The address
location is decoded (usually on the RAM or ROM
chips) and that location in memory is enabled.
The instruction stored there is transferred over the
data bus into the instruction register. The instruction
decoder looks at the instruction word and identifies
the function to be performed. The timing and control
circuits in the control section then generate the apDATA/INSTRUCTIONS
TO/FROM MEMORY
r-----------
---7
I
I
PROGRAM COUNTER
I
I
I
CONTROL SECTION
A Typical Microcomputer
The typical microcomputer consists of a single chip
microprocessor, a set of RAM chips, and one or more
ROMs that contain a dedicated control program. The
input/output section is usually made with integrated
circuits which have been specifically designed to interface the microcomputer to the external circuits or
equipment involved in the application.
For small, dedicated applications, single-chip
microcomputers can be used. These devices contain
the CPU, the ROM where the dedicated control program is stored, a small amount of RAM where data
can be stored temporarily, and a variety of input/output circuits, which connect to the equipment being
controlled. A good example of an application is the
microcomputer used in most printers.
SILICON CHIP
I
I
TIMING AND
CONTROL CIRCUITS
The input/output (1/0) section of a digital computer
is used to communicate with external circuits and
equipment. Inputs to be processed are fed to the 1/0
section and either stored in memory or processed
directly by the CPU. Binary words that are to be
transferred to some external circuit or device are
transferred from the memory or the CPU to the external equipment via the 1/0 section.
As you might expect, special input/output instructions to the CPU are used to control the 1/0 section.
I
I
1/0
88
ADDRESS TO
MEMORY
I
I
I
CONTROL SIGNALS TO
ALL OTHER SECTIONS
I
r--------------1
I
I
- - -..✓
I ---II ...'"'ft"-~-
I
I
ALU
II
I
____
I
II
II
---ARITHMETIC-LOGIC SECTION
JI
L....---------------
Fig.3: a CPU generally provides two independent
functions - a control section and an arithmetic/logic
unit which are interconnected through an external
data bus.
propriate control pulses that cause the desired action
to be carried out. Once the instruction has been executed, the program counter is incremented so that
the next instruction in sequence is fetched and executed. This process continues until the program is
fully executed.
The arithmetic/logic section of the computer consists of a main working register called the ac-
16-BIT REGISTERS
8-BIT REGISTERS
16-BIT REGISTERS
8-BIT REGISTERS
PROGRAM COUNTER
ACCUMULATOR A REGISTER
PROGRAM COUNTER
ACCUMULATOR REGISTER
INDEX REGISTER
ACCUMULATOR B REGISTER
INDEX REGISTER X
INSTRUCTION REGISTER
STACK POINTER
INSTRUCTION REGISTER
INDEX REGISTER Y
STATUS REGISTER
CONDITION CODE REGISTER
STACK POINTER REGISTER
6502
6800
(b)
(a)
Fig. 4: although there are differences in the internal architecture of the 6800 and 6502,
both use the program counter to point to the next instruction in sequence.
cumulator and the arithmetic/logic unit (ALU). The
arithmetic/logic section carries out most of the operations designated by the computer's instruction set. All
data transfers and arithmetic/logic operations take
place in the accumulator.
Most arithmetic and logic operations involve two
operands. (Operand is just the name of a number to be
involved in an arithmetic or logic computation). For
example, an add operation involves the two numbers
to be summed. One of the operands is stored in the accumulator while the other is stored in memory. The
lwo operands are then used in the desired operation.
The result of the operation, in this case the sum, is
stored back in the accumulator. The operand
previously stored in the accumulator is lost.
The ALU in most microprocessors is capable of carrying out addition and subtraction as well as the basic
logic operations AND, OR, XOR, and complement. Other
instructions are used to manipulate data in the accumulator. For example, the accumulator can be
cleared (set to zero), incremented, or decremented.
Data can also be transferred from a desired memory
location to the accumulator or taken from the accumulator and stored in a desired memory location.
The arithmetic/logic section also permits data in the
accumulator to be shifted or rotated to the right or to
the left of a given number of bit positions.
Typical Microprocessors
Now let's look at a real microprocessor: in fact , we
will examine two units which are similar in architecture and design. The first is the 6800 which, although
introduced in the mid-1970s, is still in use today. The
16800 was used in some of the earliest personal computers, among them the MITS Altair 680, Southwest
Technical Products SWTP 6800, and the Wavemate,
but it has now virtually disappeared in this application. However, the 6800 is still widely used as a
dedicated controller.
The other microprocessor we will look at is the
6502. This CPU was designed by the same group that
created the 6800. They left Motorola and developed
the 6502 for MOS Technology. The 6502 is an improved or optimised version of the 6800. It too was widely
used in personal computers and is still used in personal computers such as the Apple Ile/c and Commodore 64/128.
Both the 6800 and 6502 have an architecture and
operation that is simple and straightforward. In fact,
they are essentially the same as the generic
microprocessor described earlier.
The 6800 and 6502 are 8-bit microprocessors (all
microprocessors are rated or ranked by the basic
number of bits they process simultaneously). That is,
data transfers and arithmetic or logic operations are
made on parallel 8-bit binary numbers or words. The
6800 and 6502 have 8-bit internal registers, an 8-bit
ALU and an 8-bit data bus through which all data
transfers between CPU, memory and I/O take place.
A general block diagram of each of these
microprocessors is shown in Fig.4. Note that only the
main registers are shown. These will be explained
next.
CPU Registers
The most predominant circuit in a micro (short for
microprocessor) is the register, which is capable of
storing one binary word. As the data and instruction
words are moved from one place to another they are
typically passed through or temporarily stored in the
various registers. As data is processed, words are
transferred into and out of these registers from external sources such as the memory and I/O devices. In addition, inter-register transfers in the micro also occur
during processing.
All micros have three basic registers: the program
counter (PC); the instruction register (IR) and the accumulator (ACC). Fig.4 shows the register structure
for the 6800 and 6502. Let's look at each.
Program Counter
The program counter (PC) contains the address of
the next instruction to be fetched. As each instruction
in a program is fetched and executed, the program
counter is incremented so that it points to the next instruction in the sequence. The program counter also
specifies how many bytes of RAM and ROM a CPU can
address. The PC's output is sent to the memory where
it selects a desired word. In the 6800 and 6502. the PC
holds a 16-bit word, therefore, 216 or 65,536 (64K)
words of RAM and/or ROM can be addressed.
Instruction Register
When the CPU fetches an instruction word from
memory to be executed, that word is stored in the inJU NE 1988
89
struction register (IR). The word is then decoded to
determine which operation is to be performed. In the
6800/6502, the instruction register holds an 8-bit instruction word or an op code as it is called.
Accumulator
The accumulator is the basic processing register of
the micro. Words to be used in arithmetic or logic
operations are stored here. Data transfers to or from
memory and input/output devices are also passed
through the accumulator. Not surprisingly, the accumulator size in the 6800 and 6502 is 8-bits.
While all micros contain at least one accumulator
register, some have more than one. By using more than
one accumulator significant increases in speed can be
achieved. Also, programs written for multiple accumulator machines typically involve fewer instructions and less programming effort, which significantly
improves use of the available memory space. The 6800
has two accumulators, the 6502 has one. Some CPUs
have sets of 8 or 16 accumulators usually called
general-purpose registers.
All micros feature these basic registers but they
also feature additional registers, which further improve operations. Some of these are as follows.
Index Register
An index register stores a binary word that is used
in address-modification operations. Typically, the content of the index register is added or subtracted from
the address associated with an instruction. The index
register content can be loaded from memory, stored in
memory, incremented, or decremented with special index register instructions.
This process of using an index register for address
operations is called indexing. By using an index
register, the number of instructions used in some programs can be significantly reduced. This is particularly true where sequential operations on a list or table of
Mailbag
continued from page 3
conductor. This arrangement has
been prohibited by AS 3000 for some
12 years. The standard now requires
that the main earthing conductor be
run directly to an earth electrode.
Where the water piping is
metallically continuous from inside a
building to the point of contact with
the ground, such piping must be connected by an equipotential bonding
conductor to the main earthing conductor. With the increasing use of
non-metallic water piping, this bonding may not be necessary.
• You refer to the fact that some
current flowing to earth will do so via
the earth electrode and water pipe as
a "previously unconsidered fact".
This is simply not true. The advantages and disadvantages of the MEN
90
SILICON CHIP
data are to be performed. The 6800 has one 16-bit index register, the 6502 has two.
Status Register
The status or condition-code register is a group of
flipflops that are either set or reset - depending upon
the outcome of processing operations in the ALU. As
arithmetic, logic or shift operations are performed,
the various status flipflops are set or reset to indicate
a specific machine state. The status word may be
monitored and stored so that the condition of the computer at a given time can be determined.
The various flipflops in the status word can also be
tested under program control so that the program being executed can be modified. Jump or branch conditions that change the program sequence are usually
determined by the information stored in the status
register.
Some of the conditions monitored by the conditioncode register are arithmetic operations, such as: accumulator equals zero, carry out of the most significant bit of the accumulator, accumulator overflow,
and accumulator negative. In the 6800 and 6502, the
status or condition code register contains eight bits.
Stack Pointer
The stack pointer is a 16-bit address register that is
used to reference some particular part of the. micra's
random-access memory. The stack itself is a specific
portion of memory set aside to temporarily store data
in a particular sequence. The stack pointer is used to
address this data when it is being stored or retrieved.
The stack is set aside especially for stack operations and is not used to store ordinary sequences of instructions or data. Nor does it have a fixed size. The
number of memory locations used by the stack
depends upon how it is used.
The stack is a last-in, first-out (LIFO) memory. The
data words to be stored in the stack are written and
system are well understood by both
SAA Committee EL/1, who are
responsible for AS 3000, and the
Electricity Supply Association of
Australia. Every method of earthing
has such advantages and disadvantages and is a point which would be
conceded by supply authorities
throughout the world.
• Connections between an earth
bonding clamp and an earth electrode may be subject to corrosion as
you suggest. However, such connections, where exposed to weather, are
required to be suitably protected.
Also, the standards for household appliances that are likely to produce DC
current, such as TV sets, hair dryers,
and the like, have requirements
which limit the amount of current
that can be injected into the
household wiring.
Based on feedback from the elec-
trical contracting industry and supply authorities, it is suggested that corrosion of an extent likely to degrade
electrical safety is not a common
occurrence.
• While a warning is included in the
article to point out that unlicenced
persons should not tamper with any
wiring, I would like further warning
against the practice you describe and
picture concerning the 3-core extension cord. Removal of the sheathing of
a flexible cord to expose single insulated cable and then to further
tamper with such wiring is not a
practice which could be recommended.
I hope these points have clarified
some aspects of modern wiring
arrangements.
J. C. Tinslay
Executive Officer
Standards Association of Australia
OP CODE
OP CODE
HALF OF ADDRESS
OP CODE
ADDRESS OR DATA
HALF OF ADDRESS
(a) SINGLE WORD
(b) TWO WORO
(c) THREE WORD
Fig.5: the number of 8-bit (byte) instruction words
depends on the particular computer. A one-byte word
provides only the op code. A two-byte word provides
the op code and an address or operand to be processed.
A three-byte word provides both the op code and a
16-bit address.
retrieved sequentially so that the last item stored is
the first item to be retrieved; the first data item stored
will be the last retrieved.
The stack pointer register is used to determine the
limits of the stack and to identify specific word locations in the stack. In the 6800 and 6502, the stack
pointer register is 16-bits, and it can point to any one
of 65,536 different memory locations. This means that
the stack can be located anywhere within the maximum addressing range of the microprocessor.
To set up the boundaries of the stack, the stack
pointer register is usually loaded under program control with special instructions used for this purpose.
Once the stack pointer has been initialised, it is then
incremented or decremented to access sequential
memory locations. Stack, store and retrieve operations are called push and pull (or pop) respectively.
The Instruction Set
The instruction set is the complete list of instructions that a micro is capable of executing. The programmer uses the instruction set to develop complete
programs that perform a desired process, calculation,
or control function.
It is the instruction set that really defines the architecture of a micro. It specifies the number and
types of registers and the logic circuits and how they
are all interconnected. The instruction set for each
micro is fixed and is unique to that device.
Types of Instructions
Two types of instructions are used in microprocessors: memory-reference and non-memory
reference. A memory-reference instruction identifies
some particular memory location where the operand
to be used by that instruction is stored. The instruction
usually contains an address that designates the location of the operand. For example, an ADD instruction
contains an address that points to one of the operands
to be added. The other operand is usually in the
accumulator.
A non-memory reference instruction does not have
an address associated with it. This type of instruction
simply defines a type of operation to be performed
somewhere in the computer. The location of any data
to be used, if any, is usually in a CPU register.
Instructions are further classified by the types of
operations they perform. Some specific types are
listed below.
Data Movement Instructions - specify data
transfers from one location to another. The transfers
can take place between internal registers or between
the internal registers and the computer's memory.
Arithmetic/Logic Instructions - identify unique
arithmetic and logic operations such as add, subtract,
logical AND, compare, or other operations. Data shift
and rotate operations are usually included in this
class of instructions.
Decision-Making Instructions - test for certain conditions in the machine and cause the sequence of the
program to be modified. If the test condition is met, the
operation specified by the instruction is performed or
otherwise the next instruction in sequence is executed. Usually, the operation is a jump or branch
operation that causes the micro to begin executing a
sequence of instructions different from the normal sequence specified by the program.
Such instructions allow the micro to make decisions
based on conditions that exist in the CPU or external
circuits.
Input/Output Instructions - cause data transfers to
take place between the CPU and the I/O interface. Instructions for handling interrupts are usually included
in this instruction class. Not all microprocessors have
I/O instructions. For example, the 6800 and 6502 do
not have I/O instructions as such; they simply use the
data movement instructions to enable data transfers
to external devices and circuits.
Instruction-Word Formats - all microcomputers
have a basic fixed word length. The 6800 and 6502
both feature an 8-bit word. The memory is organised
as many sequential storage locations for 8-bit words.
These words (bytes) may be data or instructions.
Usually, data words are eight bits or less in length.
However, this limits the number size to a maximum of
255; additional memory locations may be allocated if
greater number sizes are required. For example, two
sequential memory locations can be used to store a
16-bit word, thereby increasing the number size up to
32,767. (One-half of the word would be stored in each
of the two adjacent memory locations). However, keep
in mind that the micro will only process eight bits of
data at a time.
Instruction words are similar. Some instructions
can be defined by a single 8-bit word. Others require
two or three sequential 8-bit words. Fig.5 shows the
three most commonly used instruction word formats.
In Fig.5a, a single 8-bit word defines an instruction.
This byte usually contains the op code - a specific bit
pattern that causes some unique operation to take
place. Such single word instructions are usually nonmemory reference instructions since they do not contain an address.
Fig.5b shows a two-byte instruction. The first eight
bits define the op code. The second 8-bit word in an
adjacent memory location usually contains an address
of the operand to be processed. When the instruction
is executed, the operand stored in the second word
location is used. If the second word is an address, it
references some location in memory where the
operand is stored.
Fig.5c shows a three-byte instruction. As usual, the
JUNE 1988
91
first 8-bit word contains the op code while the next
two 8-bit words contain a 16-bit address which identifies the memory location where the operand is
stored.
MICROPROCESSOR
(CPU)
Addressing Modes
Another important part of the architecture of a
micro is the way that it addresses data or instruction
words. The more different ways that memory words
can be referenced, the more powerful and flexible the
micro is. Many of the addressing modes greatly speed
up and simplify the processing operations.
The following addressing modes are used in most
micros, including the 6800 and the 6502.
Implied
No specific address is used with implied addressing;
instead, the location of the operand to be used in the
processing is implied by the instruction itself. Implied
addressing is used with non-memory reference locations. With these instructions, the operand is usually
stored in a register that is the subject of the given instruction. For example, accumulator increment,
decrement, or shift instructions imply that the operation is to take place on the operand stored in the
accumulator.
Immediate
Immediate addressing assumes that the operand is
contained within the instruction itself, usually as the
second byte of a two-byte instruction word. With this
arrangement, the operand is available immediately
for processing, thereby eliminating the need to address memory and to perform a read operation prior
to executing the instruction. Immediate instructions
are used to speed up computation.
Direct
When the direct addressing mode is used, the address bits are a part of the instruction word. The adADDRESS
14 (DATA)
ADD INSTRUCTION
63 (DATA)
STA INSTRUCTION
HALF OF ADDRESS
HIIIII} =
HALF OF ADDRESS
H111111
16-BITS
1111111111111111
65535
""' ~ 1 - - - - - ~
Fig.6: the microprocessor communicates with the
memory and input/output functions through a data bus,
an address bus and a control bus. The control bus
provides the functions other than data transfers and
memory addressing.
92
SILICON CHIP
dress may be simply the second 8-bit byte of a 2-byte
instruction, or it may be defined as the second and
third bytes of a 3-byte instruction.
Direct addressing is the simplest and most intuitive
of all the address modes, and is the one most often used. Remember, the total number of address bits determines the maximum number of memory locations that
can be referenced. In the 6800 and 6502, the address
word size is 16 bits, thereby permitting a total of
65,536 words (64K bytes) to be addressed. Direct addressing is sometimes referred to as absolute
addressing.
Register
In register addressing, the op code specifies a
register where the operand is stored.
Register Indirect
In this address mode, the instruction op code
specifies a register that contains the address of the
operand. This register must be loaded with the proper
memory address prior to executing the instruction.
Relative
RAM
LOA INSTRUCTION
4
TO EXTERNAL
Fig.7: program instructions for the computer are stored
in memory in sequential order. An individual address
might contain an op code, a data value, or another
address where the program stores or retrieves data.
In the relative addressing mode, the effective address of the operand to be used by the instruction is
obtained by adding the direct address in the instruction word itself to the contents of the program counter.
The address in the instruction word is used to specify
a displacement from the address of the instruction
currently being executed. (This address is contained
in the program counter).
This method of addressing permits the program and
the associated data to be relocated anywhere in
memory without changing the direct addresses in the
program. The relocation of the program is simply a
matter of adjusting the value of the program counter.
Indexing
Indexing or indexed addressing was discussed
earlier in connection with the index register. As you
may recall, the effective address designating the
storage location of the operand is formed by adding
the address in the instruction word to the contents of
The microprocessor, or MPU, is just a CPU. To form
a complete computer, memory, I/O and other circuits
must be added.
The MPU is usually indicated as a single box, as
shown in Fig.6. The MPU communicates with the other
circuits by way of many input and output lines. These
lines are typically organised as buses. For example,
all 8-bit data transfers into and out of the MPU take
place over the data bus. [The data bus is eight lines
over which data can travel in either direction).
Another group of 16 lines on the MPU forms the address bus. An address from the program counter or
other source in the MPU is put on the bus and sent to
RAM, ROM, or an I/O device. The address identifies
and enables a memory location or I/O circuit which
will accept data from or send data to the MPU.
The remaining lines of the MPU are collectively
known as the control bus. These input and output
signals are used to control MPU operation.
value (14) to be transferred to the accumulator. This
instruction uses immediate addressing.
Locations 2 and 3 hold an add [ADD) instruction.
Byte 2 is the op code, while byte 3 is the data word (63)
to be added to the value in the accumulator.
Locations 4, 5 and 6 hold a store [ST A) instruction.
Byte 4 is the op code, while bytes 5 and 6 form a 16-bit
address that tells where in RAM the contents of the
accumulator will be stored.
To start the program, the program counter - the
PC - is loaded with O so that it will access the first instruction in the program. Byte O is loaded into the instruction register and decoded. The PC is incremented
and the data in byte 1 is loaded into the accumulator.
The PC is now incremented again and the ADD instruction is fetched from byte 2 and put into the instruction register. After decoding, the PC is incremented and the data in byte 3 is accessed, then added by the ALU to the data word in the accumulator.
The sum 77 then appears in the accumulator.
The PC is then incremented again to fetch the STA
instruction in byte 4. The op code is loaded into the instruction register. Next, the PC is incremented twice
to bring in bytes 5 and 6. Together they form a 16-bit
address [65 ,535) that is sent to the RAM instead of the
PC content. This enables the selected RAM location.
The sum in the accumulator is sent via the data bus to
this location. The program ends at this point.
Executing a Program
The Next Lesson
the index register. Index registers can be loaded,
stored, incremented, or decremented by using special
index-register instructions. In addition, the contents of
the index register may also be tested by decisionmaking instructions.
Making a Microcomputer with a
Microprocessor
To complete our discussion of microprocessor
operation, let's take a look at how a 6800 or 6502
would execute a simple program. Refer to Fig.7. This
shows several bytes of RAM where the program is
stored. In memory locations O and 1, a load accumulator [LDA) instruction is stored. The first byte
contains the op code, the second contains the data
In the next lesson we will cover I/O operations.
Then, in the final lesson, we will examine other 6800
and 6502 instructions and show you the processes used to create programs that perform a variety of
functions.
~
Reproduced from HANDS-ON ELECTRONICS by arrangement. Copyright (c) Gernsback Publications, USA.
SHORT QUIZ ON DIGITAL FUNDAMENTALS 1. A microprocessor is an LSI _ _ _ _ _ _ __
2. The four major parts of a digital computer are:
a.
b.
c.
d.
LESSON 8
8. An area of RAM used to temporarily store data
is called the _ _ _ . The register that contains the
address of this area is called the _ _ _ _ __
9. The address of the operand to be used in a
computation is usually contained within the _ __
3. A CPU is made up of the _ _ _ _ _ section
and the _ _ _ _ _ _ section.
10. A microcomputer that replaces conventional
logic circuits in performing a specific function is
often called a ______________
4. The two kinds of information stored in a
computer memory are ___ and _ _ _ words.
11 . Communication with the world external to a
microcomputer takes place via the _ _ _ section.
5. A program is a sequential list of ______
that performs a specific function.
6. The main processing register in a CPU is the
7. The register that points to the next instruction
to be fetched and also deterrnJnes maximum
memory size is called the __________
ANSWERS
0 /1 . ~ ~
Je110Jiuo:> pere:>1pap ·o ~
uo1pnJisu1 ·6
J8lU!0d >PBlS ')1:>BlS ·g
Jaiuno:> weJ5oJd · L
JOre1nwn:>:>e ·9
suo1pnJisu1 ·g
SU0!PnJlSU! 'BlBP ·17
:>!50f/:>!I8Wl.fl!JB 'I0JlU0:> '8
0/1 ·p
:>!50i/:>!l8Wl.fl!JB ·:>
!0JlU0:> ·q
A.Jowaw ·e
l!Un 6u1sse:>0Jd IBJlU8:) · ~
·z
JUNE 1988
93
|