Um0144 ST Assemblerlinker Stmicroelectronics
Um0144 ST Assemblerlinker Stmicroelectronics
User Manual
ST Assembler-Linker
Introduction
This manual describes using the ST Assembler-Linker to develop applications for the ST7
and STM8 microcontrollers. The assembly tools described in this book form a development
system that assembles, links and formats your source code.
Stored object
LIB files (*.lib)
ASM LYN
Objects (*.obj)
Source files
*.map
Listings (*.lst) with *.cod
absolute addresses
Obsend
Programmable binary
file (*.s19 or *.hex)
Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.1 ST7 and STM8 incompatibilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3 Host PC system requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.4 Getting assistance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.5 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2 Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4 ST assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.2 Source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.3 Assembler source code format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.3.1 Label structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.3.2 Label size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.3.3 Label relativity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.3.4 Label scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.3.5 Opcodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3.6 Operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3.7 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.3.8 A source code example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.4 Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.4.1 Segments explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.4.2 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.5 Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.5.1 Defining macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.5.2 Parameter substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.6 Conditional assembly #IF, #ELSE and #ENDIF directives . . . . . . . . . . . . 32
4.7 Running the assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.7.1 Command line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.7.2 Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5 Linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.1 What the linker does . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.2 Invoking the linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.3 Command line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.3.1 Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.3.2 Response files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.4 Linking in detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.4.1 PUBLICs and EXTERNs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.4.2 Segments in the linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.4.3 Symbol files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.5 The linker in more detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.5.1 The composition of the .OBJ files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.5.2 The composition of the .COD files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.5.3 Reading a mapfile listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6 OBSEND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.1 What OBSEND does for you . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.2 Invoking OBSEND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.2.1 Destination type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.2.2 Destination arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.2.3 Format definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.2.4 Straight binary format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.2.5 Intel hex format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.2.6 Motorola S-record format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.2.7 ST 2 and ST 4 S-record formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.2.8 GP binary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
7 ABSLIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
7.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
7.2 Invoking the list file post processor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
7.3 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
8 Librarian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
8.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
8.2 Invoking the librarian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
8.3 Adding modules to a library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
8.4 Deleting modules from a library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
8.5 Copying modules from a library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
8.6 Getting details in your library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
9 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
List of tables
List of figures
1 Introduction
Generally, the instruction sets are similar, with the following notable differences:
● The STM8 instruction set supports several new addressing modes.
– The Stack Pointer (SP) can be used as an index.
– Long pointers have been added.
– There is a new 3-byte addressing mode called extended.
– Altogether there are 6 new addressing modes:
short offset SP indexed,
extended direct,
extended offset X or Y indexed,
long pointer to long data,
long pointer to long data X indexed,
long pointer to 24-bit data X or Y indexed.
● Several new instructions have been added.
● The STM8 instruction set allows for longer instructions which may span 5 bytes,
instead of 4 for the ST7.
1.2 Tools
The ST Assembler-Linker includes the following tools:
● Assembler (ASM): translates your source code (.ASM) written in assembly language,
into object code (.OBJ) specific to the target machine and a listing file with relative
addresses(.LSR).
● Linker (LYN): processes the object files (.OBJ) produced by the assembler, resolves
all cross-references between object files and locates all the modules in memory. The
resulting code is output in an object code file (.COD).
● Converter (OBSEND): translates the object code file to produce the final executable in
a format that you specify (Motorola S-record, Intel Hex).
● List file postprocessor (ABSLIST): patches the list file generated by the assembler to
produce a new list file with absolute addresses (.LST).
● Librarian (LIB): The librarian enables you to store frequently used subroutines in one
location for use with any number of ST microcontroller applications.
Note: The utility file asli.bat automatically runs ASM, LYN, OBSEND and ABSLIST one after
the other for you. Use this batch file only if you have only one assembly source file .ASM.
For assistance on all ST microcontroller subjects, or for help developing applications that
use your microcontroller’s MSCI peripheral, refer to the contact list provided in Product
Support. We’ll be glad to help you.
1.5 Conventions
The following conventions are used in this document:
● Bold text highlights key terms and phrases, and is used when referring to names of
dialog boxes and windows, as well as tabs and entry fields within windows or dialog
boxes.
● Bold italic text denotes menu commands (or sequence of commands), options,
buttons or checkboxes which you must click with your mouse to perform an action.
● The > symbol is used in a sequence of commands to mean “then”. For example, to
open an application in Windows, we would write: Click Start>Programs>ST Toolset>.
● Courier font designates file names, programming commands, path names and any
text or commands you must type.
● Italicized type is used for value substitution. Italic type indicates categories of items for
which you must substitute the appropriate values, such as arguments, or hypothetical
filenames. For example, if the text was demonstrating a hypothetical command line to
compile and generate debugging information for any file, it might appear as:
cxst7 +mods +debug file.c
● Items enclosed in [brackets] are optional. For example, [options] means that zero
or more options may be specified because options appears in brackets. Conversely, the
line: options means that one or more options must be specified because options is
not enclosed by brackets. As another example, the line:
file1.[o|st7]
means that one file with the extension .o or .st7 may be specified, and the line:
file1 [file2...]
means that additional files may be specified.
Blue italicized text indicates a cross-reference—you can link directly to the reference by
clicking on it while viewing with Acrobat Reader.
2 Getting started
Up-to-date release notes are provided in PDF format. An additional file contains
demonstration examples.
Inherent nop
Immediate ld A,#$F5
Direct (short address) ld A,$F5
Direct (long address) ld A,$F5C2
X or Y indexed (no offset) ld A,(X)
X or Y indexed (short offset) ld A,($F5,X)
X or Y indexed (long offset) ld A,($F5C2,X)
Short pointer indirect (long pointed data) ld A,[$F5.w]
Short pointer indirect (long pointed data) X or Y indexed ld A,([$F5.w],X)
Direct relative (short offset) jrt $F5
All the ST7 and STM8 addressing modes are described in full detail, with specific examples,
in the relevant programming manual, which can be downloaded from the internet at
www.st.com. This chapter only gives a brief explanation of the main addressing mode
types.
An indirect addressing mode means that the data byte(s) required to do the operation is
found by its memory address which is located in memory (pointer).
The pointer address follows the op-code. A short pointer is one byte long. A long pointer is
two bytes long.
This last group consists of memory indirect variants:
● Short pointer to short data,
for ST7 only [shortpointer .b]
● Short pointer to long data [shortpointer .w]
● Short pointer to short data X or Y indexed,
for ST7 only ([shortpointer .b],X) ([shortpointer .b],Y)
● Short pointer to long data X or Y indexed ([shortpointer .w],X) ([shortpointer .w],Y)
● For STM8 devices only:
– long pointer to long data [longpointer .w]
– long pointer to long data X indexed ([longpointer .w], X)
– long pointer to extended data X or Y indexed ([longpointer .e],X)([longpointer .e],Y)
● Pointer addresses must always be in:
– page 0 (its address must be less than $100) for the ST7
– section 0 (its address must be less than $10000) for the STM8
Examples:
ld A,[80] short pointer to short (ST7) or long (ST8) data
ld A,[80.b] short pointer to short data (ST7 only)
ld A,[80.w] short pointer to long data
ld A,[$1000.w] long pointer to long data (STM8 only)
ldf A,([$1000.e],X)long pointer to 24-bit data (STM8 only)
lab12 equ 80
ld A,([lab12],X) short pointer to short (ST7) or long (ST8) data X-indexed
ld A,([lab12.b],X) short pointer to short data X-indexed (ST7 only)
ld A,([lab12.w],Y) short pointer to long data Y-indexed
● To distinguish between short and long indirect addressing mode, the suffix.w indicates
that you want to work in long indirect mode (this is also true for indexed addressing
mode).
– Short indirect means that pointed data are short (one byte long)
– Long indirect means pointed data are long (two bytes long)
● Implicitly, if nothing is specified,
– for the ST7, short indirect addressing mode is assumed, you can also use .b to
specify short indirect addressing mode (as with the indexed addressing mode).
Use .w to specify long indirect addressing mode.
– for the STM8, long indirect addressing is assumed, you could use .w but it is not
necessary. With the STM8 ldf instruction, you must use .e to specify extended
indirect addressing mode.
nop
ld A,#lab12.h; load A with $00
ld A,#lab12.l; load A with $12
In the STM8, symbols .H and .L are not available. Use low and high primitives instead for
example:
lab1 equ $112233
ld A,#{low{seg lab1}} ; load A with $11
ld A,#{high lab1} ; load A with $22
ld A,#{low lab1} ; load A with $33
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).
For example:
label operand
The next sections describe the main components of a source code file.
The suffix is not used when the label is referred to. Using of any suffixes other than .b, .w
and .l results in an error upon assembly.
For example:
lab equ 0 ; word-size label (default)
label1.b equ 5 ; byte-size label
label2.l equ 123 ; long label
segment byte at: 80 ‘ram’
bytes ; force the size of the label to bytes
count ds.b ; byte-size label
pointer ds.w ; byte-size label with a word-size
; space reserved at this address
4.3.5 Opcodes
The Opcode field may serve three different purposes. It may contain:
● The opcode mnemonic for an assembly instruction.
● The name of a directive.
● The name of a macro to be invoked.
Opcodes must be separated from the preceding field (that is, label, if there is one) by a
space or a tab. A comprehensive Opcode description can be found in the ST programming
manual.
Macros are discussed in Section 4.5 on page 30.
Directives are discussed in Chapter 8: Librarian on page 51.
4.3.6 Operands
Operands may be any of the following:
● Numbers and addresses.
● String and character constants.
● Program counter references.
● Expressions.
The following paragraphs explain how to use these types of operands.
String constants
String constants are strings of ASCII characters surrounded by double quotes.
For example:
“This is an ASCII string”
-a negated a
a and b logical AND of A and B
a or b logical OR of A and B
a xor b logical XOR of A and B
a shr b a shifted right b times
a shl b a shifted left b times
a lt b 1 if a<b, else 0
a gt b 1 if a>b, else 0
a eq b 1 if a=b, else 0
a ge b 1 if a>=b, else 0
a ne b 1 if a unequal b, else 0
high a a/256, force arg to BYTE type
low a a MOD 256, force arg to BYTE type
offset a a MOD 65536, force arg to WORD*16 type
seg a a/65536, force arg to WORD*16 type
bnot a invert low 8 bits of a
wnot a invert low 16 bits of a
lnot a invert all 32 bits of a
sexbw a sign extend byte to 16 bits
sexbl a sign extend byte a to 32 bits
sexwl a sign extend word to 32 bits
a/b a divided by b
a div b a divided by b
a*b a multiplied by b
a mult b as above for motorola (character * is reserved)
a-b a minus b
a+b a plus b
Operator names longer than one character must be followed by a space character. For
example, '1 AND 2' is correct, '1AND2' is not.
Place curly braces { } around arithmetic expressions.
Always use curly braces at the top-level, when defining a numeric expression. Not doing so
may produce unexpected results.
Wrong syntax:
#define SIZE 128
DS.W SIZE+1 ; Wrong, syntax error
#IF SIZE eq 1 ; Wrong, same as #IF SIZE
#ENDIF
Correct syntax:
#define SIZE 128
DS.W {SIZE+1} ; OK
#IF {SIZE eq 1} ; OK
#ENDIF
4.3.7 Comments
Comments are preceded by a semicolon. Characters following a semicolon are ignored by
the assembler.
segment 'program'
start ld a,#0 ; zero counter
loop ld ioport,x ; store into ioport
4.4 Segmentation
4.4.2 Parameters
Possible arguments are:
● Name
● Align
● Combine
● cod parameter, output file control
The following paragraphs describe each argument in detail, and the final paragraph
describes Copying code.
Name
The <name> argument is optional; it can contain a name of up to 12 characters. If it does,
then all segments with the same name are grouped together within their class, in the order
that new names are defined.
Align
The <align> argument defines the threshold on which each segment must start. The
default is the alignment specified at the introduction of the class (if none is specified in the
class introduction then para alignment is assumed), although the alignment types
described in Table 10 are allowed to be specified overriding the default.
Looking back to our example on page 26, you should now be able to see that the 'RAM0'
class will allocate 80 to counter, 81 to address, 92 to stack in FILE1, and when the
linker meets the segment in FILE2 of the same class, serialtemp will be allocated 93, and
serialcou 94. The same processing happens to the two 'eprom' class segments, the
second, in FILE2, will be tacked on to the end of the first in FILE1. If the FILE2 'eprom'
class segment had specified, say, the long align type instead of the default byte, then that
segment would have been put on the next long-word boundary after the end of the FILE1
'eprom' class segment.
Combine
The <combine> argument tells the assembler and linker how to treat the segment. There
are three types to handle it:
The at-type <combine> must be used at the introduction of a class, only once.
The at-type <combine> must have one argument: the start address of the class, and may
optionally be given the end address (or limit) of the class too. If given, the linker checks that
no items in the class have gone over the limit address; if this does occur, a warning is issued
at link time. The hexadecimal numbers X and Y should not have radix specifiers.
All common-type <combine> segments that have the same class name will start at the
same address. The linker keeps track of the longest segment. common segments can be
used for sharing data across different applications.
For example:
st7/
dat1 segment byte at: 10 'DATA'
ds.w
com1 segment common 'DATA'
.lab1 ds.w 4
com1 segment common 'DATA'
.lab2 ds.w 2
com2 segment common 'DATA'
.lab3 ds.w
com2 segment common 'DATA'
.lab4 ds.w 2
dat2 segment 'DATA'
.lab5 ds.w 2
end
The values for labels lab1, lab2, lab3, lab4, and lab5 are 12, 12, 1A, 1A and 1E,
respectively.
Note: Since you cannot specify both at and common combines simultaneously, the only way to
specify the exact location of commons is to insert an empty at combine segment before the
first common declaration.
For example:
com1 segment byte at: 10 'DATA'
com1 segment common 'DATA'
...
com1 segment common 'DATA'
...
Copying code
It sometimes happens that you need to copy a block of code from EPROM to RAM. This
presents some difficulties because all labels in that piece of code must have the RAM
addresses, otherwise any absolute address references in the code will point back to the
EPROM copy.
In this case, it helps to specify a class for execution, and use a different class for storage,
as in the following example:
segment byte at: 0 'code'
segment byte at: 8000 'ram'
segment 'ram>code'
label1:nop
The code starting from label1 will be stored in the code class as usual, but all the labels in
that special segment will be given addresses in the ram class, and memory will also be
reserved in the ram class for the contents of the special segment.
4.5 Macros
Macros are assembly-time subroutines.
When you call an execution-time subroutine you have to go through several time-consuming
steps: loading registers with the arguments for the subroutine, having saved and emptied
out the old contents of the registers if necessary, pushing registers used by the subroutine
(with its attendant stack activity) and returning from the subroutine (more stack activity) then
popping off preserved registers and continuing.
Although macros don't get rid of all these problems, they can go a long way toward making
your program execute faster than using subroutines, at a cost. The cost is program size.
Each time you invoke a macro to do a particular job, the whole macro assembly code
is inserted into your source code.
This means there is no stacking for return addresses, your program just runs straight into
the code; but it is obviously not feasible to do this for subroutines above certain size.
The true use of macros is in small snippets of code that you use repeatedly, perhaps with
different arguments, which can be formalized into a 'template' for the macros' definition.
There is one further problem: because a macro may be called several times in the same
module, any labels defined in the macro will be duplicated. The LOCAL directive gets around
this problem:
For example:
getio MACRO
LOCAL loop
loop ld A,$C000
jra loop
MEND
This macro creates the code for a loop to await IO port at $C000 to go low. Without the
LOCAL directive, the label 'loop' would be defined as many times as the macro is called,
producing syntax errors at assembly time.
Because it's been declared LOCAL at the start of the MACRO definition, the assembler takes
care of it. Wherever it sees the label 'loop' inside the macro, it changes the name 'loop' to
'LOCXXXX' where XXXX is a hex number from 0000 to FFFF.
Each time a local label is used, XXXX is incremented. So, the first time the getio macro is
called, 'loop' is actually defined as 'LOC0', the second time as 'LOC1' and so on, each of
these being a unique reference name. The reference to 'loop' in the 'if' statement is also
detected and changed to the appropriate new local variable.
The directives in Table 12 are very useful, in conjunction with macros:
Marks the start of the conditional and decides whether the following zone will be
#IF
assembled or not.
#ELSE Optionally reserves the condition of the previous #IF for the following zone.
#ENDIF Marks the end of the previous #IF's.
The condition given with the '#IF' may take the form of any numeric expression. The rule for
deciding whether it resolves to 'true' or 'false' is simple: if it has a zero value then it is false,
else it is true. These directives should NOT start at column 1 of the line, reserved for labels.
For example:
#IF {count eq 1}
%OUT 'true'
#ELSE
%OUT 'false'
#ENDIF
This sequence would print true if the label count did equal 1, and ‘false’ if it did not.
For example:
#IF {count gt 1}
%OUT count more than one
#IF {count gt 2}
%OUT ...and more of TWO !
#ELSE
%OUT ...but not more than two!
#ENDIF
#ELSE
%OUT count not more than one
#ENDIF
As you can see, conditionals may be nested, the #ELSE and #ENDIF directive are assumed
to apply to the most recent unterminated #IF.
Other special #IF directives are available as shown in Table 14.
.
Requires no conditional argument. If the appropriate pass is. being assembled, the
#IF1 and
condition is considered 'true'; for instance #IF1 will be considered true while the
#IF2
assembler is in first pass, #IF2 while in the second pass.
#IFDEF Checks for label definition.
Checks for empty argument (that is, empty, or containing spaces / tabs), useful for
#IFB
testing macro parameter existence.
#IFF (IF False) is similar to #IF, but checks the negation of the condition argument.
Tests for string equality between two arguments separated by a space. This is useful
#IFIDN
for testing macro parameters against fixed strings.
#IFLAB Checks if the argument is a predefined label.
4.7.2 Options
Options are always preceded with a minus sign '-'. Upper and lower cases are accepted to
define options. Supported options are listed in Table 15.
SYM option
LI option
Description: Request to generate a complete listing file. To specify the pathname for the
generated list file use the option -li=<pathname>. The default extension
is LST. Note that the extension must be three characters long.
Format: ASM <file> -li or
ASM <file> -li=<pathname>
Example: ASM prog -li
The output is the file prog.lst in the current directory
ASM prog -li=obj\prog
The output is the file obj\prog.lst
ASM prog -li=prog.lsr
The output is the file prog.lsr
OBJ option
Description: You can specify the pathname for the generated .OBJ file, using this option:
Format: ASM <file> -obj=<pathname>
Example: ASM prog -obj=obj\prog
Forces the assembler to generate the object file obj\prog.obj.
FI option
Note: Instead of using ASM -fi, it is advised to use the list file post processor ABSLIST
which guarantees that the final list file is consistent with the executable code
generated by the linker.
Description: One side effect of using a linker is that all modules are assembled
separately, leaving inter modules' cross-references to be fixed up by the
linker. As a result the assembler listing file set all unresolved references to 0,
and displays a warning character.
The -fi option enables you to perform an absolute patch on the desired
listing. Therefore, you must have linked your application to compute
relocations and produce a .COD file and a map file.
To generate a full listing, you must not have made any edits since the last
link (otherwise the named map-file would be 'out of date' for the module
being assembled). This is not usually a problem since full listings are only
needed after all the code has been completed. -fi automatically selects a
complete listing.
Format: ASM <file> -fi=<file>.map
The output <file>.lst contains the absolute patches.
Example: ASM ex1 (produces ex1.obj)
ASM ex2 (produces ex2.obj)
LYN ex1+ex2,ex (produces ex.map, ex.cod)
(see Chapter 5: Linker on page 38)
ASM ex1 -fi=ex.map (produces ex1.lst)
ASM ex2 -fi=ex.map (produces ex2.lst)
Note: When assembling in '-fi' mode, the assembler uses the map file produced by the linker,
and no object files are generated.
When using the option -fi=<file>.map, the assembler step may fail under certain
circumstances:
● If there are empty segments (Error 73). To avoid this, comment out any empty
segments.
● If you try to assemble a file that has not been used to produce the .map file (Error
73).
● Some EXTERN labels are never used (Warning 80). To avoid this, comment the
unused EXTERN labels out.
D option
Note: If you specify multiple -D switches, they should always be separated by a space.
I option
Description: Used to specify the list of search paths for files that are included (with
#include) or loaded (with #load). The paths can be separated by the ;
character and the path list must be enclosed within double quotes. You can
also enter multiple include paths by using the -I option more than once and
separating each with a blank space.
The current working directory is always searched first. After that, the ST
assembler searches directories in the same order as they were specified
(from left to right) in the command line.
Format: ASM -I="<path1>;<path2>;...;<pathN>" call or
ASM -I="<path1>" -I="<path2>"... -I="<pathN>" call
Example: ASM -I="include;include2" call or
ASM -I="include" -I="include2" call
M option
Description: Tells the ST assembler to output a rule suitable for make, describing the
dependencies to make an object file.
For a given source file, the ST assembler outputs one make rule whose
target is the object file name for that source file and whose dependencies
are all the included (#include) source files and loaded (#load) binary files it
uses. The rule is printed on the standard output.
Format: -M <source file name>
Example: ASM -I="include;include2" -M call
The output appears on the screen as the rule:
call.obj: call.asm include\map.inc include2\map2.inc
include\map3.inc include\code.bin
PA option
NP option
5 Linker
5.3.1 Arguments
The linker needs the following arguments:
LYN [-no_overlap_error] <.OBJ file>[+<.OBJ file>...],
[<.COD file>],[<lib>][+<lib>...]
-no_overlap_error forces the generation of the .cod executable even if some
segments overlap.
If all or any arguments are left out of the command line, you will be prompted. For example:
LYN
STMicroelectronics - Linker - rel 3.00
.OBJ files: begin
.COD file [begin.cod]: begin
Libraries:
The .OBJ files are simply a list of all the object files that form your program. The .OBJ suffix
may be left out, and if more than one is specified they should be separated by '+' characters,
for example game+scores+keys would tell the linker to link game.obj, scores.obj and
key.obj. Object file path names should not include '-' or ';' characters. Character '.'
should be avoided, except for suffixes.
The .COD file has a default name formed of the first object file's name with forced suffix of
.COD. This will be the name of the file produced at the end of the link session. It contains all
the information from the link session in a special format: however, OBSEND must be used on
the .COD file before it is ready to use. If the default filename is not what you want, the
filename given at the prompt is used instead. The suffix will be forced to .COD if left blank.
The default is selected by leaving this argument blank at the command line, or pressing
<ENTER> at the prompt.
The Libraries prompt asks for a list of library files generated by the lib utility that should
be searched in case of finding unresolved external references. The format for giving multiple
libraries is the same as for the .OBJ list, except the suffix .LIB is assumed.
Some examples:
Linking together the modules game.obj, scores.obj, key.obj, game1.obj,
game2.obj and game3.obj without using any libraries and generating a .COD file named
game.cod, requires the following command line:
LYN game+scores+keys+game1+game2+game3;
Linking the same modules in the same environment, but generating a .cod file named
prog.cod requires the following command line:
LYN game+scores+keys+game1+game2+game3,prog;
hex ld A,#1
add A,#10
nop
If this example followed immediately after the class instruction the 'xtemp' label would be
given the value 0, time would be given 2 and hex C000. If, however, the code was several
modules away from the introduction with segments of the classes 'RAM0' or 'ROM', then the
value allocated to all the labels will depend on how much space was used up by those
modules. The linker takes care of all this allocation. This is the way the linker handles the
problems of relocatability; keep in mind that this link system is going to have to handle
compiled code from high level languages and you will perhaps begin to understand why
things have to be generalized so much.
So far the segments we have looked at have had no <name> field, or, more accurately, they
all had a null <name> field. You can ensure that related segments of the same class,
perhaps scattered all over your modules with segments of the same class are collated
together in a contiguous area of the class memory by giving them the same name.
For example:
grafix segment byte at: 100-027F 'RAM1'
cursor_buf ds.b 64 ; buffer for map under cursor
segment byte at: 8000-BFFF 'ROM'
show_page nop
segment 'RAM1'
field-buf ds.b {{256 mult 256}/8}
segment 'ROM'
dump_buf ld A,field_buffer
grafix segment 'RAM1'
cursor_temp ds.b 64
This complex sequence of segments shows now instances of the class RAM1 being used
with a segment name of grafix. Because the first instance of the class RAM1 had the
name grafix the two grafix RAM1 segments are placed in memory first followed by the
null-name RAM1 segment (which defines field_buf). Note this is not the order of the
segments in the code, segments with the same name are collated together (even from
separate .OBJ files), and the lumps of segments of the same name are put into memory in
the order that the names are found in the .OBJ files.
As explained on page 29, if x is your cod file suffix when introducing a class, all code for that
code is sent into a new cod-file named file_x.cod, where file is the name of the first
cod file, and x is the cod-file suffix (1-9).
Class list:
0 ‘RAM0' byte from 0 to 78 (lim FF) 45% D
0 ‘RAM1' byte from 100 to 138 (lim 27F) 50% D
0 ‘eprom' byte from 8000 to 875B (lim BFFF) 21% C
0 ‘rom' byte from C000 to FFF9 (lim FFDF) C*Overrun*
0 ‘vectors' byte from FFEE to FFFF (lim FFFF) 100% D
The external label list only includes labels that were declared PUBLIC: labels used
internally to the module are not included. This table is most useful for debugging purposes,
since the values of labels are likely to be relocated between assemblies. The labels are
given in first-character-alphabetic order.
External label list:
Symbol Name Value Size Def(line)
char 64 BYTE game.obj(10)
char1 66 BYTE game.obj(11)
label ABCD WORD game.obj(25)
3 labels
6 OBSEND
The next two characters are the record type for this line: 00 is a data line, and 01 signals
EOF. The following characters, until the last two, are the 16 data bytes for this line, the last
two are a checksum for the line, calculated by starting with $00 subtracting the real value of
all characters sent after the ':' until the checksum itself. 'Real value' means that for example,
the two characters 3 and 0 should subtract $30 from the checksum, not 51 and 48. Every
line ends with a CR-LF combination, $0A and $0D.
The last line sent must be an END-OF-FILE line, which is denoted by a line with no data
bytes and a record type of 01 instead of 00.
Giving I32 or i32 instead of intel as the argument uses the same format, but sends 32 bytes
of data per line.
S113001AFF120094FF130094D08AFF390094FF1250
S20801C004FFC0000073
<format>= x
The extended S-record format, selected by format x, sends code as described above,
except that after the S9, it sends a list of SX records, one after the other, in the format:
SX 0000 LABEL
where 0000 are four ASCII zeroes, and LABEL is five ASCII characters. There are two
spaces after the SX and one space after the 0000. 0000 represents the hexadecimal value
of the label. LABEL may extend to 31 characters, and end with a carriage return.
6.2.8 GP binary
<format>= g
This format is simple. It has a 16-byte count at the beginning low-byte first, calculated by
starting at 0, and adding the value of each byte until the end of the data is reached. If there
are any 'gaps' in your code, OBSEND fills them in with $FF, and adjusts the checksum
accordingly. After four bytes of header information, the data follows in one big block.
7 ABSLIST
7.1 Overview
As the list file with absolute addresses generated by the assembler from the source file and
the map file (ASM ex1.asm -fi=ex.map) may show differences with the actually generated
code, a post processor has been written to be sure that the list file will be coherent with the
executable file.
ABSLIST is a post processor which reads a list file with relative addresses and unresolved
symbols and converts it into a list file with absolute addresses and resolved symbols. For
this, the post processor needs information which is located in two files generated by the
linker: the map file and the executable file in Motorola S-record format (.s19) or in Intel Hex
format (.hex).
This is possible because the linker does not optimize the code generated by the assembler.
The list file with relative addresses is generated by the assembler and it must include
symbols.
Thus the following assembler command must be executed first, to generate a list file with
relative addresses and including a symbol list:
asm -sym file1.asm -li=Debug\file1.lsr
Such a list file is composed of two parts:
● A list of assembler instructions with addresses, codes and mnemonics,
● A list of labels.
To transform relative addresses for instructions and labels, the postprocessor adds to the
relative address the start address of the corresponding segment.
The segment start address is found in the segment list of the map file.
As for the list of relative labels, there are two cases:
● Public labels: their absolute addresses can be found in the external label list of the map
file.
● Private labels: as for the instructions, the start address of the corresponding segment
must be added to the relative address.
The segment corresponding to an instruction is the last segment which has been declared
in the source file.
It is the same for a local label, so a list of labels with the segments where they are defined
must be constituted as the list file is parsed.
To generate the code for instructions with unresolved labels (subroutine calls, variable read
or write accesses), the final code is read in the executable file.
7.3 Limitations
1. There is one main limitation. The update of the relative address is based on the search
of the last declared segment. If the search cannot succeed because of the use of
.NOLIST directives which hide segment declarations, the absolute file cannot be
properly generated.
There is the same problem with .XALL and .SALL for macro expansions. If a segment
is declared in a macro, these directives should not be used.
There is the same kind of problem for label definitions which are removed from the list
file by the previously mentioned directives. Label definitions are needed to compute the
addresses of labels printed in the symbol table at the end of the list file.
In conclusion, do not use .NOLIST, .XALL and .SALL primitives to hide code where
segments are declared or labels are defined.
2. There is another limitation regarding the use of the EQU and CEQU directives to define
private labels.
The addresses of public labels can be found in the symbol table generated in the map
file.
There is a problem with private labels set by EQU or CEQU to a relative expression
involving a label defined in a relative segment. As ABSLIST does not parse the
expression after EQU and CEQU directives, it has no way to know which label is used in
the expression and which segment it belongs to.
ABSLIST always generates warnings for labels equaled to relative expressions.
For private labels equaled to relative expressions, the post processor will print question
marks for the unknown address.
There is a workaround to get the addresses of labels equaled to relative expressions in
the list file: just make these labels public and ABSLIST will be able to find their
addresses in the map file.
3. ABSLIST only accepts the ST7 and the STM8 processors. It could be easily
generalized to other processors but more validation time would be necessary.
8 Librarian
8.1 Overview
If you do a lot of work on similar boards especially those with the same processor, it makes
a great deal of sense to reuse lumps of code you have already written to do the same task in
a different program. At the simplest level, you could just copy the source code as a block of
text into the new program. This works fine, but has a subtle disadvantage: if you update the
subroutine, you have to hunt around all the usages of it, performing the update on each.
To get around this problem, many people have the source for common routines in one place,
and link the .OBJ module with each program needing routine. Then you only need to update
the source code once, reassemble it to get a new .OBJ file, then link again all the users of
the routine, who will now have the new .OBJ file.
While this scheme works well, it generates some problems of its own. For example, each
routine needs its own .OBJ file. By nature, these common routines tend to be small, so you
end up giving dozens of extra .OBJ modules to the linker, and having the .OBJ modules
scattered around your hard disk.
The base concept of a librarian is to combine all these small, useful .OBJ modules into one
large .LIB library file. You could then tell the linker about the library, and it takes care of
which .OBJ modules to pull in to link. It would know which ones to pull in by the fact that the
main code being linked would have undefined externals, for example, to call the missing
library routines. The librarian simply takes each undefined external in turn, and checks it
against all the modules in the library. If any of the modules declares a PUBLIC of the same
name, it knows you need that .OBJ module and it includes it automatically.
9 Definitions
This is the printed circuit board onto which you wish to connect the target ST MCU. It should
Application include a socket or footprint so that you can connect the application board to your emulator or
board development kit using the probe and the appropriate device adapter. This allows you to emulate
the behavior of the ST MCU in a real application in order to debug your application program.
Device adapters are included in your emulator kit to allow you to connect the emulator to your
application board. The type of device adapter depends on the target device’s packaging. Many
Device adapter
MCUs come in at least different packages, and you should therefore use the device adapter that
corresponds to the type of package you have chosen for your application.
Dual in line. Designates a type of device package with two rows of pins for thru-hole mounting.
DIL
Sometimes also called DIP (dual in-line package).
ECP Extended capabilities port communication standard.
EPP Enhanced parallel port communication standard.
LSB Least significant byte of a 16-bit value.
This is the main board of the emulator that is common to the entire ST HDS2 family of emulators.
Main board
It controls common functions such as communication with your PC via the parallel port.
mem Memory location.
mnem Mnemonic.
Microcontroller unit. Otherwise referred to as the target device throughout this manual. This is the
core product (or family of products) for which the Development Kit is designed to act as an
MCU
emulator and programming tool. In general terms, an MCU is a complete computer system,
including a CPU, memory, a clock oscillator and I/O on a single integrated circuit.
A printed card having connector pins that allow you to connect the emulator to the MCU socket of
ST7MDT6- the user application board. Using the active probe allows the HDS2 emulator to function as if it
active probe were the target device embedded in your application. The probe is connected to the emulator by
two flat cables.
The program counter is the CPU register that holds the address of the next instruction or operand
PC
that the CPU will use.
S Stack pointer LSB.
short Uses a short 8-bit addressing mode.
Small outline. Designates a type of device package with two rows of pins for SMD or socket
SO
mounting. For example, SO34 designates a 34-pin device of this package type.
src source
ST7 visual A graphic debugger software package that allows you to debug applications destined for the ST7
debug (STVD7) family of MCUs, either using a built-in simulator function, a Development Kit or an HDS2 Emulator.
This is the ST MCU that you wish to use in your application, and which your emulator or
Target device
development kit will emulate for you.
User application
Designates your application board.
board
A.1 Introduction
Each directive is described in a table.
● The name of the directive is given in the table title (and always appears in the Format).
● The Format shows the arguments allowed (if any) for this directive.
● The Description describes the action of the directive and the format and nature of the
argument specified in the Format.
● The Example gives one or more example of the directive in use.
● The See also lists possible cross references.
All the directives must be placed in the second, OPCODE, field, with any arguments one tab
away in the argument field.
A.2 Directives
Table 20. .BELL
Purpose Ring bell on console.
Format .BELL
This directive simply rings the bell at the console; it can be used to signal the end of
Description pass-1 or pass-2 with #IF1 or #IF2. This directive does not generate assembly code or
data.
Example .BELL
See also
Note: The name of the program that handled the error (third field), can be as1 or as2 depending
on the pass in progress when the error was found.
The error number (fourth field) can be used as an index to find a more complete description
of the error in the next section (fatal errors read 'FATAL nn', instead of 'ERROR nn').
1 Empty file: The assembler could not read even the first line of the given source code file.
EOF while in Macro Definition: The file ended while a macro was being defined; you should end the last
2
macro definition properly with a MEND statement.
Could not return to old place in source file 'X.asm': This error should never occur; it implies you have a disk
3 fault of some kind. After a #include, the assembler returns to the line after the #include itself. If it cannot
return to that line this error is produced.
4 Illegal source EOF: Main source code files must end with an END directive and a carriage-return.
EOF before line terminator: The END directive must have at least one CR after it: for example <TAB> END
5
<EOF> will generate this error while <TAB> END <EOF> will work fine.
Code produced outside segment: Any code produced by the assembler is going to have to be placed on a
given address in the target system at the end of the day. Since segments are the assemblers way of
allocating addresses to lumps of code, any code generated before the first SEGMENT directive is
nonsense.
^T 55 Move to top line of current window
^V 56 Move to last line of current window
^U 57 Undo changes to last edited line
^[ 58 Drop start of black marker
^] 59 Drop end of black marker
6 ^F 60 Find Source Code for Hex address
^J 61 Report value of given label
^N 62 Report address of current Editor line
These functions mostly explain themselves; the Alternate functions do the same job as the original
functions of the same name: having two indexes for the same job allows the cursor keys and control
codes to move the cursor, whichever the user prefers. Some indexes are not used by the default key
sequence matrix; these allow some WordStar-like commands to be implemented with more meaning.
Multiple-key sequences, such as those found in WordStar format control codes need to be implemented as
follows: take the sequence <^Y><L>, that is, CTRL-Y followed by the letter L should be coded as ^Y+L
where the + denotes that the following character needs no CTRL or SHIFT.
18 File capture error: #Include had problems finding the named file.
Cannot find position in source file: Again to do with #include, another 'impossible' error reporting that it
19
could not find the current position of the source file to remember it for after the #include.
Cannot have more than 4096 #defines: Each #define has to be checked for in each possible position in
each source line: having too many of them slows the assembly noticeably. Although you can have up to
20
4096 #defines, there are also limits on the storage space for both the arguments (error 23); an average of
eight characters for both arguments is recommended.
21 Run out of #define storage space (1): See error 20.
#define has no second argument: #define requires a space between the two parts of its argument to
22
delimit it.
Run out of #define storage space (2): See errors 20 and 21 above; you have reached the limit of the
23
storage space set aside for the second argument of #defines.
24 No strings in DC.W: Strings are only allowed as parts of BYTE, DC.B or STRING directives.
25 No strings in DC.L: Strings are only allowed as parts of BYTE, DC.B or STRING directives.
Illegal external suffix: Only the suffixes .b, .B, .w, .W, .l, .L are legal after an external label in an external
26 directive. If the suffix is left out then the default label size is used (as set by BYTES, WORDS or LONGS;
default is WORDS).
27 Bad character in public line.
More than four characters in single quotes: This assembler uses double-quotes to surround string items
28
and single-quotes to surround character constants. See Section 4.3 on page 18.
29 Uneven single quotes: Single-quoted items must have a closing quote to delimit.
30 Sequential operator error: It does not allow arithmetic operators to be hard up against each other.
No lvalue in expression: An lvalue is the left-hand argument of an operator: a + b has 'a' as its lvalue. +b
31
would cause this error.
32 Divide by zero: Attempt to divide a number by zero, in a numeric expression.
33 Ifs nested past 15 levels: Exceeded maximum number of nested #IF statements.
34 Spurious ELSE: An ELSE was discovered when no active IF was in force.
35 Spurious ENDIF: An ENDIF was discovered when no active IF was in force.
36 Only allowed inside Macros: A LOCAL directive was attempted outside a Macro definition.
37 No strings in word: See Error 24.
38 No string in long: See Error 25.
39 No REPEAT for this UNTIL: An UNTIL directive is found with no matching REPEAT directive.
40 Could not return to old place in source: Similar to Error 3 but generated by UNTIL instead of #include.
43 Syntax error in SKIP arguments: SKIP expects two numeric arguments, separated by a comma.
First SKIP argument is extern/relative; SKIP aborted: SKIP arguments must be known to the assembler
44 absolutely. Extern or relative arguments are not allowed, although arithmetic is. If you need to move up to
a new page, for example, use a new SEGMENT of the same class with a page align type.
45 Second SKIP argument is extern/relative; SKIP aborted: See Error 44.
46 Undefined label: This error happens when a reference is made to an undefined label.
Out of label space: A maximum of 1024 labels are allowed per module, and 10k is set aside to contain their
names. If either of these limits is exceeded, this error results. Cut the module into two smaller ones; the
47
assembly will happen twice as fast and you will only have to reassemble the half you have made changes
to, speeding things up.
48 Label more than 30 characters: Labels longer than 30 characters are not allowed.
Label defined as PUBLIC twice: This warning occurs if the same label appears more than once in a
49 PUBLIC statement. It is trapped because the second appearance may be a typographical error of a
slightly different label you wanted declared as public.
50 Doubly defined label: This happens when a label is defined twice or more.
Phase inconsistency (P1=X,P2=Y) 'label': Reports that the named label was allocated different values
from pass-1 and pass-2, implies awful things. It's generally caused when for some reason the assembler
has generated different lengths for the same instruction between pass-1 and pass-2. Sometimes if the
assembler has problems identifying which addressing mode you wanted for a particular instruction
because of typographical errors, or labels that are discovered to be undefined during the second pass it
51 may give an error (see Error 54) and create no object code for that line. All labels after that line will then be
allocated different values seeing as the object code is now that many bytes shorter, causing tons of Phase
Inconsistency errors. Because this mass of Error 51s can sometimes hide the real cause of the error, a
special assembler switch /np for 'no phase [errors]' can be used to switch them off. We strongly suggest
that you don't always use /np on all your assemblies; only use it when you need it or you might miss critical
phase errors.
52 Public symbol undefined: You defined a symbol in a PUBLIC directive that was not defined in the module.
53 Missing hex number: The assembler was led to expect a hex number but found one of zero length.
Cannot match addressing mode: This error is a catchall for the assembler if it cannot see anything wrong
with your line but cannot match it to a known addressing mode either.
There are two main causes of errors: significant ordering and numeric range errors. The significant
ordering error is a simple typographical error: what should have been (val),y was coded as (valy, or
whatever. All the components of the addressing mode are properly formed; it is just that the ordering is
wrong. The numeric range errors can be harder to detect. For example, an 8-bit relative branch branching
54
out of range would be trapped as an addressing mode error.
To aid diagnostics of what went wrong the assembler dumps out its model of the line to the screen just
before the error. Numerics are printed as a hex value followed by an attribute string: INTernal, EXTernal,
ABSolute, RELative and .b, .w, .l. Significands are printed as the characters they represent, and strings are
printed with their string.
Numeric range errors are also trapped at the link stage (See Section 5.1 on page 38).
55 Bad PSIG index: An 'impossible' error that could only occur through corruption of the .TAB file.
Un-recognized opcode: The Opcode (second field) could not be matched against any opcode names for
56
this instruction set, nor could it be matched against any macro names or directives.
57 No closing quote: String must have closing double-quote before the end of the line.
No more than 12 numerics allowed on one line: There is a limit of 12 numeric units allowed on one line:
58 this usually only matters on long DC.B-type directives where data tables are being defined. If it is a
problem, simply cut the offending long line into two shorter lines.
Out of space for macro definition: The macro storage area (ca 64K) has overflowed. You must have some
59
really big macros!
60 Too many macros attempted: There is a limit of 128 Macros allowed per source code module.
61 Mend only allowed in macro: MEND directive found with no matching MACRO directive.
62 No closing single quote: See error 29.
63 Bad ending: Another 'impossible' error, saying that the CR on the end of a source code line was missing.
Bad character in line: As each source code line is read into the assembler it is checked for non-ASCII
64
characters (that is >128).
Parameter mismatch: The macro definition implies that there is a different number of parameters than
65
there actually were in this calling line.
Currently unknown numeric type: An error in your Tabgen file, or a corrupted .TAB file: the numeric handler
66 was asked to check a number against an undefined numeric type. Are you using the latest version of
ASM.EXE and your .TAB file?
67 Improper characters: Unusual characters have been spotted in the source file, of value >127.
Label used before its EXTERN definition: Labels must be declared EXTERNAL before use, preferably in a
68
group at the top of the file.
Ambiguous label name: The label name in the single-quotes at the end of the error-line can be confused
69
with a register name in this instruction set. Change the name.
Cannot have DS.X in segments containing code/data! (only for [void] segs!): DS.X does not produce any
70 code; it simply advances the assembler's notional Program Counter. It cannot be used in the same
segment as real 'code' or data.
Cannot have code in segments previously containing DS.X (only for non-void segs!): DS.X does not
71 produce any code; it simply advances the assembler's notional Program Counter. It cannot be used in the
same segment as real 'code' or data.
Constant too large for directive 'value': A DC.B cannot be given an argument >255, for example. Use LOW
72
or OFFSET operators to truncate any wild arguments.
Could not find entry for segment in mapfile: This is for listings produced with '-fi' option. Complex include
73
file structures and empty segments can sometimes throw the assembler off the track.
COD index only allowed on introduction: When you are using the multiple linker output file scheme, you
74
can only specify the linker output file number for a particular class at the time of that class's introduction.
#LOAD before segment!: The #load has to be but at a given address! Before the first segment the
75
assembler does not know what address to put it at! Shift the #load after a SEGMENT directive.
#LOAD before segment!: The assembler had problems finding the file you have named in a #LOAD
76
directive.
77 All EQUs involving external args must be before first segment!
78 Cannot nest #includes > 5 levels
Could not find label list in mapfile: Happens with option '-fi' - Implies problem with the mapfile itself, or
79
unsuccessful previous link, etc.
Could not find label in mapfile: As above. Is the Mapfile up to date with your edits? A label may be declared
80
EXTERN, but never used.
Could not find label in mapfile: The date info has to be stored at a given address - before a SEGMENT
81
there is no address information for the assembler to work on.
No string given on FCS line?: FCS is used for defining strings. Why is there no string on this line? Did you
82
intend that? If so, use DC.B or BYTE.
Address not on WORD boundary: For 68000 and certain other genuine 16-bit, Opcodes must be on word
83 boundary. This error occurs if you have assembled an instruction at an odd address. Your processor would
crash!
84 Byte size label has value >255 (need WORDS?).
85 Word size label has value > 65535 (need LONGS?).
86 Over 250 macline pull: Internal error.
87 Run out of source file: Internal error.
88 TAB arguments incorrect: Must be in order num, num, num, num for example, TAB 8, 8, 12, 32.
89 Illegal suffix: An unknown suffix has been used with a label. Recognized suffixes are .b, .w and .l.
100 Label defined as NEAR and FAR
Revision history
Index
Symbols -i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
-li . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
.asm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
-li= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
.cod . . . . . . . . . . . . . . . . . . . . . . . . 9, 29, 38, 44
-m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
.fin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
-np . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
.lib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51
-obj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
.map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
-pa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
.obj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9
-sym . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
.rsp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
attributes
.s19 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
.sym . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
externally . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
.tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
internally . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
/np assembler switch . . . . . . . . . . . . . . . . . . . .81
linker relative or absolute . . . . . . . . . . . . . . . 19
‘@’ sign (linker) . . . . . . . . . . . . . . . . . . . . . . . .39
long . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
’&’ character . . . . . . . . . . . . . . . . . . . . . . . . . . .31
relativity . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
’.’ in labels . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
scope . . . . . . . . . . . . . . . . . . . . . . . . . . . 19, 21
size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Numerics word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
128-byte boundary . . . . . . . . . . . . . . . . . . . . . .27
16-byte boundary . . . . . . . . . . . . . . . . . . . . . . .27 C
1k-byte boundary . . . . . . . . . . . . . . . . . . . . . . .27
cbe.err . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18, 78
256-byte boundary . . . . . . . . . . . . . . . . . . . . . .27
class-names . . . . . . . . . . . . . . . . . . . . . . . . . . 26
30 characters . . . . . . . . . . . . . . . . . . . . . . . . . .80
combine
4-byte boundary . . . . . . . . . . . . . . . . . . . . . . . .27
at . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4K-byte boundary . . . . . . . . . . . . . . . . . . . . . . .27
common . . . . . . . . . . . . . . . . . . . . . . . . . 28, 73
64-byte boundary . . . . . . . . . . . . . . . . . . . . . . .27
Combine argument in a segment . . . . . . . . . . 28
80-column printer . . . . . . . . . . . . . . . . . . . . . . .74
comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
conditional assembly . . . . . . . . . . . . . . . . . . . . 32
A conditionals (nesting) . . . . . . . . . . . . . . . . . . . 64
address representation . . . . . . . . . . . . . . . . . .22 constants . . . . . . . . . . . . . . . . . . . . . . . . . . 22-23
align copied code . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
128 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 cross-references . . . . . . . . . . . . . . . . . . . . . . . . 9
1K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27, 73
4K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27, 73 D
64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27, 73
directives
byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27, 73
#DEFINE . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
long . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27, 73
#ELSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
page . . . . . . . . . . . . . . . . . . . . . . . . . . . .27, 73
#ENDIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
para . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27, 73
#IF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
word . . . . . . . . . . . . . . . . . . . . . . . . . . . .27, 73
#IF1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Align argument in segments . . . . . . . . . . . . . . .27
#IF2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
ampersand (’&’) character . . . . . . . . . . . . . . . .31
#IFB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
asli.bat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9
#IFDEF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
ASM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
#IFIDN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
assembler options
#IFLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
-d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
#INCLUDE . . . . . . . . . . . . . . . . . . . . . . . . . . 66
-fi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33-34
#LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
f . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45 S
g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
segment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
segment address list . . . . . . . . . . . . . . . . . . . . 42
i32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
segment name . . . . . . . . . . . . . . . . . . . . . . . . . 27
ix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . 26
s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
segments in the linker . . . . . . . . . . . . . . . . . . . 40
Opcodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
SKIP aborted . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
source files . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
ST S-record . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
{} . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
ST S-record format . . . . . . . . . . . . . . . . . . . . . 47
-a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
straight binary format . . . . . . . . . . . . . . . . . 44-45
a*b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
string constants . . . . . . . . . . . . . . . . . . . . . . . . 23
a+b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
suffixes
a/b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
.asm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
a-b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
.cod . . . . . . . . . . . . . . . . . . . . . . . . 9, 29, 38, 44
and . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
.fin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
bnot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
.lib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
div . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
.map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
eq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
.obj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 51
ge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
.rsp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
gt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
.s19 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
high . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
.sym . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
lnot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
.tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
low . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
lt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
mult . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 T
ne . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 table of segments . . . . . . . . . . . . . . . . . . . . . . 42
offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
precedence . . . . . . . . . . . . . . . . . . . . . . . . . .23
seg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 U
sexbl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 utilities
sexbw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 asli.bat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
sexwl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
shl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
shr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
wnot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
xor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
P
pass-1,-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81
pass-1,-2 listing . . . . . . . . . . . . . . . . . . . . . . . .33
precedence (operators) . . . . . . . . . . . . . . . . . .23
program counter . . . . . . . . . . . . . . . . . . . . . . . .23
PUBLIC labels . . . . . . . . . . . . . . . . . . . . . . . . .21
R
radix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
representation of addresses . . . . . . . . . . . . . . .22
representation of numbers . . . . . . . . . . . . . . . .22
response files . . . . . . . . . . . . . . . . . . . . . . . . . .39
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,
DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE
GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.