,ll 6.6
,cs 10
,pl 66
,lm 0.2,0.5
,pn 6
,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
MACROS AND CONDITIONAL ASSEMBLY

MACROS

The macro directive allows you to setup a pattern of code to be repeated with variations.

MACRO - define macro

syntax :    label    macro

The label is put into the symbol table with the macro attribute. The lines that follow may include instructions and directives and the macro definition is terminated by the ENDM directive. Macro definitions and expansions may not be nested. The lines within the macro definition may contain parameters. 

Up to 35 parameters are allowed, they are \1 through \9 and \A through \Z (upper and lower case are equivalent). Parameters may not contain any spaces and may contain commas only if they are bracketed by "<" and ">".

Labels can be used within in a macro so a method is provided to make sure that each expansion of a macro results in unique labels. As part of a label you may use a \@ which will substitute a 3 digit integer number which is incremented for each expansion.

MEXIT - exit macro prematurely

syntax :             mexit

Exits the macro expansion (skips to the ENDM directive). Can be used if deeply nested IF's would be confusing or after a FAIL directive.

ENDM - end of macro definition

syntax :             endm

Terminates a macro definition.

CONDITIONAL ASSEMBLY

Conditional assembly is used where more than one version of source code must be generated. Normally there is one or more control constants at the front of the assembly which are used throughout the assembly to substitute different code. 

Conditional assembly is used in the Pascal runtime routines to allow removal of error checking code.

IFxx - conditional assembly

syntax :            ifxx         expression         {comment} or
                    ifxx         'string1','string2'

The expression is evaluated and its value used to determine whether or not the following code will be assembled (up until an ENDC or ELSE). These directives may be nested up to 30 levels. There are eight variations of the IFxx directive :
,pg
,ce
MACROS AND CONDITIONAL ASSEMBLY

IFEQ - assemble code if expression is equal to 0
IFGE - assemble code if expression is greater than or equal to 0
IFGT - assemble code if expression is greater than 0
IFLE - assemble code if expression is less than or equal to 0
IFLT - assemble code if expression is less than 0
IFNE - assemble code if expression is not equal to 0

IFC  - assemble code if string1 is the same as string2
IFNC - assemble code if string1 is not the same as string2

ELSE - reverse condition

Reverses whether code is assembled or not from the last IF condition.

ENDC - terminate conditional assembly

Returns the assembly status to what is was before the last IF condition. An ENDC directive is required for each IF directive.

EXAMPLE

The below example shows a macro and two expansions of it.

blkmove   macro
          ldx #\1
          ldu #\2
          ldy #\3
          beq abc\@
def\@     lda 0,x+
          sta 0,u+
          leay -1,y
          bne def\@
abc\@     equ *
          endm

          blkmove  $4000,$5000,$100
          ldx      #$4000
          ldu      #$5000
          ldy      #$100
          beq      abc.001
def.001   lda      0,x+
          sta      0,u+
          leay     -1,y
          bne      def.001
abc.001   equ      *
          blkmove  $5000,$6000,$53
          ldx      #$5000
          ldu      #$6000
          ldy      #$53
          beq      abc.002
def.002   lda      0,x+
          sta      0,u+
          leay     -1,y
          bne      def.002
abc.002   equ      *
,pg
,ce
ASSEMBLER DIRECTIVES

ABS - enter absolute section

syntax :            ABS         [offset]

The ABS directive will instruct the assembler to enter absolute section and set the location counter to the offset in the operand field, if specified. The location counter defaults to zero at the start of the assembly. Instructions and the BSZ, FCB, FDB, and FCC directives are not allowed in this section, and therefore no code or data can be generated to pass to the linker.

BSZ - block storage of zeroes

syntax : [label]    BSZ         expression            [comment]

The BSZ directive causes the assembler to allocate a block bytes, each with an initial value of zero. The value of the expression must be absolute and the expression value must be defined before the BSZ directive statement.

CODE - enter code section

syntax :            CODE                              [comment]

The CODE directive will instruct the assembler to enter the code section. The section at the start of the assembly is CODE and the program counter is 0. The code and/or data generated will be relocated by the linker.

DATA - enter data section

syntax :            DATA                              [comment]

The DATA directive will instruct the assembler to enter the data section. The location counter defaults to zero at the start of the assembly. Instructions are not allowed in the data section, however all directives are. Data will be generated and will be relocated by the linker.

