STMicrolectronics ST7 Assembler Linker User manual

STMicrolectronics
ST7 Assembler
Linker
UM0144
User manual
Rev 2
June 2005

BLANK

Rev 2
June 2005 UM0144 3/92
4
UM0144
User Manual
ST7 Assembler Linker
Introduction
Thanks for choosing ST7! This manual describes how to use the ST7 Assembler-Linker to
develop applications for ST7 microcontrollers. The assembly tools described in this book form a
development system that assembles, links and formats your source code.
The ST7 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 an optional listing file (.LST).
●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). In a second pass, the Assembler
uses these files to produce an object code file, map and listing with absolute paths.
●Obsend (OBS): translates the object code file to produce the final executable in a default
format (.FIN) or other format that you specify (e.g. ST S-record, Motorola S-record, Intel
Hex...).
●LIB (Librarian): The librarian enables you to store frequently used subroutines in one
location for use with any number of ST7 applications.
Figure 1. Schematic overview of the ST7 assembler toolset
www.st.com

ST7 Assembler Linker
4/92 UM0144
Note: The utility file asli.bat automatically runs ASM, LYN, and OBSEND one after the other for you. Use this batch file only
if you have only one assembly source file ".ASM".
About the user manuals...
This manual provides information about producing an application executable for ST7 from your
application source code in Assembly language. Here, you will find:
●An overview of Assembly language for ST7
●Instructions for running the ST7 Assembler-Linker
●Descriptions of the Assembler output
For information on related subjects refer to the following documentation:
ST7xxxx Datasheet
– full description of your ST7.
ST7 Programming Manual
– a complete reference to ST7 Assembly language
Host PC system requirements
This tool has been designed to operate on a PC that meets the following:
●One of the following operating systems: Microsoft®Windows®98, 2000, Millennium, NT®
or XP®.
●Intel®Pentium (or compatible) processor with minimum speed of 133 MHz.
●Minimum RAM of 32 MB (64 MB recommended).
●60 MB of free hard disk space to install all of the ST7 tools.
Getting assistance
For more information, application notes, FAQs and software updates for all the ST
microcontroller development tools, check out the CD-ROM or our website:
www.st.com/mcu
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
on
page 108. We’ll be glad to help you.

ST7 Assembler Linker
UM0144 5/92
Contents
1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 ST7 Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1 Overview of ST7 addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2 General instruction syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Short and long addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Inherent addressing mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5 Immediate operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.6 Direct and indirect modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.7 Indexed modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
2.8 Relative mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
2.9 High, low addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
3 ST7 Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 Source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3 Assembly source code format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.4 Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.5 Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.6 Conditional assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.7 Running the assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4 Linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.1 What the linker does . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.2 Invoking the linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.3 Command line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.4 Linking in detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.5 The linker in more detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5 OBSEND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.1 What OBSEND does for you . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.2 Invoking OBSEND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

ST7 Assembler Linker
6/92 UM0144
6 Librarian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.2 Invoking the librarian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.3 Adding modules to a library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.4 Deleting modules from a library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.5 Copying modules from a library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.6 Getting details in your library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Appendix A Assembler Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Appendix B Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Appendix C Revision History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Appendix D Product Support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

ST7 Assembler Linker 1 Getting Started
UM0144 7/92
1 Getting Started
Installing the ST7 Assembler-Linker
The ST7 Assembler-Linker is delivered as part of the ST7 toolset. A free installation package is available
at www.st.com/mcu. To install it:
1. Select
ST7>ST7 toolchain
from the main menu of the “Microcontroller Development
Tools” CD-ROM, or...
2. Run the installation executable that you have downloaded from the internet.
Note: Windows
®
2000, NT®and XP®users must have administrator privileges to install certain
software components.
After installation, the installation directory should contain the following (
Table 1
):.
Up-to-date release notes are provided in PDF format. An additional file contains demonstration examples.
Table 1. Description of installed files
ASM.EXE ST7 Assembler
LYN.EXE ST7 Linker
OBSEND.EXE output file formatter
LIB.EXE librarian
ST7.TAB ST7 description files
ASLI.BAT batch file ASM+LYN+OBSEND
RELEASE_NOTES.PDF release notes

