Document Navigation
Table Of Contents
Previous
Next

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:

  1. "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:
    1. Any line beginning with an asterisk (hex 2A) in column one.
    2. 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 output listing.
  2. 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 program.

  1. 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.
  2. 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'.
  3. Every label must begin with a letter.
  4. Labels may be of any length, but only the first 6 characters are significant.
  5. The label field must be terminated by a space or a return.

OPCODE FIELD:

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.

  1. 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 interchangeably.
  2. This field must be terminated by a space if there is an operand or by a space or return if there is no operand.

OPERAND FIELD:

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.

  1. The operand field can contain no spaces.
  2. This field is terminated with a space or return.
  3. Any of several types of data may make up the operand: register specifications, numeric constants, symbols, ASCII literals, and the special PC designator.

COMMENT FIELD:

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 assembler.

  1. The comment field is always optional.
  2. This field must be preceded by a space.
  3. Comments may contain any characters from SPACE (hex 20) thru DELETE (hex 7F).
  4. This field is terminated by a carriage return.

REGISTER SPECIFICATION

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:

A,B,CC,DP,X,Y,U,S,D,PC

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 description.

EXPRESSIONS

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, and shift.

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.

ITEM TYPES:

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 the operators.

  1. 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 be decimal.
  2. 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.
  3. 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.
  4. 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.

EXPRESSION OPERATORS

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.

  1. ARITHMETIC OPERATORS The arithmetic operators are as follows:

    Operator Meaning

    + Unary or binary addition
    - Unary or binary subtraction
    * Multiplication
    / Division (any remainder is discarded)

  2. LOGICAL OPERATORS The logical operators are as follows:

    Operator Meaning

    & 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.

  3. RELATIONAL OPERATORS The relational operators are as follows:

    Operator Meaning

    = Equal
    < 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.

OPERATOR PRECEDENCE

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):

  1. Parenthesized expressions
  2. Unary + and -
  3. Shift operators
  4. Multiply and Divide
  5. Binary Addition and Subtraction
  6. Relational Operators
  7. Logical NOT Operator
  8. Logical AND and OR Operators


Table Of Contents Previous Next
Document Navigation