III. ASSEMBLER OPERATION & SOURCE LINE COMPONENTS
The TSC Assembler is a 2 pass assembler. During pass one a symbolic
reference table is constructed and in pass two the code is actually
assembled, printing a listing and outputting object code if desired.
The source may be supplied in free format as described below. Each line
of source consists of the actual source statement terminated with a
carriage return (0D hex). The source must be comprised of ASCII
characters with their parity or 8th bit cleared to zero. Special
meaning is attached to many of these characters as will be described
later. Control characters (00 to FF hex) other than the carriage return
(0DH) are prohibited from being in the actual source statement part of
the line. Their inclusion in the source statement will produce
undefined results. Each source line is comprised of up to four fields:
Label, Opcode, Operand, and Comment. With two exceptions, every line
must have an opcode while the other fields may or may not be optional.
These two exceptions are:
- "Comment Lines" may be inserted anywhere in the source and are
ignored by the assembler during object code production.
Comment lines may be either of two types:
- Any line beginning with an asterisk (hex 2A) in column
- A null line or a line containing only a carriage return.
While this line can contain no text, it is still
considered a comment line as it causes a space in the
- lines which contain a label but no opcode or operand field.
SOURCE STATEMENT FIELDS
The four fields are described here along with their format
specifications. The fields are free format which means there may be any
number of spaces separating each field. In general, no spaces are
allowed within a field.
LABEL OR SYMBOL FIELD:
This field may contain a symbolic label or name which is assigned the
instruction's address and may be called upon throughout the source
- The label must begin in column one and must be unique. Labels
are optional. If the label is to be omitted, the first
character of the line must be a space.
- A label may consist of letters (A-Z or a-z), numbers (0-9), or
an underscore (_ or 5F hex). Note that upper and lower case
letters are not considered equivalent. Thus 'ABC' is a
different label from 'Abc'.
- Every label must begin with a letter.
- Labels may be of any length, but only the first 6 characters
- The label field must be terminated by a space or a return.
This field contains the 6809 opcode (mnemonic) or pseudo-op. It
specifies the operation that is to be performed. The pseudo-ops
recognized by this assembler are described later in this manual.
- The opcode is made up of letters (A-Z or a-z) and numbers
(0-9). In this field, upper and lower case may be used
- This field must be terminated by a space if there is an
operand or by a space or return if there is no operand.
The operand provides any data or address information which may be
required by the opcode. This field may or may not be required,
depending on the opcode. Operands are generally combinations of
register specifications and mathematical expressions which can include
constants, symbols, ASCII literals, etc. as explained later.
- The operand field can contain no spaces.
- This field is terminated with a space or return.
- Any of several types of data may make up the operand: register
specifications, numeric constants, symbols, ASCII literals,
and the special PC designator.
The comment field may be used to insert comments on each line of source.
Comments are for the programmer's convenience only and are ignored by
- The comment field is always optional.
- This field must be preceded by a space.
- Comments may contain any characters from SPACE (hex 20) thru
DELETE (hex 7F).
- This field is terminated by a carriage return.
Many opcodes require that the operand following them specify one or more
registers. EXG and TFR require two registers specified, push and pull
allow any number, and the indexed addressing mode requires specification
of the register by which indexing is to be done. The following are
possible register names:
The EXG and TFR instructions require two register specs separated by a
comma. The push and pull instructions allow any number of registers to
be specified, again, separated by commas. Indexed addressing requires
one of X,Y,U, or S as explained under the indexed addressing mode
Many opcodes require that the operand supply further data or information
in the form of an expression. This expression may be one or more items
combined by any of four operator types: arithmetic, logical, relational,
Expressions are always evaluated as full 16 bit operations. If the
result of the operation is to be only 8 bits, the assembler truncates
the upper half. If truncation occurs when warnings are enabled, an
appropriate message will be issued.
No spaces may be imbedded in an expression.
The "item or items" used in an expression may be any of four types as
listed below. These may stand alone or may be intermixed by the use of
- NUMERICAL CONSTANTS: Numbers may be supplied to the assembler
in any of the four number bases shown below. The number given
will be converted to 16 bits truncating any numbers greater
than that. If 8 bit numbers are required, the 16 bit number
will then be further truncated to 8 bits with notification of
such if warning messages are enabled. To specify which number
base is desired, the programmer must supply a prefix character
to a number as detailed below.
BASE PREFIX CHARACTERS ALLOWED
Decimal none 0 thru 9
Binary % 0 or 1
Octal @ 0 thru 7
Hexadecimal $ 0 thru 9, A thru F
If no prefix is assigned, the assembler assumes the number to
- ASCII CONSTANTS: The binary equivalent of a single ASCII
printable character may be supplied to the assembler by
preceding it with a single quote. The character should be
between 20 and 7F hex.
- LABELS: Labels which have been assigned some address or
constant value may be used in expressions. As described above
under the label field, a label is comprised of letters,
digits, and hyphens beginning with a letter. The label may be
of any length, but only the first 6 characters are
significant. Any label used in the operand field must be
defined elsewhere in the program.
- PC DESIGNATOR: The asterisk (*) has been set aside as a
special PC designator (Program Counter). It may be used in an
expression just as any other value and is equal to the address
of the current instruction.
As mentioned previously, the four classes of operators are: arithmetic,
logical, relational, and shift. These operators permit assembly-time
operations such as addition or division to take place. "Assembly-time"
means that the expression is evaluated during the assembly and the
result becomes a permanent part of your program.
- ARITHMETIC OPERATORS
The arithmetic operators are as follows:
+ Unary or binary addition
- Unary or binary subtraction
/ Division (any remainder is discarded)
- LOGICAL OPERATORS
The logical operators are as follows:
& logical AND operator
| Logical OR operator
! Logical NOT operator
>> Shift right operator
<< Shift left operator
The logical operations are full 16 bit operations.
In other words for the AND operation, every bit from
the first operand or item is individually AND'ed with
its corresponding bit from the second operand or item.
The shift operators shift the left term the number of
places indicated by the right term. Zeroes are
shifted in and bits shifted out are lost.
- RELATIONAL OPERATORS
The relational operators are as follows:
< Less than
> Greater than
<> Not equal
<= Less than or equal
>= Greater than or equal
The relational operations yield a true-false result.
If the evaluation of the relation is true, the resulting
value be all ones. If false, the resulting value will
will be all zeros. Relational operations are generally
used in conjunction with conditional assembly as shown
in that section.
Certain operators take precedence over others in an expression. This
precedence can be overcome by use of parentheses. If there is more than
one operator of the same priority level and no parentheses to indicate
the order in which they should be evaluated, then the operations are
carried out in a left to right order.
The following list classifies the operators in order of precedence
(highest priority first):
- Parenthesized expressions
- Unary + and -
- Shift operators
- Multiply and Divide
- Binary Addition and Subtraction
- Relational Operators
- Logical NOT Operator
- Logical AND and OR Operators