User manual

ST assembler ST Assembler-Linker
18/89 Doc ID 11392 Rev 4
4 ST assembler
4.1 Overview
The ST assembler program is a cross-assembler, meaning that it produces code for a target
machine (an ST7 or STM8 microprocessor) which is different from the host machine.
The assembler turns the source code files into re-locatable object modules ready for linking.
During the process, it checks for many different types of errors. These errors are recorded in
an ASCII file called cbe.err (Note that the linker also writes to this file). Error messages are
explained in Appendix B: Error messages on page 78.
To produce code ready for execution, you must run the assembler (ASM), the linker (LYN),
and the object code formatter (OBSEND).
4.2 Source files
Source program code is written in the ST7 or STM8 assembler language and is saved in an
ASCII text file named source file. A source file has the extension .asm. It is made up of
lines, each of which is terminated by a new line character.
For a complete reference of the ST7 or STM8 assembler language, refer to the relevant
programming manual.
4.3 Assembler source code format
The first line of an assembler source code file is reserved for specifying the *.tab file for the
target processor. You cannot put other instructions or comments in this line.
Use this line to specify the directory location of the *.tab file. If the directory is not specified,
by default the Assembler searches first in the current directory, then in the directory where
the Assemblers executable is located.
The '.tab' suffix may be left out, as the assembler only looks for this file type.
The first line of your source code might look like:
st7\ or c:\sttools\asm\st7\ (to use the ST7 processor)
stm8\ or c:\sttools\asm\stm8\ (to use the STM8 processor)
If the file st7.tab (or stm8.tab) cannot be found in the specified or default directories,
then an error is produced and assembly is aborted.
The rest of the source code lines have the following general format:
[label[:]]<space>[opcode]<space>[operand]<space>[;comment]
where <space> refers to either a SPACE ($20) or a TAB ($09) character.
All four fields may be left blank, but the <space> fields are mandatory unless:
the whole line is blank, or
the line begins as a comment, or
the line ends before the remaining fields.