2 ST7 Addressing Modes ST7 Assembler Linker
8/92 UM0144
2 ST7 Addressing Modes
2.1 Overview of ST7 addressing modes
The ST7 assembler instruction set incorporates the following different addressing modes:
All ST7 addressing modes are described in full detail, with specific examples, in the
ST7 Family
8-bit MCUs Programming Manual
. This chapter seeks only to give a brief explanation of the
main addressing mode types.
2.2 General instruction syntax
The ST7 instruction set provide a single source-coding model regardless of which components
are operands—the accumulator (A), an index register (X or Y), an 8-bit stack pointer (S) for
ST7, the condition code register (CC), or a memory location. For example, a single instruction,
ld, originates register to register transfers as well as memory to accumulator data movements.
Table 2. ST7 Addressing modes
Instruction Set Addressing Mode Example
ST7
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 (short pointed data) ld A,[$F5]
Short Pointer Indirect (long pointed data) ld A,[$F5.w]
Short Pointer Indirect (short pointed data) X
or Y Indexed ld A,([$F5],X)
Short Pointer Indirect (long pointed data) X or
Y Indexed ld A,([$F5.w],X)
Direct Relative (short offset) jrt $F5
Short Pointer Indirect Relative (short pointed
data) jrt [$F5]
Bit operation bset byte, #5

ST7 Assembler Linker 2 ST7 Addressing Modes
UM0144 9/92
Two-operand instructions are coded with destination operand appearing at first position. For
example:
2.3 Short and long addressing modes
For ST7 there are two addressing modes that differ in memory address size (i.e. one byte for
short mode and two bytes for long mode).
Because of these different addressing modes, the target address range of the operands will
depend upon the addressing mode chosen:
Some instructions accept both long and short addressing modes, while others only accept one
or the other.
For example:
For ST7 instructions supporting both short and long formats, when external symbols are
referenced, long mode is chosen by the Assembler. For example:
2.4 Inherent addressing mode
This concept is hardware-oriented, meaning that instruction operands are coded inside the
operation code. At the source coding level, operands are written explicitly.
Examples:
lab01 ld A,memory ; load accumulator A with memory contents
lab02 ld memory,A ; load memory location with A contents
ld X,A ; load X with accumulator contents
0-$FF for short addressing mode
$100-$FFFF for long addressing mode
lab10 add A,memory ; accepts both types of addressing modes
lab11 inc memory ; accepts only short addressing mode
EXTERN symb3 ;
symb1 equ $10 ;
...
ld A,symb1 ; short mode
ld A,symb3 ; long mode chosen
lab06 push A ; put accumulator A onto the stack
lab07 mul X,A ; multiply X by A

