,ll 6.6
,cs 10
,pl 66
,lm 0.2,0.5
,pn 1
,ju
,hd
,ce
OmegaSoft 6809 Cross Relocatable Macro Assembler (V1.0)
,,
,ft

,ce 1
10-##
,,
,ce
OmegaSoft 6809 Cross Relocatable Macro Assembler (V1.0)

,ce
ASSEMBLER

The OmegaSoft 6809 Cross Relocatable Macro Assembler is a two pass assembler whose output is compatible with the OmegaSoft 6809 Cross linking loader. This document serves as a reference for the OmegaSoft assembler, not as an introduction to assembly language programming. The Motorola MC6809 User Manual is recommended as a reference for programming the 6809.

,ce
RELOCATION AND LINKING

Relocation is the process of assigning absolute addresses to a program where required. Linking is the process of merging various assembled programs together, doing the necessary relocation, and resolving references from one program to values defined in another program.

SECTIONS

This assembler supports four sections : absolute, code, data, and varib.

The absolute section is used to define absolute values, such as stack frame offsets or the location of I/O devices. The absolute section is not relocated in any way, and does not pass through to the linker.

The code section is where all instructions must be placed. If any data is placed in this section it should be accessed by using one of the program counter relative addressing modes. This section allows the code to be relocated by the linker and the resolving of inter-module references.

The data section, if used, is also relocatable. It is provided so that initialized data can be accepted without it having to be in the code section. Access to data can be made using absolute, program counter relative, or immediate addressing or by loading a base register and using indexed addressing.

The varib section, if used, is also relocatable. Data and instructions are not allowed in varib section, it is only used for assigning an offset from a base register for addressing. The Reserve Memory Bytes and equate directives are normally the only directives used when in varib section.

,ce
SOURCE STATEMENT SYNTAX

Source statements consist of up to 120 characters in the following form :

LABEL   OPERATION    OPERANDS    COMMENTS

where each field is separated by one or more spaces.

LABEL FIELD

The label field must always start in column 1. If no label is present, there must be at least one space preceding the operation field. 
,pg
,ce
SOURCE STATEMENT SYNTAX

An asterisk "*" in the first column marks the line as a comment and no further processing is required on that line, otherwise, the label field defines a symbol. 

A valid symbol can contain at most eight characters. The first character of a symbol must be one of the following: "A" thru "Z", or "." . The rest of the symbol can consist of the characters "A" thru "Z", "0" thru "9", ".", "$", or "_". Lower case letters are always acceptable and are converted internally to upper case, except for character strings. The following symbols are reserved by the assembler : "A", "B", "D", "CC", "DP", "PC", "S", "U", "X", and "Y".

A symbol can only be defined once in the label field (except for the SET directive). A symbol defined in this manner is assigned the value of the location counter and type of the section you are in (absolute, code, data, or varib). The exception to this rule is the EQU and SET directives. Each unique label or external reference symbol requires 18 bytes in the symbol table. The maximum number of symbols is determined by the amount of memory available to the assembler and this number is reported at the end of the assembly.

OPERATION FIELD

The operation field can either be an opcode or an assembler directive. Opcodes correspond directly to the machine instructions whereas directives control the assembly process. Refer to the instruction summary for a list of opcodes. The following opcode mnemonics are automatically translated into their corresponding 6809 equivalent.

Mnemonic      6809 Equivalent        Meaning                      

CLC           ANDCC #$FE             clear carry flag
SEC           ORCC #$01              set carry flag
SCALL expr    SWI2                   system call, example :
              FCB expr               SCALL $4D = SWI2
                                                 FCB $4D

OPERANDS

Expressions

An expression is a combination of symbols, constants, and algebraic operations. The expression is used to specify a value which is to be used as an operand. The expression is evaluated left to right and there may be no spaces in the expression. Expressions may contain absolute, relocatable, or externally defined symbols. Absolute symbols used in an expression must be defined before use. 

Externally defined symbols (via xref directive) can only be used with the add and subtract operations. A relocatable symbol is one that represents an address in the program (defined in label field). Relocatable symbols can only be used with the plus and minus operations. 
,pg
,ce
OPERANDS

The following operations are available for absolute expressions :

               +            addition
               -            subtraction
               !.           logical and
               !+           logical or
               !X           logical exclusive or
               !<           shift left
               !>           shift right
               *            multiply
               /            divide

Note that the expression analyzer always starts out with a type of absolute and a sign of "+" and then starts scanning from left to right. For the expression : LABEL-3 the actual operations are:
0 + LABEL - 3.

There are three type of relocatable symbols ; code, data, and varib. In addition, forward defined symbols must be handled (symbol referenced before being defined, such as a forward branch).

