![RCA CDPl8S693 Скачать руководство пользователя страница 30](http://html.mh-extra.com/html/rca/cdpl8s693/cdpl8s693_user-manual_334504030.webp)
5. Running the MCDS COSM AC Resident Assembler (CRA)
29
title and at line 3 asks for the source tape drive number.
When a carriage return (CR) is struck, the system
checks the entry for a 0 or a 1. Either response sets the
appropriate tape source. If an unacceptable number is
the entry before the (CR), the system again asks for a 0
or a 1. Non-numeric characters are ignored by the
Assembler.
At line 4 the system asks for the object tape. The
same conditions apply here as with line 3 and the (CR)
key sets the write (object) tape. In line 5 and line 6, the
system tells the user to enable the source tape by
pressing the play button on the cassette recorder and
then to type any key to continue to line 7.
At line 7 the system asks for H (generate a
hexadecimal file), L (generate a listing file), U (abort
and go to UT62), or J (enable tapes for rewind). If H or
L is typed by the user, the system starts PASS1 of the
source tape to create a symbol table. After PASS1 is
done, the system tells the user to rewind the source tape
(line 8) and then type a key.
At line 9, the system tells the user to enable the read
tape for PASS2 by pressing the play button. Line 10
alerts the user to press the record button for the object
(write) tape. At this point, the typing of any key starts
the system running PASS2. During the pass object
code is generated (hexadecimal or listing) and written
to the object tape.
Line 12 tells the user that the assembly is done and
line 13 requests a new command. A J response enables
both source and object tapes for rewind. A U response
causes the system to exit the assembler and enter
monitor UT62.
Location Counter
The basic function of CRA is to fill a simulated
COSMAC memory (the object code area or file) with
the hexadecimal equivalent of the user’s source
program. Lor this purpose, CRA maintains a two-byte
location counter as a pointer into this area. The initial
value of the location counter is zero. As CRA runs and
produces output code, it places this code in the output
area at the position specified by the location counter,
and then advances the location counter past the bytes
just inserted. The value of the location counter is also
controlled by the CRA directive statements ORG and
PAGE (explained later). These statements may be
used, for example, to advance the location counter
past an area without filling it.
The source programmer may explicitly refer to the
current location counter value by use of the character
“*” in an expression (see later discussion).
Symbol Table
The most fundamental logical facility provided by
an assembler to aid in the output code generating
process is its ability to construct and reference a
symbol table. A symbol is a sequence of one to six
alphanumeric characters beginning with a letter. Each
programmer-defined symbol is given an entry in this
table where it is assigned a two-byte value which is
often an address value equal to the location counter
contents at the point where the symbol is “defined” in
the program. However, it may also be a user-specified
value (for example, a constant) if the symbol is defined
in an EQUATE directive (explained later). Thus, while
a symbol most often represents an address, it may also
represent a specific CPU register, an I/O device
number, or any other user-specified value (e.g., a
constant, an immediate argument, etc.).
A symbol normally appears at many points in the
source program. At one of these points, it is assigned a
value in the symbol table; i.e., it is defined. At all other
points (whenever the symbol is referenced), this value
is used by the assembler to derive or produce code.
Thus, by changing the value assigned to a single
symbol, the program mer can make substantial
changes in his object code file.
A symbol is also called a label, a name, an identifier,
or a symbolic address or pointer.
Expression Evaluation
As CRA processes source statements, it produces
hexadecimal code values. Much of this code is the
direct equivalent of explicit, user-specified informa
tion in the source program (constants, register or
device numbers, operation code mnemonics). Other
code values are derived indirectly using either the
current value in the location counter or the value
assigned to a specific symbol in the symbol table. The
code values thus produced are either assembled into
the output stream, as previouslydescribed, orassigned
to new symbol table entries (when new symbols are
defined).
At various places in the source program, CRA will
be expecting to encounter an expression. An
expression is defined as one of the following forms.
1) expression constant
2
) *
3) *±expression constant
4) symbol
5) symbol ±expression constant
#2F or 47
*
*+47 or *-#F1
SAM or J65MP
AREA9^2F
where an expression constant contains an explicit
hexadecimal or decimal value. (The acceptable forms
for expression constants are described later.) CRA
evaluates the expression by using the explicit constant
value (if present), the current location counter value
(for the “*”, if it is present), the symbol’s value in the
symbol table (if a symbol is present), and by
performing the required arithmetic operation (if
necessary). The result is always a two-byte value which
may be disposed of in any one of several ways, as
discussed further later. Spaces adjacent to the + or
- operators are optional.