
REFERENCE
DATA
FOR ENGINEERS
by an internal
symbol table.
For example, in the
statement below,
START M0VE.W
XX,DO
DO
:=
con-
tents
of
memory location
XX.
the value of the symbol START equals the memory
address at which the
MOVE.
W
instruction is stored. In
general, the value of a symbol is the memory address at
which the corresponding instruction or data value is
stored (except with the EQU pseudo-operation, de-
scribed later). Each symbol may be defined only once,
but may be referenced as often as needed.
Symbols only have values at the time a program is
being assembled, that is, at
assembly time.
Symbols
exist in the source text of the program, and in the
environment
of
the assembler, but do not appear in the
machine-language program. For instance, when our
example program is loaded into memory (at
load time)
or
is actually run (at
run time),
there is no way to
discover, simply by looking at the object module or at
memory, that the programmer had associated the sym-
bo1 MULT with address
$00001000,
or
even that there
had been a symbol MULT at all. (However,
symbolic
debuggers
may access this information in the run-time
environment by referring to a copy of the source code
and the symbol table that were used by the assembler.)
The OPCODE field contains the mnemonic
of
either a
machine instruction or a pseudo-operation or assembler
directive. In
68000
assembly language, many opcode
mnemonics have a
size
SUB
of
.B,
.
W,
or
.L
to
indicate the size of the operands and operation. The size
suffix
is
optional for operations that have only one size
(such as
LEA).
Depending on the contents
of
the OPCODE field, the
OPERAND field specifies zero or more operands sepa-
rated by commas. An operand is an expression consist-
ing
of
symbols, constants, and operators such as
+
and
-.
The simplest expression consists
of
a single symbol
or constant.
In
68000
assembly language, a sequence of decimal
digits denotes a
decimal constant,
and a sequence
of
hexadecimal digits preceded by
$
denotes a
hexadeci-
mal constant. Character constants
are surrounded by
single quotes (e.g.,
A
’
)
and have the corresponding
ASCII value.
The COMMENTS field is ignored by the assembler,
but it is used by the programmer to convey a high-level
explanation of the program to human readers. It is also
possible to use an entire line as a comment
by
placing
and asterisk
(*)
at the beginning of the line.
Four different
assembler directives
appear in Table
7;
their functions are described below:
*
ORG
(origin). The operand is the address at which
the next instruction or datum is to be deposited
when the program
is
loaded into memory. Subse-
quent instructions and data are deposited in succes-
sive memory addresses.
DS
.
W
(define storage-word). The operand is a
number of memory words to be skipped without
storing any instructions or data, thereby reserving
space to be used by variables in a program.
DC
.
W
(define constant-word). The specified
word value is stored into memory when the pro-
gram is first loaded into memory, thereby estab-
lishing a constant value that may be accessed when
the program is run.
EQU
(equate). The identifier in the label field
is
assigned the value in the operand field, instead
of
the value in the address field. This makes the
identifier a synonym for a constant value for the
duration of the assembly process.
END (end assembly). This pseudo-operation de-
notes the end of the text to be assembled. Its
operand, if present, is the address
of
the first
executable instruction of the program.
Of course, there are many other directives
in
a
full
assembly language, and different assembly languages
may use different names and conventions for the same
thing.
The input of an assembler is the text file containing
the source code, while the output consists of an object
module (or “object file” or “binary file”) and a listing
similar to Table
7.
To understand a little more about how an assembler
works, it is useful to examine the Address column in the
listing. The Address column indicates the address at
which the assembler “thinks” that it should assemble
the instruction on the current line. By default, this
address is initialized to zero.
The
ORG
directive tells the assembler to start assem-
bling subsequent instructions starting from a new ad-
dress, and hence changes the Address column on the
next
line. Some directives, such as EQU, do not
assemble any instructions or data and therefore do not
affect the Address column at all. Others, such as
DS
.
W,
advance the Address value but do not cause anything to
be loaded into the corresponding memory location at
load time.
For its own and the programmer’s use, the assembler
creates a
symbol table
that lists the numeric value
associated with each symbol. As evident in Table
7,
in
most cases the symbol receives the value of the Address
column in the line in which
it
is defined, except
in
the
case of EQU statements, which assign the symbol the
value in the Operand column. In all cases, the symbols
and their values exist only at assembly time.
Many instructions in the
68000
are more than one
word long. It is therefore convenient to compress the
program listing, showing all words associated with the
same instruction on one line as in Table
8.