END - end of source program

syntax :            END          [label]

The END directive indicates the logical end of the source program has been encountered. If the operand is specified the relative address of the label is used as the begin execution address of this program.

EQU - equate symbol to a value

syntax :  label     EQU          expression           [comment]

The EQU directive assigns the value of the expression in the operand field to the label. The expression cannot contain any external references or forward references. The symbol will be the same type as the expression (absolute, code, data, or varib).
,pg
,ce
ASSEMBLER DIRECTIVES

FAIL - generate assembler error message

syntax :            FAIL

This directive will generate error number 31. This is normally used inside conditional assembly or macros to indicate an error.

FCB - form constant byte

syntax : [label]    FCB       expression{,expression} [comment]

The value of each expression is truncated to one byte and stored in successive locations in the object program. The expression(s) must be absolute.

FCC - form constant characters

syntax : [label]    FCC       number,string
                 or
         [label]    FCC       <delimiter>string<delimiter>

The FCC directive stores ASCII characters into consecutive bytes of memory. In the first format the number defines the number of characters after "," to be output. There are never more characters output than there are characters on a line regardless of the count specified.

The second format of the FCC directive specifies the characters to be output between 2 identical delimiters. The delimiter is the first non-blank after the "FCC".

FDB - form double byte

syntax : [label]    FDB       expression{,expression} [comment]

The value of each expression fills 2 bytes and are stored in successive locations in the output. The expression(s) may be of type absolute, code, data, or external expressions.

IDNT - Relocatable identification record

syntax :  name      IDNT         <version>,<revision> [desc.]

This directive will setup the identification record that is generated in the relocatable object file. This information is displayed for each module when in the linker by using the map command. Name is the module name (max 8 characters), version and revision are decimal numbers 0 to 255. Desc. is a description of the module (max of 60 characters). If there is no IDNT directive in the assembly then name and description will be null strings and version and revision will be zero. The label used for the name must not be used again in the assembly.

INCLUDE - include source from file

syntax :            INCLUDE      <path name>          [comment]

The path name given is opened and source is read from the path until end of file. At that point the path is closed and source continues from the main file. Include directives may not be nested.
,ce
ASSEMBLER DIRECTIVES

LIST - enable listing

syntax :            LIST                              [comment]

The listing is enabled (default) if the L command line option is enabled. List and nolist directives increment and decrement a counter. In other words, it takes N list directives to enable the listing if N nolist directives have been used.

NOLIST - disable listing

syntax :            NOLIST                            [comment]

The listing is disabled. List and nolist directives increment and decrement a counter. In other words, it takes N+1 nolist directives to disable the listing if N list directives have been used.

PAGE - move listing to next page

syntax :            PAGE                              [comment]

This directive causes the listing to move to the top of the next page if listing is enabled and page size is non-zero.

RMB - reserve memory bytes

syntax : [label]    RMB          expression           [comment]

This directive will skip the indicated number of bytes in the current section. These bytes will not be initialized. The expression must be absolute and defined before the RMB directive.

SET - equate symbol to a temporary value

syntax : label      SET          expression           [comment]

This directive is identical to the EQU directive except the same label may be set to an expression more than once in the file. This is normally used for counters in macros.

SPC - put blank lines in listings

syntax :            SPC          expression

This directive is used to waste paper. It will space the number of lines specified by the integer expression. It will not space past the top of a new page.

TTL - set page title

syntax :            TTL          string

The TTL directive causes the page title to be set to the string in the operand field.
,pg
,ce
ASSEMBLER DIRECTIVES

VARIB - enter variable section

syntax :            VARIB                             [comment]

The VARIB directive will instruct the assembler to enter the varib section. The location counter defaults to zero at the start of the assembly. Instructions and the BSZ, FCB, FDB, and FCC directives are not allowed in this section. Offsets will be generated and will be relocated by the linker.

XDEF - external definition

syntax :            XDEF         symbol{,symbol}      [comment]

The XDEF directive is used to specify that the list of symbols is defined within the current program and the definition is passed through the linker.

XREF - external reference

syntax :            XREF         symbol{,symbol}      [comment]

THe XREF directive is used to specify that the list of symbols is referenced within the current program but is defined in another program (via XDEF).
