Summary of Assembler Syntax Rules

  1. Any text appearing on the same line after a semi-colon (;) is treated as a comment.
  2. An asterix (*) at the leftmost position on the line also defines the line as a comment.
  3. Operations (CPU instructions) and assembler directives may be lower or upper case.
  4. All symbols or labels are case sensitive.
  5. Only the first 10 characters of a symbol or label are significant.
  6. Label definitions must begin at the leftmost position on the line.
  7. The use of the colon (:) after the label is optional.
  8. Operations and directives must be preceded by white space or horizontal tabs (HT).
  9. Parameter fields are separated by space, comma or tab.
  10. Literal constants (i.e. numbers) are in decimal except if preceded by % or $.
  11. Binary constants are preceded by %.
  12. Hexadecimal constants are preceded by $.

Filename Restriction

Since the XAVR assembler is written for DOS, the length of the name of the source file is restricted to 8 characters plus the .ASM extension.


Assembler Directives

ORG - Set the assembler's memory address to a new origin.

The ORG directive sets the assembler's current memory address to the value specified in the operand field. If no ORG directive is specified, the memory address is initialized to $0000. Examples:

  ORG $0010    
  ORG main    

END - End of assembly

The END directive indicates to the assembler the end of the program. Any statements following the END directive are treated as comments and are not assembled.

EQU - Equate symbol to a value

The EQU directive assigns the value of the expression in the operand field to the label. The EQU directive assigns a value other than the current memory address to the label. The label cannot be redefined anywhere else in the program. The expression must not contain any forward references or undefined symbols. Examples:

SRAM EQU $0060    
ten EQU 10    

FCB - Form Constant Byte (also DB - Define Byte)

The FCB directive stores a byte into the current memory location. Examples:

CR FCB $0D    
ONE FCB 1    

FCC - Form Constant Character

The FCC directive stores a single byte representing the ASCII code the specified character. Examples:

charA FCC A    
quote FCC "    
ZERO FCC 0    

Note the differences with the following statements:

ZERO EQU 0 ;nothing is stored in memory
ZERO FCB 0 ;$00 is stored at current PC
ZERO FCC 0 ;$30 is stored at current PC

FCS - Form Constant String

The FCS directive places a sequence of bytes representing the ASCII codes of the characters in the specified string. The first non-space character following FCS is the string delimiter and is not part of the string. The string consists of all characters following the delimiter up to, and not including, the next delimiter. The sequence of bytes stored is terminated with a zero byte. Examples:

mess FCS 'This is a string'
title FCS $This is another string
text FCS "The second delimiter is not needed

FDB - Form Double Byte constant (also DW - Define Word)

The FDB directive places a double byte (16-bits) the the current memory location. The low order byte is placed in the lower of the the memory addresses. Examples:

num FDB 1234    
vect FDB $FFFE    
rstrt FDB start    

RMB - Reserve Memory Bytes (also DS - Define Storage)

The DS or RMB directive reserves the specified number of bytes at the current memory address. The memory address counter is then advanced by the specified number of bytes. Examples:

num DS 1 ;reserve 1 byte
result DS 4 ;create a 32-bit result
buffer DS 16 ;create a buffer of 16 bytes


Additions to XAVR Assembler

DATA - append to Data segment

The DATA directive precedes any RMB or DS directive to specify that data storage is to be reserved in the SRAM Data space.

EEPROM - append to EEPROM segment

The EEPROM directive precedes any RMB, DS, FCB, FCW, FDB, FCC, FCS, DB, DW directives to specify that data is to be stored in the EEPROM data space.

CODE - append to CODE segment

The CODE directive specifies that all code and data following this directive are to be stored in the flash (program) memory space.

LO - assign LO-Order byte of byte-address to a label

HI - assign HI-Order byte of byte-address to a label

The LO and HI directives are used together to assign the LO and HI bytes of the 16-bit byte-address of a table created in CODE space. These are used in the program by loading a 16-bit index register with the LO-HI pair. For example:

myadr.L LO table  
myadr.H HI table