Alto Hardware Manual Section
9:
Nuts and Bolts for the Microcoder
63
9.2
Microcode
Techniques
Which
Need Not Be Rediscovered
For
the most part, since the Alto
is
such a simple machine, writing Alto microcode is a straightforward
exercise in rule-following. However, during the course
of
writing the few-odd thousand microinstructions
which have ever been written by anybody for the Alto, a
few
microcoding techniques have emerged as
particularly ingenious or useful or both. They are recorded here for posterity.
The beginning microcoder is advised to acquire a copy
of
the standard microcode (AltoCodex.MU),
and
to study it carefully in conjunction with this manual. The knack comes easily.
9.2.1
Microcode
Subroutines
You have probably already noticed that that the Alto hardware does
not
provide
an
easy way
of
doing
microcode-level subroutine calls and returns. Several subroutine-call techniques have evolved. Two
of
these are used for
RAM-tO-ROM
subroutine calls,
and
these will be presented first.
PC
CALL
(used with
BLT,
BLKS,
MUL,
DIV,
BITBLT)
This call takes advantage
of
the assumption that nobody in his right
mind
would want the
emulator to execute in the non-memory
1/0
area from
177000B
to
177777B.
Therefore when
one
of
these
ROM
subroutines terminates, the R-register
PC
is
examined.
If
it is outside the range
177000B-177777B,
then control is passed to the beginning
of
the emulator'S main loop in the
ROM.
Otherwise, control
is
passed to location
PC
AND
777B
in
RAM
or
ROMI.
The bank
dispatched to
is
determined by the
SWMODE
rules described in section 8.4.
Warning: Some
of
these
ROM
subroutines modify
PC
during execution.
If
BLT
or
BLKS
or
BITBLT
is
terminated by an interrupt condition,
PC
is
decremented by 1 so
that
the instruction
can
be
resumed later.
If
a
DIV
is
successful,
PC
is
incremented by 1 to cause a skip.
REGISTER
CALL
(used with
RAMCYCX)
This call uses an R-register,
in
this case
CYRET
(R-register
5),
to dispatch into a table
of
successor
instructions. The cyclic shift subroutine, for example,
is
called from
six
places
in
the
ROM.
Each
of
these places sets
CYRET
to the index
of
its successor instruction in the return dispatch table
[O-
S],
and then dispatches into the cycle table beginning
at
1.0.
The successor corresponding to
RAMCYCX
dispatches into
RAM
or
ROMlusing the low-order
10
bits
of
the
PC
register, according
to the
SWMODE
rules described
in
section 8.4. .
IR
CALLS
These calls use the emulator'S
IR
register in various
ways:
some straightforward
and
some
devious. The main advantages
of
IR
calls are that
1)
several levels
of
return can be encoded into a single number, because
it
is
fairly easy
to dispatch on various parts
of
IR,
and
2) unlike R-registers,
IR
can be loaded in one microinstruction.
The most straightforward use
of
IR
is
dispatching on its low-order 8 bits using the
DISP
bus
source. Since
DISP
is a bus source
)3,
a constant may be "and-ed" onto
the
bus with
DISP,
allowing one to dispatch on sub-fields
of
DISP.