Addressing - RCA 1800 Operator's Manual

Cosmac development system ii
Hide thumbs Also See for 1800:
Table of Contents

Advertisement

i
CDS Resident Software Development Aids _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 53
The use of short hand mnemonics for the m-
structions and appending comments gives:
LDI
n
..
n
IS APPROXIMATELY THE
·
.
NUMBER
,PHI COUNTER
..
OF
256
LOOP PASSES BELOW
DEC COUNTER
.
.
REDUCE NUMBER OF PASSES
·
. REMAINING
DUMMY
DUMMY
· .
JUST TO WASTE TIME
· .
WASTE MORE TIME
GHI COUNTER .. SEE
IF COUNT HAS YET
..
REACHED
BNZ-,
HERE
EXIT INSTR
,
.
ZERO. LOOP IF NOT
·
.
TIME EXPIRED. GO ON
where LDI, PHI, DEC, GHI, and BNZ are
operation mnemonics standing for LOAD IM-
MEDIATE, PUT HIGH, DECREMENT, GET
HIGH, and BRANCH IF NOT ZERO, respectively,
Their equivalent hexadecimal codes (for example, 3A
for BNZ) can be found in.Appendix E and in the
User Manual for the RCA CDPI802 COSMAC
Microprocessor,
MPM-201. Each line is now
beginning
to
resemble
an
assembly
language
statement.
The last version illustrates two fundamental
properties of an assembly language - the use of
operation mnemonics and the use of comments.
An
assembler
is
designed
to
recognize
operation
mnemonics, which are much more descriptive to the
programmer, and to convert them into their hex-
adecimal code equivalents. In addition, an assembler
is designed to ignore comment text fields in
statements when it recognizes their existence. In the
program version above, every comment begins with a
.
double period ( .. ) and extends to the end of the line.
Comments are invaluable to the programmer because
they permit him to add documentation to a program's
statements.
Addressing
The next problem considered is that of assigning
addresses - specifically, the branch address in the
last instruction in the loop. Clearly, addresses which
are assigned depend on where the program will reside
in memory while it is executing.
li
it is assumed that
this location
i
not presently known absolutely
(for
example,
becau
e
lh routine's
exact
location
within a
larger
program may change), a labelling procedure
may be defined to replace the arrowed path shown.
Two examples are given below:
Example I)
LABEL: DEC COUNTER
BNZ LABEL
An
assembler permits locations within a program to
be
identified
by
English-like
symbols
(e.g.,
"LABEL:" above). Then any reference to a location
may be made by use of its label (e.g., "BNZ
LABEL"). The programmer is free to select almost
any sequence of up to 6 characters for each label.
Typically, he chooses a symbol which has some
logical meaning within the context of his program
(e.g., LOOP, DELAY, TESTI, SEARCH, etc.).
During the process of translating the program's
statements, the assembler keeps track of the ad-
dresses of all bytes it generates (starting from some
known address reference, such as zero). It uses an
internal location counter for this purpose. Whenever
it encounters a LABELed statement, it enters the
address of the instruction in a symbol table. All
references to that label may then be replaced with
appropriate address bytes.
Example 2)
BNZ*-m
An
assembler also normally permits addressing
relative to the position at which the reference is
found. The special symbol
"*,,
is meant to refer to the
address of this statement and m is a count of the
number of bytes from this point.
Two forms of symbolic addressing have been
defined: using a statement label or using the symbol
"*". One form of the program now becomes:
BEGIN: LDI
n
·
.
n
IS APPROXIMATELY THE
·
.
NUMBER
PHI COUNT
·
.
OF
256
LOOP PASSES BELOW
LOOP: DEC COUNT
.
.
REDUCE NUMBER OF
..
PASSES REMAINING
DUMMY
· .
JUST TO WASTE TIME
DUMMY
·
.
WASTE MORE TIME
GHI COUNT
· .
SEE IF COUNT HAS REACHED
BNZ LOOP
· .
ZERO. LOOP IF NOT
EXIT
:
IDL
·
.
STOP
AFTER TIME DELAY
· .
HAS
EXPIRED
which is almost a correct assembly language program.
(Notice that three statement labels have been
specified. Only one is presently referenced).

Advertisement

Table of Contents
loading

Table of Contents