2 ST7 Addressing Modes ST7 Assembler Linker
10/92 UM0144
2.5 Immediate operands
Immediate operands permit you to input a specific value for use with an instruction. They are
signaled by the use of a sharp sign (#) before the value.
Examples:
The range for an 8-bit immediate operand is from 0 to 255.
2.6 Direct and indirect modes
A direct addressing mode means that the data byte required to do the operation is found by
its memory address, which follows the op-code.
An indirect addressing mode means that the data byte required to do the operation is found
by its memory address which is located in memory (pointer). The pointer address follows the
op-code.
This last group consists of memory indirect variants:
●short indirect (short pointed data),
●long indirect (long pointed data),
●short indirect indexed (short pointed data),
●long indirect indexed (long pointed data),
For ST7 devices, the address specified must always be in page 0 (i.e. its address must be less
than $100). Examples:
To make the distinction between short and long indirect addressing mode, the suffix.w is
specified to indicate that you want to work in long indirect mode (this is also true for indexed
addressing mode). Implicitly, if nothing is specified, the short indirect addressing mode is
assumed.
For ST7 devices, you can also use.b to specify short indirect addressing mode (as with the
indexed addressing mode).
lab08 ld A,#1 ; load A with immediate value 1
lab09 bset memory,#3 ; set bit #3 in memory location
btjt memory,#3,label ; test bit #3 of memory and
jump if true (set)
ld A,[80] ; short indirect
ld A,[80.b] ; short indirect
ld A,[80.w] ; long indirect
lab12 equ 80
ld A,([lab12],X) ; short indirect X-indexed
ld A,([lab12.b],X) ; short indirect X-indexed
ld A,([lab12.w],Y) ; long indirect Y-indexed

ST7 Assembler Linker 2 ST7 Addressing Modes
UM0144 11/92
2.7 Indexed modes
The ST7 hardware supports four types of indexed mode:
●indexed without offset,
●indexed with a 8-bit unsigned offset (range [0 ,255]),
●indexed with a 16-bit offset,
The source coding syntax is:
(X) or (Y) for no-offset indexing.
(offset,X) or (offset,Y)for indexed with offset.
Some instructions (such as ld A or add) support the first three types of indexed mode. Some
ST7 instructions (such as inc) only support the first two types (i.e. indexed without offset and
indexed with 8-bit unsigned offset). Examples:
2.8 Relative mode
This addressing mode is used to modify the Program Counter (PC) register value by adding an
8-bit signed offset to it (i.e. in the range -128 to +127). The relative addressing mode is made
up of two sub-modes:
●relative (direct)—where the offset is following the op-code.
●relative (indirect)—where the offset is defined in memory, whose address follows the op-
code.
Relative mode is used by the instructions JRxx, CALLR, and BTJx.
At source coding level, the target label is specified (and the assembler computes the
displacement).
2.9 High, low addressing modes
In some instances, it may be necessary to access the highest part of an address (8 highest
bits) or the lowest part of an address (8 lowest bits) as well. For this feature, the syntax is the
following one:
<expression>
where expression is:
symbol.H (highest part) , or
symbol.L (lowest part).
ld A,(X) ; no-offset mode
ld A,(0,X) ; 8-bit offset mode
ld A,(127,X) ; 8-bit offset mode
ld A,(259,X) ; 16-bit offset mode

2 ST7 Addressing Modes ST7 Assembler Linker
12/92 UM0144
Examples:
For more information about each instruction and the various addressing modes, refer to the
ST7 Programming Manual
, which can be downloaded from the Internet at www.st.com/mcu.
lab12 equ $0012
nop
ld A,#lab12.h ; load A with $00
ld A,#lab12.l ; load A with $12

ST7 Assembler Linker 3 ST7 Assembler
UM0144 13/92
3 ST7 Assembler
3.1 Overview
The ST7 Assembler program is a cross-assembler, meaning that it produces code for a target
machine—an ST7 microprocessor—which is different from the host machine.
The assembler turns your source code files into relocatable 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 on page 78.
To produce code ready for execution, you must run the assembler (ASM), the linker (LYN), and
the object code formatter (OBSEND).
3.2 Source files
Source program code is written in the ST7 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 to the ST7 Assembler language, refer to the
ST7 Programming
Manual
.
3.3 Assembly source code format
The first line of an assembly 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
Assembler’s executable is located.
The '.tab' suffix may be left out—as the assembler only looks for this file type.
For example, the first line of your source code might look like:
c:\st7tools\asm\st7\
If the file st7.tab can't 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.

3 ST7 Assembler ST7 Assembler Linker
14/92 UM0144
For example:
The next sections describe the main components of a source code file.
3.3.1 About labels
Label structure
Labels must start in column one. A label may contain up to 30 of any of the following
characters:
●Upper Case letters (A-Z)
●Lower case letters (a-z)
●Digits (0-9)
●Underscore (_)
The first letter of a label must be a letter or an underscore. Note that upper and lower case are
treated differently because the assembler is case sensitive.
Upon assembly, any label that exceeds 30 characters is truncated and a warning alerts the
user that this has occurred. When truncated, if two of more labels have the same name, a
phase inconsistency error is generated.
When labels are defined, several attributes are defined along with the value.
These are:
●Size (Byte, Word or Long)
●Relativity (Linker Relative or Absolute)
●Scope (Internally or Externally defined)
The function of each attribute is explained in the following sections.
Label size
Defining a label’s size allows the assembler to determine what kind of addressing mode to
choose even if the value associated with the label is undefined.
The default size of the memory location for a label is word (2 bytes). Whenever the label has no
suffix, then the default size is assumed. The directives BYTES, WORDS and LONGS (4
bytes) allow you to change the default.
Regardless of the default size, you can define the size for a specific label by adding a suffix to
it: .b for byte, .w for word and .l for long. The suffix is not used when the label is referred to.
Using of any suffixes other than .b, .w and .l will result in an error upon assembly.
examp ld A,$ffff ; long addressing mode
comments
operand
opcode
label
separator

ST7 Assembler Linker 3 ST7 Assembler
UM0144 15/92
For example:
Label relativity
There are two sorts of labels:
absolute
labels and
relative
labels.
●
Absolute
labels are usually assigned to constants, such as IO port addresses, or common
values used within the program.
●
Relative
labels are defined as (or derived from) an
external
label or a label derived from
the position of some program code. They are exclusively used for labels defined within
pieces of program or data.
For example:
Only the linker can sort out the actual address of the code, as the assembler has no idea how
many segments precede this one in the class. At assembly time, labels such as 'start' or 'loop'
are actually allocated 'blank' values ($0000). These values will be filled later by the linker.
Labels such as 'count' or 'ioport', which were defined absolutely will be filled by the assembler.
Source code lines that have arguments containing relative labels are marked with an 'R' on the
listing, showing that they are 'linker relative'. Segments are discussed in
Section 3.4
on
page 22.
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
lab equ 0 ; absolute label ‘count’
ioport equ $8000 ; absolute word label ‘ioport’
segment ‘eprom’
start ld X,#count
ld A,#’*’
loop ld ioport,A
dec X
jrne loop
stop jp stop ; then loop for ever

3 ST7 Assembler ST7 Assembler Linker
16/92 UM0144
Label scope
Often, in multi-module programs, a piece of code will need to refer to a label that is actually
defined in another module. To do this, the module that exports the label must declare it
PUBLIC, and the module which imports the label must declare it EXTERN. The two directives
EXTERN and PUBLIC go together as a pair.
Most labels in a program will be of no interest for other pieces of the program—these are
known as 'internal' labels since they are only used in the module where they are defined.
Labels are 'internal' by default.
Here are two incomplete example modules that pass labels between them:
As you can see, module 1 refers to the '_sig2' subroutine which is defined in module 2. Note
that when module 1 refers to the '_sig2' label in an EXTERN directive it specifies a WORD size
with the '.w' suffix. Because the assembler cannot look up the definition of '_sig2' it has to be
told its address size explicitly. It doesn't need to be told relativity: all external labels are
assumed to be relative.
Absolute labels declared between modules should be defined in an INCLUDE file that is called
by all modules in the program; this idea of using INCLUDE files is very important since it can
reduce the number of PUBLIC symbols—and therefore the link time—significantly.
Lines in the source code listing which refer to external labels are marked with an X and given
'empty' values for the linker to fill.
module 1
EXTERN _sig1.w ; import _sig1
EXTERN _sig2.w ; import _sig2
PUBLIC _handlers ; export _handlers
segment byte ‘P’
_handlers: ; define _handlers
jp _sig1 ; refer to _sig1
jp _sig2 ; refer to _sig2
end
module 2
EXTERN _handlers.w ; import _handlers (addr. is a word)
PUBLIC _sig2 ; export _sig2
segment byte ‘P’
_sig2: ; define _sig2
...
call _handlers ; refer to _handlers
...
ret
end

ST7 Assembler Linker 3 ST7 Assembler
UM0144 17/92
As a short cut, labels may be declared as PUBLIC by preceding them with a '.' at their
definition. If this is done the label name need not be given in a PUBLIC directive. For example,
the following code fragment declares the label 'lab4' as PUBLIC automatically:
3.3.2 About 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 (i.e. label, if there is one) by a space or a
tab.
A comprehensive Opcode description can be found in the
ST7 Programming Manual
.
Macros are discussed in
Section 3.5
on page 26.
Directives are discussed in on page 48.
3.3.3 About 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.
Number and address representation
By default, the representation of numbers and addresses follows the MOTOROLA syntax.
When you want to use hexadecimal number with instructions or labels, they must be preceded
by $. When nothing is specified, the default base is decimal.
For example:
lab3 ld A,#0
ret
.lab4 nop
ret
lab03 equ 10 ; decimal 10
lab04 equ $10 ; hexadecimal 10
ld A,$ffff ; long addressing mode
ld A,#$cb ; immediate addressing mode
ld A,#100 ; decimal representation

3 ST7 Assembler ST7 Assembler Linker
18/92 UM0144
You can change the Motorola format representation by using directives (.INTEL, .TEXAS) to
indicate the new setting format. For more information, refer to on page 48.
Caution: Addresses for SEGMENT definition are always given in hexadecimal:
segment byte at: 100-1FF 'test'
The segment 'test' is defined within the 256-511 address range.
Numeric constants and radix
Constants may need special characters to define the radix of the given number.
The assembler supports the MOTOROLA format by default. INTEL, TEXAS, ZILOG formats
are also available if the format is forced by .INTEL .TEXAS or .ZILOG directives.
Table 3
on
page 18 shows a summary of these formats.
Note: Decimal constants are always the default, and require no special characters.
String constants
String constants are strings of ASCII characters surrounded by double quotes.
For example:
ASCII character constants
The assembler's arithmetic parser also handles ASCII characters in single quotes, returning
the ASCII of the given character(s).
For example:
Table 3. Numeric constants and radix formats
Format Hex Binary Octal Current PC
Motorola $ABCD or &ABCD %100 ~665 *
(use MULT for
MULTIPLY)
Intel 0ABCDh 100b 665o
or
665q
$
Texas >ABCD ?100 ~665 $
Zilog %ABCD %(2)100 %(8)665 $
“This is an ASCII string”
‘A’ $41
‘6’ $06
‘AB’ $4142

ST7 Assembler Linker 3 ST7 Assembler
UM0144 19/92
Up to 4 characters may be used within a single pair of quotes to give a long constant. The
following special sequences are used to denote special characters:
Program counter reference
The current value of the program counter (PC) can be specified by an asterisk "*".
For example:
Expressions and operators
Expressions are numeric values that may be made up from labels, constants, brackets and
operators.
Labels and constants have been discussed in previous paragraphs.
Arithmetic brackets are allowed up to 8 nested levels—the curly braces {} are used instead
of the common “()” because instructions may use a parenthesis to denote indexed addressing
modes.
‘\b’ $7F backspace
‘\f’ $0C formfeed
‘\n’ $0A linefeed
‘\r’ $0D carriage return
‘\t’ $09 tabulation
‘\\’ $5C slash
‘\’ $27 single-quote
‘\0’ $00 null
‘\”’ $22 double-quote
lab05 jra *

3 ST7 Assembler ST7 Assembler Linker
20/92 UM0144
Operators have 4 levels of precedence. Operators in level #1 (listed in
Ta bl e 4
) take
precedence over operators in level #2 (listed in
Tab le 5
), and so on. In each level, operators
have same precedence—they are evaluated from left to right.
Table 4. Level 1 operators
Operation Result, level #1
-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
Table 5. Level 2 operators
Operation Result, level #2
a/b a divided by b
a div b a divided by b
Table 6. Level 3 operators
Operation Result, level #3
a * b a multiplied by b
a mult b as above for motorola (character * is reserved)
Table of contents
Popular Microcontroller manuals by other brands

NXP Semiconductors
NXP Semiconductors Freescale DEMOEM MCF51EM Lab Tutorial

Silicon Laboratories
Silicon Laboratories SLSTK3701A user guide

ST
ST STEVAL-FKI433V1 user manual

Abov
Abov MC97F6108A user manual

Freescale Semiconductor
Freescale Semiconductor *KE02 Series Technical data

QRP Labs
QRP Labs Ultimate3S manual