The mixture of relocatable, forward, absolute, and externally defined symbols that may be added and subtracted are summarized in the following table :

 Left side     Operation      Right side      Result    

 external         -           code            external  
 external         -           external        external
 code             -           external        code
 data             -           external        data
 external         -           data            external
 absolute         -           absolute        absolute
 absolute         +           absolute        absolute
 absolute         +           code            code
 absolute         +           forward         forward
 code             +           absolute        code
 code             -           absolute        code
 code             -           code            absolute
 code             -           forward         absolute
 forward          +           absolute        forward
 forward          -           absolute        forward
 forward          -           forward         forward
 forward          -           code            absolute
 external         +           absolute        external
 external         -           absolute        external
 absolute         +           external        external
 data             +           absolute        data
 absolute         +           data            data
 data             -           absolute        data
 data             -           data            absolute
 absolute         +           varib           varib
 varib            +           absolute        varib
 varib            -           absolute        varib
 varib            -           varib           absolute
 absolute         -           external        external
,pg
,ce
OPERANDS

Note that there cannot be more than one external reference in an expression except in the case of external-external where two externals are allowed. Relocatable sections cannot be mixed in an expression.

Symbols

Every symbol is assigned a 16 bit value which is used in place of the symbol during expression evaluation. The reserved symbol "*" represents the value of the location counter at the start of the line of source code for whatever section you are in. Symbols have one of the following attributes:

1) Absolute : label in absolute section or constant
2) Code : label in code section.
3) Data : label in data section.
4) Varib : label in varib section.
5) External reference : by use of XREF directive

Constants

Four types of constants are provided in this assembler : hex, integer, binary, and string. Hex values are preceded by a "$" and can be in the range of $0 thru $FFFF. Integer values have no base specifier (prefix) and can be in the range of -32767 thru +32767. Binary values are preceded by a "%" and can be in the range of %0 thru %1111111111111111. A fourth type of non-numeric data, character, is also provided.  Character data is represented by a single character preceeded by a "'" (single quote). The result is a value which is the ASCII value of the character.

Addressing modes

,in 0.3
,si -0.3
1) Immediate addressing := #expression

Immediate addressing uses information that immediately follows the operation in memory. If the operation references a two byte register (D, S, U, X, Y) then a two byte immediate value is generated, otherwise a one byte value is generated. The immediate value is interpreted either as a two's complement signed value (one byte in the range -128 to 127 or two byte in the range -32768 to 32767) or as an unsigned value (one byte in the range 0 to 255 ($FF) or two byte in the range 0 to 65536 ($FFFF)).

Immediate addressing is also used to represent the specification of two registers, or a register list. The two register mode is used by the TFR and EXG instructions. The two registers are separated by a comma and must either be both one byte registers or both two byte registers. The register list mode is used by the PSH and PUL instructions. They consist of a list of registers separated by commas.

,si -0.3
2) Relative addressing := expression

Relative addressing is used by branch instructions. The offset is a one byte value for short branches with a range of -128 to +127 bytes from the start of the next instruction. The offset is a two byte value for long branches with a range of -32768 to +32767 bytes from the start of the next instruction.
,pg
,ce
OPERANDS

,si -0.3
3) Extended addressing := expression

Extended addressing uses two bytes to contain the address of the operand. This allows addressing of the full memory range of $0000 to $FFFF.

,si -0.3
4) Direct addressing := <expression

Direct addressing uses one byte to contain the lower part of the address of the operand, the upper part being contained in the direct page register. The lower address must be in the range of 0 to 255 ($FF). Notice that in this assembler you must use the "<" character to force direct addressing where extended addressing is possible.

,si -0.3
5) Inherent addressing

Inherent addressing has no operands, all information required is contained in the operation code.

,si -0.3
6) Indexed addressing := expression,R or [expression,R] or
                      [expression]

Indexed addressing is relative to one of the index registers (except extended indirect). In all indexed addressing forms the value 0 can be omitted (except extended indirect).

,in 0.6
(A) The first type of indexed addressing is constant offset from R (where R = X, Y, U, or S). Valid forms are :

expression,R and [expression,R]

where the number of extension bytes depends on the size of the expression. The "[ ]"'s indicate the indirect addressing option.

(B) Accumulator offset from R is of the following form :

acc,R or [acc,R]

where acc is A, B, or D.

(C) Auto increment/decrement R is of the following form :

0,R+ or 0,R++ or 0,-R or 0,--R or [0,R++] or [0,--R]

Notice that indirect mode can only be used with increment or decrement by two.

(D) Constant offset from program counter is of the form :

expression,PCR or [expression,PCR]

where expression can be an 8 or 16 bit offset.

(E) Extended indirect is of the form :

[expression]

where expression is a 16 bit address.

