registers eliminates the need
to
"shuffle"
intermediate re-
sults back and
forth
between
memory
and
the
accumulator,
thus
improving processing speed
and
efficiency.
Program Counter (Jumps, Subroutines
and the Stack):
The
instructions
that
make
up
a program are stored
in
the system's memory.
The
central processor references
the
contents
of memory,
in
order
to
determine
what
action
is
appropriate. This means
that
the
processor must
know
which location contains
the
next
instruction.
Each
of
the
locations
in
memory
is
numbered,
to
dis-
tinguish it
from
all
other
locations
in
memory. The number
which identifies a memory location
is
called its Address.
The
processor maintains a
counter
which contains the
address of the
next
program instruction. This register
is
called
the
Program Counter.
The
processor updates
the
pro-
gram counter
by
adding
"1"
to
the
counter
each time it
fetches
an
instruction, so
that
the
program
counter
is
always
current
(pointing
to
the
next
instruction).
The
programmer
therefore
stores his instructions
in
numerically adjacent addresses, so
that
the
lower addresses
contain the first instructions
to
be executed
and
the
higher
addresses contain later instructions.
The
only
time
the
pro-
grammer may violate this sequential rule
is
when
an instruc-
tion
in
one section
of
memory
is
a
Jump
instruction
to
another
section of memory.
A jump instruction contains the address
of
the
instruc-
tion which
is
to
follow
it_
The
next
instruction may be
stored
in
any memory location, as long as
the
programmed
jump
specifies the correct address. During
the
execution
of
a
jump
instruction, the processor replaces
the
contents
of its
program counter with
the
address
embodied
in the
Jump.
Thus,
the
logical
continuity
of
the
program
is
maintained.
A special kind
of
program
jump
occurs
when
the
stored
program "Calls" a subroutine.
In
this kind
of
jump,
the
pro-
cessor
is
required
to
"remember"
the
contents
of
the
pro-
gram counter
at
the
time
that
the
jump
occurs. This enables
the
processor
to
resume
execution
of
the
main program
when
it
is
finished with the last instruction
of
the
subroutine.
A
Subroutine
is
a program within a program. Usually
it
is
a general-purpose set
of
instructions
that
must
be exe-
cuted
repeatedly
in
the
course
of
a main program. Routines
which calculate the square, the sine, or
the
logarithm
of
a
program variable are good examples
of
functions
often
written
as subroutines.
Other
examples might be programs
designed for inputting
or
outputting
data
to
a particular
peripheral device.
The
processor has a special way
of
handling sub-
routines,
in
order
to
insure an orderly return
to
the main
program. When
the
processor receives a Call instruction, it
increments
the
Program
Counter
and stores
the
counter's
contents
in
a reserved
memory
area known as
the
Stack.
The
Stack
thus
saves
the
address
of
the
instruction
to
be
executed
after
the
subroutine
is
completed.
Then
the
pro-
1-2
cessor loads
the
address specified
in
the
Call into its Pro-
gram Counter.
The
next
instruction
fetched
will
therefore
be
the
first step
of
the
subroutine.
The last instruction
in
any
subroutine
is
a
Return.
Such
an instruction need specify no address. When
the
processor
fetches a Return instruction, it simply replaces
the
current
contents
of
the
Program
Counter
with
the
address
on
the
top
of
the
stack. This causes
the
processor
to
resume execu-
tion
of
the
calling program
at
the point immediately
foLlow-
ing
the
original Call Instruction.
Subroutines
are
often
Nested;
that
is,
one
subroutine
will sometimes call a second subroutine.
The
second may
call a third,
and
so on. This
is
perfectly acceptable, as long
as
the
processor has enough capacity
to
store
the
necessary
return addresses,
and
the
logical provision
for
doing so.
In
other
words,
the
maximum
depth
of
nesting
is
determined
by
the
depth
of
the
stack itself.
If
the
stack has space for
storing
three
return addresses,
then
three
levels
of
subrou-
tines may
be
accommodated.
Processors have different ways
of
maintaining stacks.
Some have facilities for
the
storage
of
return addresses built
into
the
processor itself_
Other
processors use a reserved
area
of
external
memory
as
the
stack
and
simply maintain a
Pointer register which contains the address
of
the
most
recent stack
entry.
The
external stack allows virtually un-
limited subroutine nesting.
In
addition, if
the
processor pro-
vides instructions
that
cause the
contents
of
the
accumulator
and
other
general purpose registers
to
be
"pushed"
onto
the
stack or
"popped"
off
the stack
via
the
address stored
in
the
stack pointer, multi-level
interrupt
processing (described
later
in
this
chapter)
is
possible. The
status
of
the
processor
(i.e.,
the
contents
of
all
the
registers) can be saved
in
the
stack
when
an
interrupt
is
accepted
and
then
restored
after
the
interrupt
has been serviced. This ability
to
save
the
pro-
cessor's
status
at
any
given time
is
possible even if an inter-
rupt
service routine, itself,
is
interrupted.
Instruction Register
and
Decoder:
Every
computer
has a Word Length
that
is
characteris-
tic
of
that
machine. A
computer's
word length
is
usually
determined
by
the
size
of
its internal storage elements
and
interconnecting paths (referred
to
as Busses);
for
example,
a
computer
whose registers
and
busses can store
and
trans-
fer 8 bits
of
information has a characteristic
word
length of
8-bits
and
is
referred
to
as an 8-bit parallel processor. An
eight-bit parallel processor generally finds it
most
efficient
to
deal
with
eight-bit binary fields, and
the
memory
asso-
ciated
with
such a processor
is
therefore organized
to
store
eight bits
in
each addressable memory location. Data
and
instructions are
stored
in
memory
as eight-bit binary num-
bers,
or
as numbers
that
are
integral multiples
of
eight bits:
16 bits,
24
bits, and so
on.
This characteristic eight-bit field
is
often
referred
to
as a Byte.
Each
operation
that
the
processor can
perform
is
identified by a unique
byte
of
data
known
as an Instruction