Escolar Documentos
Profissional Documentos
Cultura Documentos
Reference Guide
AARM-6
COPYRIGHT NOTICE
Copyright 2002 IAR Systems. All rights reserved.
No part of this document may be reproduced without the prior written consent of IAR
Systems. The software described in this document is furnished under a license and
may only be used or copied in accordance with the terms of such a license.
DISCLAIMER
The information in this document is subject to change without notice and does not
represent a commitment on any part of IAR Systems. While the information contained
herein is assumed to be accurate, IAR Systems assumes no responsibility for any
errors or omissions.
In no event shall IAR Systems, its employees, its contractors, or the authors of this
document be liable for special, direct, indirect, or consequential damage, losses, costs,
charges, claims, demands, claim for lost profits, fees, or expenses of any nature or
kind.
TRADEMARKS
IAR, IAR Embedded Workbench, IAR XLINK Linker, and IAR XLIB Librarian are
trademarks owned by IAR Systems. C-SPY is a trademark registered in Sweden by
IAR Systems.
ARM and Thumb are registered trademarks of Advanced RISC Machines Ltd.
Microsoft and Windows are registered trademarks of Microsoft Corporation.
All other product names are trademarks or registered trademarks of their respective
owners.
EDITION NOTICE
Latest edition: June 2002
Part number: AARM-6
This guide replaces the ARM IAR Assembler Reference Guide, part number
AARM-5.
AARM-6
Contents
Tables ..................................................................................................................................... vii
Preface .................................................................................................................................. ix
Who should read this guide ..........................................................................ix
How to use this guide ........................................................................................ix
What this guide contains ................................................................................ix
Other documentation ........................................................................................x
Document conventions .....................................................................................x
Assembler options
.................................................................................................. 9
iii
AARM-6
Assembler operators
......................................................................................... 23
Assembler directives
.......................................................................................... 37
iv Reference Guide
AARM-6
Contents
AARM-6
Examples ......................................................................................................... 78
Assembler pseudo-instructions
............................................................ 97
Summary .................................................................................................................. 97
Descriptions of pseudo-instructions ...................................................... 98
Assembler diagnostics
.................................................................................... 105
........................................ 107
Index
vi Reference Guide
AARM-6
.................................................................................................................................... 113
Tables
1: Typographic conventions used in this guide .......................................................... x
2: Integer constant formats ......................................................................................... 4
3: ASCII character constant formats .......................................................................... 4
4: Floating-point constants ......................................................................................... 5
5: Predefined symbols ................................................................................................ 5
6: Predefined register symbols ................................................................................... 7
7: Assembler error return codes ............................................................................... 10
8: Asssembler environment variables ...................................................................... 10
9: Assembler options summary ................................................................................ 11
10: Conditional list (-c) ............................................................................................ 12
11: Generating debug information (-r) ..................................................................... 19
12: Controlling case sensitivity in user symbols (-s) ............................................... 19
13: Disabling assembler warnings (-w) .................................................................... 20
14: Including cross-references in assembler list file (-x) ......................................... 21
15: Operator synonyms ............................................................................................ 25
16: Assembler directives summary .......................................................................... 37
17: Assembler directive parameters ......................................................................... 41
18: Module control directives .................................................................................. 42
19: Symbol control directives .................................................................................. 45
20: Mode control directives ..................................................................................... 46
21: Segment control directives ................................................................................. 48
22: Value assignment directives ............................................................................... 53
23: Conditional assembly directives ........................................................................ 57
24: Macro processing directives ............................................................................... 59
25: Listing control directives ................................................................................... 68
26: C-style preprocessor directives .......................................................................... 73
27: Data definition or allocation directives .............................................................. 77
28: Assembler control directives .............................................................................. 80
29: Call frame information directives ...................................................................... 83
30: Unary operators in CFI expressions ................................................................... 92
31: Binary operators in CFI expressions .................................................................. 92
vii
AARM-6
AARM-6
Preface
Welcome to the ARM IAR Assembler Reference Guide. The purpose of this
guide is to provide you with detailed reference information that can help you
to use the ARM IAR Assembler to best suit your application requirements.
The architecture and instruction set of the ARM core; refer to the documentation
from Advanced RISC Machines Ltd for detailed information
Assembler options first explains how to set the assembler options from the
command line and how to use environment variables. It then gives an alphabetical
summary of the assembler options, and contains detailed reference information
about each option.
Assembler operators gives a summary of the assembler operators, arranged in
order of precedence, and provides reference information about each operator.
Assembler directives gives an alphabetical summary of the assembler directives,
and provides detailed reference information about each of the directives, classified
into groups according to their function.
ix
AARM-6
Other documentation
Assembler diagnostics contains information about the formats and severity levels
of diagnostic messages.
Migrating to the ARM IAR Assembler contains information that is useful when
you want to use the ARM IAR Assembler with source code that was originally
developed for another assembler.
Other documentation
The complete set of IAR Systems development tools for the ARM cores is described
in a series of guides. For information about:
Using the IAR Embedded Workbench and the IAR C-SPY Debugger, refer to
the ARM IAR Embedded Workbench User Guide
Programming for the ARM IAR C/EC++ Compiler, refer to the ARM IAR
C/EC++ Compiler Reference Guide
Using the IAR XLINK Linker and the IAR XLIB Librarian, refer to the IAR
XLINK Linker and IAR XLIB Librarian Reference Guide.
Using the IAR DLIB Library, refer to the C++ Library Reference.
Online versions of these guides are delivered on the installation media and available
from the Help menu in the IAR Embedded Workbench. Some of them are also
delivered as printed books.
Document conventions
This guide uses the following typographic conventions:
Style
Used for
computer
parameter
[option]
{a | b | c}
Alternatives in a command.
bold
reference
x Reference Guide
AARM-6
Preface
Style
Used for
xi
AARM-6
Document conventions
AARM-6
Source format
The format of an assembler source line is as follows:
[label [:]] [operation] [operands] [; comment]
operation
operands
comment
Assembler expressions
Expressions can consist of operands and operators. The assembler will accept a wide
range of expressions, including both arithmetic and logical operations. All operators
use 32-bit twos complement integers, and range checking is only performed when a
value is used for generating code.
AARM-6
Assembler expressions
Expressions are evaluated from left to right, unless this order is overridden by the
priority of operators; see also Precedence of operators, page 23.
The following operands are valid in an expression:
2 Reference Guide
AARM-6
MOV
MOV
LDR
LDR
LDR
LDR
LDR
LDR
LDR
LDR
LDR
LDR
END
Note: At assembly time, there will be no range check. The range check will occur at
link time and, if the values are too large, there will be a linker error.
SYMBOLS
User-defined symbols can be up to 255 characters long, and all characters are
significant.
Symbols must begin with a letter, az or AZ, ? (question mark), or _ (underscore).
They can include the digits 09 and $ (dollar).
Symbols may contain any printable characters if they are quoted with ` (backquote).
For example:
`strange#label`
For built-in symbols like instructions, registers, operators, and directives case is
insignificant. For user-defined symbols case is by default significant but can be turned
on and off using the Case sensitive user symbols (-s) assembler option. See page 19
for additional information.
LABELS
Symbols used for memory locations are referred to as labels.
AARM-6
Assembler expressions
INTEGER CONSTANTS
Since all IAR Systems assemblers use 32-bit twos complement internal arithmetic,
integers have a (signed) range from -2147483648 to 2147483647.
Constants are written as a sequence of digits with an optional - (minus) sign in front
to indicate a negative number. Commas and decimal points are not permitted.
The following types of number representation are supported:
Integer type
Example
Binary
1010b, b'1010'
Octal
1234q, q'1234'
Decimal
Hexadecimal
Note: Both the prefix and the suffix can be written with either uppercase or lowercase
letters.
Value
'ABCD'
"ABCD"
'A''B'
A'B
'A'''
A'
'''' (4 quotes)
'
'' (2 quotes)
""
\'
'
\\
4 Reference Guide
AARM-6
FLOATING-POINT CONSTANTS
The ARM IAR Assembler will accept floating-point values as constants and convert
them into IEEE single-precision (signed 32-bit) floating-point format or fractional
format.
Floating-point numbers can be written in the format:
[+|-][digits].[digits][{E|e}[+|-]digits]
Value
10.23
1.023 x 101
1.23456E-24
1.23456 x 10-24
1.0E3
1.0 x 103
PREDEFINED SYMBOLS
The ARM IAR Assembler defines a set of symbols for use in assembler source files.
The symbols provide information about the current assembly, allowing you to test
them in preprocessor directives or include them in the assembled code. The strings
returned by the assembler are enclosed in double quotes.
The following predefined symbols are avilable:
Symbol
Value
__BIG_ENDIAN__
__DATE__
__FILE__
AARM-6
Assembler expressions
Symbol
Value
__IAR_SYSTEMS_ASM__
__LINE__
__LITTLE_ENDIAN__
__TID__
__TIME__
__VER__
Notice that __TID__ is related to the predefined symbol __TID__ in the ARM IAR
C/EC++ Compiler. It is described in the ARM IAR C/EC++ Compiler Reference
Guide.
tim
DATA
DC8 __TIME__ ; time string
CODE32
ADR R0, tim ; load address of string
BL printstr ; routine to print string
END
6 Reference Guide
AARM-6
Register symbols
The following table shows the existing predefined register symbols:
Name
Address size
Description
R0R12
32 bits
R13 (SP)
32 bits
Stack pointer
R14 (LR)
32 bits
Link register
R15 (PC)
32 bits
Program counter
CPSR
32 bits
SPSR
32 bits
Notice that only consecutive registers can be specified in register pairs. The upper odd
register should be entered to the left of the colon, and the lower even register to the
right.
Programming hints
This section gives hints on how to write efficient code for the ARM IAR Assembler.
For information about projects including both assembler and C/Embedded C++
source files, see the ARM IAR C/EC++ Compiler Reference Guide.
AARM-6
Output formats
Since the header files are also intended to be used with the ARM IAR C/EC++
Compiler, ICCARM, the SFR declarations are made with macros. The macros that
convert the declaration to assembler or compiler syntax are defined in the
io_macros.h file.
The header files are also suitable to use as templates, when creating new header files
for other ARM derivatives.
Example
The USART write address 0xFFFD0000 of the ARM7TDMI core is defined in the
ioat91m40400.h file as:
__IO_REG32_BIT(__US_CR,0xfffd0000,__WRITE,__usartcr_bits)
If any assembler-specific additions are needed in the header file, these can be added
easily in the assembler-specific part of the file:
#ifdef __IAR_SYSTEMS_ASM__
(assembler-specific defines)
#endif
Output formats
The relocatable and absolute output is in the same format for all IAR assemblers,
because object code is always intended for processing with the IAR XLINK Linker.
In absolute formats the output from XLINK is, however, normally compatible with the
chip vendors debugger programs (monitors), as well as with PROM programmers
and stand-alone emulators from independent sources.
8 Reference Guide
AARM-6
Assembler options
This chapter first explains how to set the options from the command line, and
gives an alphabetical summary of the assembler options. It then provides
detailed reference information for each assembler option.
The ARM IAR Embedded Workbench User Guide describes how to set
assembler options in the IAR Embedded Workbench, and gives reference
information about the available options.
Some options accept a filename, included after the option letter with a separating
space. For example, to generate a list file with the name list.lst:
aarm power2 -l list.lst
Some other options accept a string that is not a filename. This is included after the
option letter, but without a space. For example, to generate a list file to the default
filename but in the subdirectory named list:
aarm power2 -Llist\
Note: The subdirectory you specify must already exist. The trailing backslash is
required because the parameter is prepended to the default filename.
AARM-6
By default, extended command line files have the extension xcl, and can be specified
using the -f command line option. For example, to read the command line options
from extend.xcl, enter:
aarm -f extend.xcl
Description
Description
ASMARM
set AARM_INC=c:\myinc\
Table 8: Asssembler environment variables
For example, setting the following environment variable will always generate a list
file with the name temp.lst:
ASMARM=-l temp.lst
For information about the environment variables used by the IAR XLINK Linker and
the IAR XLIB Librarian, see the IAR XLINK Linker and IAR XLIB Librarian
Reference Guide.
10 Reference Guide
AARM-6
Assembler options
Description
-B
-b
-c{DMEAO}
Conditional list
--cpu
Core configuration
-Dsymbol[=value]
Defines a symbol
-Enumber
-e
-G
-Iprefix
Includes paths
-i
#included text
-j
-L[prefix]
-l filename
-Mab
-N
-Oprefix
-o filename
-plines
Lines/page
-r[en]
-S
-s{+|-}
-tn
Tab spacing
-Usymbol
Undefines a symbol
-w[string][s]
Disables warnings
-x{DI2}
Includes cross-references
11
AARM-6
-B -B
Use this option to make the assembler print macro execution information to the
standard output stream on every call of a macro. The information consists of:
This option is mainly used in conjunction with the list file options -L or -l; for
additional information, see page 16.
This option is identical to the Macro execution info option in the AARM category in
the IAR Embedded Workbench.
-b -b
This option causes the object file to be a library module rather than a program module.
By default, the assembler produces a program module ready to be linked with the IAR
XLINK Linker. Use the -b option if you instead want the assembler to make a library
module for use with XLIB.
If the NAME directive is used in the source (to specify the name of the program
module), the -b option is ignored, i.e. the assembler produces a program module
regardless of the -b option.
This option is identical to the Make a LIBRARY module option in the AARM
category in the IAR Embedded Workbench.
-c -c{DMEAO}
Use this option to control the contents of the assembler list file. This option is mainly
used in conjunction with the list file options -L and -l; see page 16 for additional
information.
The following table shows the available parameters:
Command line option
Description
-cD
12 Reference Guide
AARM-6
Assembler options
Description
-cM
Macro definitions
-cE
No macro expansions
-cA
-cO
Multiline code
This option is related to the List options in the AARM category in the IAR Embedded
Workbench.
Use the --cpu option to specify the target core and get the correct instruction set.
Valid values for <target core> are target values such as ARM7TDMI and
architecture versions, e.g. 4T. ARM7TDMI is the default.
-D Dsymbol[=value]
Use this option to define a preprocessor symbol with the name symbol and the value
value. If no value is specified, 1 is used.
The -D option allows you to specify a value or choice on the command line instead of
in the source file.
Example
For example, you could arrange your source to produce either the test or production
version of your program dependent on whether the symbol testver was defined. To
do this, use include sections such as:
#ifdef testver
...
; additional code lines for test version only
#endif
aarm prog
aarm prog -Dtestver
Alternatively, your source might use a variable that you need to change often. You can
then leave the variable undefined in the source, and use -D to specify the value on the
command line; for example:
aarm prog -Dframerate=3
13
AARM-6
This option is identical to the #define option in the AARM category in the
IAR Embedded Workbench.
-E -Enumber
This option specifies the maximum number of errors that the assembler report will
report.
By default, the maximum number is 100. The -E option allows you to decrease or
increase this number to see more or fewer errors in a single assembly.
This option is identical to the Max number of errors option in the AARM category
in the IAR Embedded Workbench.
-e -e
This option causes the assembler to generate code and data in big-endian byte order.
The default byte order is little-endian.
This option is related to the Target options in the General category in the
IAR Embedded Workbench.
--endian --endian
This option specifies the byte order of the generated code and data.
-f -f extend.xcl
This option extends the command line with text read from the file named
extend.xcl. Notice that there must be a space between the option itself and the
filename.
The -f option is particularly useful where there is a large number of options which
are more conveniently placed in a file than on the command line itself.
Example
To run the assembler with further options taken from the file extend.xcl, use:
aarm prog -f extend.xcl
14 Reference Guide
AARM-6
Assembler options
-G -G
This option causes the assembler to read the source from the standard input stream,
rather than from a specified source file.
When -G is used, no source filename may be specified.
-I -Iprefix
Use this option to specify paths to be used by the preprocessor by adding the
#include file search prefix prefix.
By default, the assembler searches for #include files only in the current working
directory and in the paths specified in the AARM_INC environment variable. The -I
option allows you to give the assembler the names of directories where it will also
search if it fails to find the file in the current working directory.
Example
Using the options:
-Ic:\global\ -Ic:\thisproj\headers\
in the source, will make the assembler search first in the current directory, then in the
directory c:\global\, and finally in the directory c:\thisproj\headers\
provided that the AARM_INC environment variable is set.
This option is related to the #include option in the AARM category in the
IAR Embedded Workbench.
-i -i
15
AARM-6
-j -j
-L -L[prefix]
By default the assembler does not generate a list file. Use this option to make the
assembler generate one and sent it to file [prefix]sourcename.lst.
To simply generate a listing, use the -L option without a prefix. The listing is sent to
the file with the same name as the source, but the extension will be lst.
The -L option lets you specify a prefix, for example to direct the list file to a
subdirectory. Notice that you must not include a space before the prefix.
-L may not be used at the same time as -l.
Example
To send the list file to list\prog.lst rather than the default prog.lst:
aarm prog -Llist\
This option is related to the List options in the AARM category in the IAR Embedded
Workbench.
-l -l filename
Use this option to make the assembler generate a listing and send it to the file
filename. If no extension is specified, lst is used. Notice that you must include a
space before the filename.
By default, the assembler does not generate a list file. The -l option generates a
listing, and directs it to a specific file. To generate a list file with the default filename,
use the -L option instead.
This option is related to the List options in the AARM category in the IAR Embedded
Workbench.
16 Reference Guide
AARM-6
Assembler options
-M -Mab
This option sets the characters to be used as left and right quotes of each macro
argument to a and b respectively.
By default, the characters are < and >. The -M option allows you to change the quote
characters to suit an alternative convention or simply to allow a macro argument to
contain < or > themselves.
Example
For example, using the option:
-M[]
This option is identical to the Macro quote chars option in the AARM category in
the IAR Embedded Workbench.
-N -N
Use this option to omit the header section that is printed by default in the beginning of
the list file.
This option is useful in conjunction with the list file options -L or -l; see page 16 for
additional information.
This option is related to the List file option in the AARM category in the
IAR Embedded Workbench.
-O -Oprefix
Use this option to set the prefix to be used on the name of the object file. Notice that
you must not include a space before the prefix.
By default the prefix is null, so the object filename corresponds to the source filename
(unless -o is used). The -O option lets you specify a prefix, for example to direct the
object file to a subdirectory.
Notice that -O may not be used at the same time as -o.
17
AARM-6
Example
To send the object code to the file obj\prog.r79 rather than to the default file
prog.r79:
aarm prog -Oobj\
This option is related to the Output directories option in the General category in the
IAR Embedded Workbench.
-o -o filename
This option sets the filename to be used for the object file. Notice that you must
include a space before the filename. If no extension is specified, r79 is used.
The option -o may not be used at the same time as the option -O.
Example
For example, the following command puts the object code to the file obj.r79 instead
of the default prog.r79:
aarm prog -o obj
Notice that you must include a space between the option itself and the filename.
This option is related to the filename and directory that you specify when creating a
new source file or project in the IAR Embedded Workbench.
-p -plines
The -p option sets the number of lines per page to lines, which must be in the range
10 to 150.
This option is used in conjunction with the list options -L or -l; see page 16 for
additional information.
This option is identical to the Lines/page option in the AARM category in the
IAR Embedded Workbench.
-r -r[en]
The -r option makes the assembler generate debug information that allows a
symbolic debugger such as C-SPY to be used on the program.
By default, the assembler does not generate debug information, to reduce the size and
link time of the object file. You must use the -r option if you want to use a debugger
with the program.
18 Reference Guide
AARM-6
Assembler options
Description
-re
-rn
This option is identical to the Generate debug information option in the AARM
category in the IAR Embedded Workbench.
-S -S
The -S option causes the assembler to operate without sending any messages to the
standard output stream.
By default, the assembler sends various insignificant messages via the standard output
stream. Use the -S option to prevent this.
The assembler sends error and warning messages to the error output stream, so they
are displayed regardless of this setting.
-s -s{+|-}
Use the -s option to control whether the assembler is sensitive to the case of user
symbols:
Command line option
Description
-s+
-s-
By default, case sensitivity is on. This means that, for example, LABEL and label
refer to different symbols. Use -s- to turn case sensitivity off, in which case LABEL
and label will refer to the same symbol.
This option is identical to the Case sensitive user symbols option in the AARM
category in the IAR Embedded Workbench.
-t -tn
By default the assembler sets 8 character positions per tab stop. The -t option allows
you to specify a tab spacing to n, which must be in the range 2 to 9.
19
AARM-6
This option is useful in conjunction with the list options -L or -l; see page 16 for
additional information.
This option is identical to the Tab spacing option in the AARM category in the
IAR Embedded Workbench.
-U -Usymbol
This option is identical to the #undef option in the AARM category in the
IAR Embedded Workbench.
-w -w[string][s]
Description
-w+
-w-
-w+n
-w-n
-w+m-n
Enables warnings m to n.
-w-m-n
Disables warnings m to n.
20 Reference Guide
AARM-6
Assembler options
By default, the assembler generates exit code 0 for warnings. Use the -ws option to
generate exit code 1 if a warning message is produced.
Example
To disable just warning 0 (unreferenced label), use the following command:
aarm prog -w-0
This option is identical to the Warnings option in the AARM category in the
IAR Embedded Workbench.
-x -x{DI2}
Use this option to make the assembler include a cross-reference table at the end of the
list file.
This option is useful in conjunction with the list options -L or -l; see page 16 for
additional information.
The following parameters are available:
Command line option
Description
-xD
#defines
-xI
Internal symbols
-x2
This option is identical to the Include cross-reference option in the AARM category
in the IAR Embedded Workbench.
21
AARM-6
22 Reference Guide
AARM-6
Assembler operators
This chapter first describes the precedence of the assembler operators, and
then summarizes the operators, classified according to their precedence.
Finally, this chapter provides reference information about each operator,
presented in alphabetical order.
Precedence of operators
Each operator has a precedence number assigned to it that determines the order in
which the operator and its operands are evaluated. The precedence numbers range
from 1 (the highest precedence, i.e. first evaluated) to 7 (the lowest precedence, i.e.
last evaluated).
The following rules determine how expressions are evaluated:
The highest precedence operators are evaluated first, then the second highest
precedence operators, and so on until the lowest precedence operators are
evaluated.
Operators of equal precedence are evaluated from left to right in the expression.
Parentheses ( and ) can be used for grouping operators and operands and for
controlling the order in which the expressions are evaluated. For example, the
following expression evaluates to 1:
7/(1+(2*3))
UNARY OPERATORS 1
+
Unary plus.
Unary minus.
Logical NOT.
Bitwise NOT.
LOW
Low byte.
HIGH
High byte.
BYTE1
First byte.
23
AARM-6
BYTE2
Second byte.
BYTE3
Third byte.
BYTE4
Fourth byte
LWRD
Low word.
HWRD
High word.
DATE
Current time/date.
SFB
Segment begin.
SFE
Segment end.
SIZEOF
Segment size.
Multiplication.
Division.
Modulo.
Addition.
Subtraction.
SHIFT OPERATORS 4
>>
<<
AND OPERATORS 5
&&
Logical AND.
&
Bitwise AND.
OR OPERATORS 6
24 Reference Guide
AARM-6
||
Logical OR.
Bitwise OR.
XOR
Assembler operators
COMPARISON OPERATORS 7
=, ==
Equal.
<>, !=
Not equal.
>
Greater than.
<
Less than.
UGT
ULT
>=
<=
OPERATOR SYNONYMS
A number of operator synonyms have been defined for compatibility with other
assemblers. The operator synonyms are enabled by the option -j. For details, see the
chapter Migrating to the ARM IAR Assembler.
Operator synonym
Operator
Function
:AND:
&
Bitwise AND
:EOR:
Bitwise exclusive OR
:LAND:
&&
Logical AND
:LEOR:
XOR
Logical exclusive OR
:LNOT:
Logical NOT
:LOR:
||
Logical OR
:MOD:
Modulo
:NOT:
Bitwise NOT
:OR:
Bitwise OR
:SHL:
<<
:SHR:
>>
Note: The ARM operators and the operator synonyms may have different precedence.
For more information about the precedence of the operators and their synonyms, see
the following reference sections. See also the chapter Migrating to the ARM IAR
Assembler
25
AARM-6
Descriptions of operators
Descriptions of operators
The following sections give detailed descriptions of each assembler operator. See
Assembler expressions, page 1, for related information.
* Multiplication (2).
* produces the product of its two operands. The operands are taken as signed 32-bit
4
-4
+3
3*+2
3
6
+ Addition (3).
The + addition operator produces the sum of the two operands which surround it. The
operands are taken as signed 32-bit integers and the result is also a signed 32-bit
integer.
Examples
92+19
-2+2
-2+-2
111
0
-4
26 Reference Guide
AARM-6
Assembler operators
Subtraction (3).
The subtraction operator produces the difference when the right operand is taken away
from the left operand. The operands are taken as signed 32-bit integers and the result
is also signed 32-bit integer.
Examples
92-19
-2-2
-2--2
73
-4
0
/ Division (2).
/ produces the integer quotient of the left operand divided by the right operator. The
operands are taken as signed 32-bit integers and the result is also a signed 32-bit
integer.
Examples
9/2
-12/3
9/2*6
4
-4
24
operand.
Examples
1
0
0
-1 < 2
2 < 1
2 < 2
Examples
1 <= 2
2 <= 1
1 <= 1
1
0
1
27
AARM-6
Descriptions of operators
Examples
1 <> 2
1
2 <> 2
0
'A' <> 'B'
=, == Equal (7).
= evaluates to 1 (true) if its two operands are identical in value, or to 0 (false) if its two
1 = 2
0
2 == 2
1
'ABC' = 'ABCD'
operand.
Examples
0
1
0
-1 > 1
2 > 1
1 > 1
28 Reference Guide
AARM-6
0
1
1
Assembler operators
Use && to perform logical AND between its two integer operands. If both operands
are non-zero the result is 1; otherwise it is zero.
Note: The precedence of :LAND: is 8.
Examples
B1010 && B0011
B1010 && B0101
B1010 && B0000
1
1
0
B0010
B0000
B0OOO
B11111111111111111111111111110101
B1111
B1010
29
AARM-6
Descriptions of operators
B1111
B1001
Examples
BYTE1 0xABCD
0xCD
Examples
BYTE2 0x12345678
0x56
Examples
BYTE3 0x12345678
0x34
30 Reference Guide
AARM-6
Assembler operators
Examples
BYTE4 0x12345678
0x12
Use the DATE operator to specify when the current assembly began.
The DATE operator takes an absolute argument (expression) and returns:
DATE 1
DATE 2
DATE 3
DATE 4
DATE 5
DATE 6
Examples
To assemble the date of assembly:
today: DC8 DATE 5, DATE 4, DATE 3
Examples
HIGH 0xABCD
0xAB
Examples
HWRD 0x12345678
0x1234
31
AARM-6
Descriptions of operators
The result is the unsigned, 8-bit integer value of the lower order byte of the operand.
Examples
LOW 0xABCD
0xCD
Examples
LWRD 0x12345678
0x5678
operand. The operands are taken as signed 32-bit integers and the result is also a
signed 32-bit integer.
X % Y is equivalent to X-Y*(X/Y) using integer division.
Examples
0
5
1
2 % 2
12 % 7
3 % 2
||
0
1
32 Reference Guide
AARM-6
Assembler operators
Examples
B1010 || B0000
B0000 || B0000
1
0
Syntax
SFB(segment [{+ | -} offset])
Parameters
segment
offset
Description
SFB accepts a single operand to its right. The operand must be the name of a
relocatable segment.
The operator evaluates to the absolute address of the first byte of that segment. This
evaluation takes place at linking time.
Examples
NAME
RSEG
start: DC16
demo
CODE
SFB(CODE)
Even if the above code is linked with many other modules, start will still be set to
the address of the first byte of the segment.
SFE Segment end (1).
Syntax
SFE (segment [{+ | -} offset])
33
AARM-6
Descriptions of operators
Parameters
segment
offset
Description
SFE accepts a single operand to its right. The operand must be the name of a
relocatable segment. The operator evaluates to the segment start address plus the
segment size. This evaluation takes place at linking time.
Examples
end:
NAME
RSEG
DC16
demo
CODE
SFE(CODE)
Even if the above code is linked with many other modules, end will still be set to the
address of the last byte of the segment.
The size of the segment MY_SEGMENT can be calculated as:
SFE(MY_SEGMENT)-SFB(MY_SEGMENT)
Use << to shift the left operand, which is always treated as unsigned, to the left. The
number of bits to shift is specified by the right operand, interpreted as an integer value
between 0 and 32.
Examples
B00011100 << 3
B11100000
B00000111111111111 << 5
B11111111111100000
14 << 1
28
Use >> to shift the left operand, which is always treated as unsigned, to the right.
The number of bits to shift is specified by the right operand, interpreted as an integer
value between 0 and 32.
Note: The precedence of :SHR: is 2.5.
34 Reference Guide
AARM-6
Assembler operators
Examples
B01110000 >> 3
B00001110
B1111111111111111 >> 20
0
14 >> 1
7
Syntax
SIZEOF segment
Parameters
The name of a relocatable segment, which must be defined
before SIZEOF is used.
segment
Description
SIZEOF generates SFE-SFB for its argument, which should be the name of a
relocatable segment; i.e. it calculates the size in bytes of a segment. This is done when
modules are linked together.
Examples
NAME
RSEG
size: DC16
demo
CODE
SIZEOF CODE
1
1
2 UGT 1
-1 UGT 1
35
AARM-6
Descriptions of operators
Examples
1
0
1 ULT 2
-1 ULT 2
36 Reference Guide
AARM-6
0
1
Assembler directives
This chapter gives an alphabetical summary of the assembler directives. It then
describes the syntax conventions and provides detailed reference information
for each category of directives.
Summary of directives
The following table gives a summary of all the assembler directives.
Directive
Description
Section
Includes a file.
Assembler control
#define
C-style preprocessor
#elif
#else
C-style preprocessor
#endif
C-style preprocessor
#error
Generates an error.
C-style preprocessor
#if
C-style preprocessor
#ifdef
C-style preprocessor
#ifndef
C-style preprocessor
#include
Includes a file.
C-style preprocessor
#message
C-style preprocessor
#undef
Undefines a label.
C-style preprocessor
/*comment*/
Assembler control
//
Assembler control
Value assignment
ALIAS
Value assignment
ALIGNRAM
Segment control
ALIGNROM
Segment control
ASEG
Segment control
ASEGN
Segment control
ASSIGN
Value assignment
37
AARM-6
Summary of directives
Directive
Description
Section
CASEOFF
Assembler control
CASEON
Assembler control
CFI
Call-frame
information
CODE16
Mode control
CODE32
Mode control
COL
Listing control
COMMON
Segment control
DATA
Mode control
DC8
DC16
Data definition or
allocation
DC24
Data definition or
allocation
DC32
Data definition or
allocation
DCB
DCD
Data definition or
allocation
DCW
Data definition or
allocation
DEFINE
Value assignment
DF32
Data definition or
allocation
DF64
Data definition or
allocation
DS8
Data definition or
allocation
DS16
Data definition or
allocation
DS24
Data definition or
allocation
38 Reference Guide
AARM-6
Assembler directives
Directive
Description
Section
DS32
Data definition or
allocation
ELSE
Conditional assembly
ELSEIF
Conditional assembly
END
Module control
ENDIF
Ends an IF block.
Conditional assembly
ENDM
Macro processing
ENDMOD
Module control
ENDR
Macro processing
EQU
Value assignment
EVEN
Segment control
EXITM
Macro processing
EXPORT
Symbol control
EXTERN
Symbol control
EXTRN
Symbol control
IF
Conditional assembly
IMPORT
Symbol control
INCLUDE
Includes a file.
Assembler control
LIBRARY
Module control
LIMIT
Value assignment
LOCAL
Macro processing
LSTCND
Listing control
LSTCOD
Listing control
LSTEXP
Listing control
LSTMAC
Listing control
LSTOUT
Listing control
LSTPAG
Listing control
LSTREP
Listing control
LSTXRF
Listing control
39
AARM-6
Syntax conventions
Directive
Description
Section
LTORG
Assembler control
MACRO
Defines a macro.
Macro processing
MODULE
Module control
NAME
Module control
ODD
Segment control
ORG
Segment control
PAGE
Listing control
PAGSIZ
Listing control
PROGRAM
Module control
PUBLIC
Symbol control
RADIX
Assembler control
REPT
Macro processing
REPTC
Macro processing
REPTI
Macro processing
REQUIRE
Symbol control
RSEG
Segment control
RTMODEL
Module control
SET
Value assignment
SETA
Value assignment
STACK
Segment control
VAR
Value assignment
Syntax conventions
In the syntax definitions the following conventions are used:
Parameters, representing what you would type, are shown in italics. So, for
example, in:
ORG expr
expr represents an arbitrary expression.
40 Reference Guide
AARM-6
Assembler directives
Optional parameters are shown in square brackets. So, for example, in:
END [expr]
An ellipsis indicates that the previous item can be repeated an arbitrary number of
times. For example:
PUBLIC symbol [,symbol]
An optional label, which will assume the value and type of the current program
location counter (PLC), can precede all directives. For clarity, this is not included in
each syntax definition.
In addition, unless explicitly specified, all directives can be followed by a comment,
preceded by ; (semicolon).
PARAMETERS
The following table shows the correct form of the most commonly used types of
parameter:
Parameter
What it consists of
expr
label
A symbolic label.
symbol
An assembler symbol.
41
AARM-6
Description
END
ENDMOD
LIBRARY
MODULE
NAME
PROGRAM
RTMODEL
SYNTAX
END [label]
ENDMOD [label]
LIBRARY symbol [(expr)]
MODULE symbol [(expr)]
NAME symbol [(expr)]
PROGRAM symbol [(expr)]
RTMODEL key, value
PARAMETERS
42 Reference Guide
AARM-6
expr
key
label
symbol
Name assigned to module, used by XLINK and XLIB when processing object
files.
value
Assembler directives
DESCRIPTION
Beginning a program module
Use NAME to begin a program module, and to assign a name for future reference by the
IAR XLINK Linker and the IAR XLIB Librarian.
Program modules are unconditionally linked by XLINK, even if other modules do not
reference them.
Terminating a module
Use ENDMOD to define the end of a module.
At the beginning of a new module all user symbols are deleted, except for those
created by DEFINE, #define, or MACRO, the location counters are cleared, and
the mode is set to absolute.
Listing control directives remain in effect throughout the assembly.
Note: END must always be used in the last module, and there must not be any source
lines (except for comments and listing control directives) between an ENDMOD and a
MODULE directive.
If the NAME or MODULE directive is missing, the module will be assigned the name of
the source file and the attribute program.
43
AARM-6
MOD_1 and MOD_2 cannot be linked together since they have different values for
runtime model "foo".
MOD_1 and MOD_3 can be linked together since they have the same definition of
runtime model "bar" and no conflict in the definition of "foo".
MOD_2 and MOD_3 can be linked together since they have no runtime model
conflicts. The value "*" matches any runtime model value.
MODULE MOD_1
RTMODEL
"foo", "1"
RTMODEL
"bar", "XXX"
...
ENDMOD
MODULE MOD_2
RTMODEL
"foo", "2"
RTMODEL
"bar", "*"
...
ENDMOD
MODULE MOD_3
RTMODEL
"bar", "XXX"
...
END
44 Reference Guide
AARM-6
Assembler directives
Description
PUBLIC (EXPORT)
REQUIRE
SYNTAX
EXTERN symbol [,symbol]
PUBLIC symbol [,symbol]
REQUIRE symbol [,symbol]
PARAMETERS
symbol
DESCRIPTION
Exporting symbols to other modules
Use PUBLIC to make one or more symbols available to other modules. The symbols
declared as PUBLIC can only be assigned values by using them as labels. Symbols
declared PUBLIC can be relocated or absolute, and can also be used in expressions
(with the same rules as for other symbols).
The PUBLIC directive always exports full 32-bit values, which makes it feasible to use
global 32-bit constants also in assemblers for 8-bit and 16-bit processors. With the
LOW, HIGH, >>, and << operators, any part of such a constant can be loaded in an 8-bit
or 16-bit register or word.
There are no restrictions on the number of PUBLIC-declared symbols in a module.
Importing symbols
Use EXTERN to import an untyped external symbol.
The REQUIRE directive marks a symbol as referenced. This is useful if the segment
part containing the symbol must be loaded for the code containing the reference to
work, but the dependence is not otherwise evident.
45
AARM-6
EXAMPLES
The following example defines a subroutine to print an error message, and exports the
entry address err so that it can be called from other modules. It defines print as an
external routine; the address will be resolved at link time.
MODULE error
EXTERN print
PUBLIC err
CODE16
PUSH {LR}
err ADR R0,msg
BL print
POP {PC}
DATA
msg DC8 "**Error **"
RET
END
Description
CODE16
CODE32
DATA
SYNTAX
CODE16
CODE32
DATA
DESCRIPTION
Use CODE16 and CODE32 with the BX instruction (Branch and Exchange) to change
between the Thumb and ARM processor modes. The CODE16 and CODE32 mode
directives do not assemble to instructions that change the mode, they only instruct the
assembler how to interpret the following instructions.
46 Reference Guide
AARM-6
Assembler directives
Always use the DATA directive when defining data in a Thumb code segment with
DC8, DC16, or DC32, otherwise labels on the data will have bit 0 set.
Note: Be careful when porting assembler source code written for other assemblers.
AARM always sets bit 0 on Thumb code labels (local, external or public). See the
chapter Migrating to the ARM IAR Assembler for details.
EXAMPLES
Changing the processor mode
ADR R0, Into_THUMB
BX R0
CODE16
Into_THUMB
.
.
ADR R5, Back_to_ARM
BX R5
;
;
;
;
;
;
;
;
;
;
;
;
;
;
.
.
CODE32
Back_to_ARM
my_data_label1 DC32
my_data_label2 DC32
47
AARM-6
Description
ALIGNRAM
ALIGNROM
ASEG
ASEGN
COMMON
EVEN
ODD
ORG
RSEG
STACK
SYNTAX
ALIGN align [,value]
ASEG [start [(align)]]
ASEGN segment [:type], address
COMMON segment [:type] [(align)]
EVEN [value]
ODD [value]
ORG expr
RSEG segment [:type] [flag] [(align)]
STACK segment [:type] [(align)]
PARAMETERS
address
align
Exponent of the value to which the address should be aligned, in the range 0
to 30. For example, align 1 results in word alignment 2.
expr
flag
NOROOT
This segment part may be discarded by the linker even if no symbols in this
segment part are referred to. Normally all segment parts except startup
code and interrupt vectors should set this flag. The default mode is ROOT
which indicates that the segment part must not be discarded.
48 Reference Guide
AARM-6
Assembler directives
REORDER
Allows the linker to reorder segment parts. For a given segment, all segment
parts must specify the same state for this flag. The default mode is
NOREORDER which indicates that the segment parts must remain in order.
SORT
The linker will sort the segment parts in decreasing alignment order. For a
given segment, all segment parts must specify the same state for this flag.
The default mode is NOSORT which indicates that the segment parts will
not be sorted.
segment
start
A start address that has the same effect as using an ORG directive at the
beginning of the absolute segment.
type
The memory type, typically CODE, or DATA. In addition, any of the types
supported by the IAR XLINK Linker.
value
DESCRIPTION
Beginning an absolute segment
Use ASEG to set the absolute mode of assembly, which is the default at the beginning
of a module.
If the parameter is omitted, the start address of the first segment is 0, and subsequent
segments continue after the last address of the previous segment.
The ASEGN directive can be used to start a named absolute segment; it allows a
segment type to be specified.
49
AARM-6
Aligning a segment
Use ALIGNROM to align the program location counter to a specified address boundary.
The expression gives the power of two to which the program counter should be
aligned.
The alignment is made relative to the segment start; normally this means that the
segment alignment must be at least as large as that of the alignment directive to give
the desired result.
ALIGNROM aligns by inserting zero/filled bytes. The EVEN directive aligns the
program counter to an even address (which is equivalent to ALIGNROM 1) and the
ODD directive aligns the program counter to an odd address.
Use ALIGNRAM to align the program location counter to a specified address boundary.
The expression gives the power of two to which the program location counter should
be aligned. ALIGNRAM aligns by incrementing the data; no data is generated.
50 Reference Guide
AARM-6
Assembler directives
EXAMPLES
Beginning an absolute segment
The following example assembles a branch to the function main in address 0. On
reset, the chip starts execution at address 0:
MODULE reset
EXTERN main
ASEG
ORG 0
reset:
CODE32
B main
END
codeseg:CODE(2)
CODE32
main:
LDR
LDR
END
R0,=f1
PC,[R0]
; get address
; jump to it
51
AARM-6
parms
opers
STACK
DATA
DC8
DC8
END
rpnstack
100
100
count
up
down
NAME
COMMON
DATA
DC32
ENDMOD
NAME
COMMON
DATA
DC8
ORG
DC8
END
common1
dataseg(2)
1
common2
dataseg
1
.+2
1
Because the common segments have the same name, dataseg, the variables up and
down refer to the same locations in memory as the first and last bytes of the 4-byte
variable count.
Aligning a segment
This example starts a relocatable segment, moves to an even address, and adds some
data. It then aligns to a 64-byte boundary before creating a 64-byte table.
NAME
RSEG
target
align
dataseg (6) ; Start a relocatable data
; segment and verify that it
; is correctly aligned
DATA
DS16
1
ALIGNROM 6
results DS32
64
DS32
ALIGNROM 3
52 Reference Guide
AARM-6
;
;
;
;
Target is on an even
Zero fill to a 64-byte
boundary
Create a 64-byte table
Assembler directives
ages
DS32
END
64
Description
ALIAS
ASSIGN
DEFINE
EQU
LIMIT
SET
SETA
VAR
SYNTAX
label
label
label
label
label
LIMIT
label
label
label
= expr
ALIAS expr
ASSIGN expr
DEFINE expr
EQU expr
expr, min, max, message
SET expr
SETA expr
VAR expr
PARAMETERS
expr
label
Symbol to be defined.
message
min, max
53
AARM-6
DESCRIPTION
Defining a temporary value
Use either of ASSIGN and VAR to define a symbol that may be redefined, such as for
use with macro variables. Symbols defined with VAR cannot be declared PUBLIC.
EXAMPLES
Redefining a symbol
The following example uses SET to redefine the symbol cons in a loop to generate a
table of the first 8 powers of 3:
NAME
table
54 Reference Guide
AARM-6
SET
Assembler directives
DATA
cr_tabl 4
END table
00000000
00000000
00000001
00000000
00000000
00000000
00000003
00000004
00000004
00000004
00000009
00000008
00000008
00000008
0000001B
0000000C
0000000C
0000000C
00000051
00000010
00000010
00000010
00000010
00000010
00000010
00000010
00000010
00000010
00000010
00000010
cons
table:
NAME table
; Generate table of powers of 3
SET 1
cr_tabl 4
cr_tabl 4
SET cons*3
IF 4>1
cr_tabl 4-1
cr_tabl 4
SET cons*3
IF 4-1>1
cr_tabl 4-1-1
cr_tabl 4
SET cons*3
IF 4-1-1>1
cr_tabl 4-1-1-1
cr_tabl 4
SET cons*3
IF 4-1-1-1>1
cr_tabl 4-1-1-1-1
ENDIF
ENDM
ENDIF
ENDM
ENDIF
ENDM
ENDIF
ENDM
END table
01000000
cons
03000000
cons
09000000
cons
1B000000
cons
55
AARM-6
DAT
value
NAME
PUBLIC
CODE32
DEFINE
EQU
add1
add12
1
12
add12:
MOV
R0, #value
ADD
R0,R0, #DAT
MOV
PC, LR
ENDMOD
value
; Return
NAME
add2
PUBLIC add20
EQU
20
add20:
MOV
ADD
MOV
END
R0, #value
R0,R0, #DAT
PC, LR
; Return
The symbol DAT defined in module add12 is also available to module add20.
56 Reference Guide
AARM-6
VAR
23
speed,10,30,...speed out of range...
Assembler directives
Description
IF
ELSE
ELSEIF
ENDIF
Ends an IF block.
SYNTAX
IF condition
ELSE
ELSEIF condition
ENDIF
PARAMETERS
condition
string1=string2
string1<>string2
DESCRIPTION
Use the IF, ELSE, and ENDIF directives to control the assembly process at assembly
time. If the condition following the IF directive is not true, the subsequent instructions
will not generate any code (i.e. it will not be assembled or syntax checked) until an
ELSE or ENDIF directive is found.
Use ELSEIF to introduce a new condition after an IF directive. Conditional assembler
directives may be used anywhere in an assembly, but have their greatest use in
conjunction with macro processing.
57
AARM-6
All assembler directives (except END) as well as the inclusion of files may be disabled
by the conditional directives. Each IF directive must be terminated by an ENDIF
directive. The ELSE directive is optional, and if used, it must be inside an
IF...ENDIF block. IF...ENDIF and IF...ELSE...ENDIF blocks may be nested
to any level.
EXAMPLES
The following macro defines two different implementations of an addition depending
on the number of arguments used in the macro:
?add
CODE32
MACRO a,b,c
IF _args <3
ADD
a,a, #b
ELSE
ADD
a,b, #c
ENDIF
ENDM
If two macro-arguments are supplied then the first and second argument of the add
instruction are assumed to be the same:
main:
MOV
?add
?add
add
END
58 Reference Guide
AARM-6
R1,
R1,
R1,
R1,
#0xF0
0xFF
R1, 0xFF
R1, #0xFF
;this
;and this
;are the same as this
Assembler directives
Description
ENDM
ENDR
EXITM
LOCAL
MACRO
Defines a macro.
REPT
REPTC
REPTI
SYNTAX
ENDM
ENDR
EXITM
LOCAL symbol [,symbol]
name MACRO [,argument]
REPT expr
REPTC formal,actual
REPTI formal,actual [,actual]
PARAMETERS
actual
String to be substituted.
argument
expr
An expression.
formal
name
symbol
59
AARM-6
DESCRIPTION
A macro is a user-defined symbol that represents a block of one or more assembler
source lines. Once you have defined a macro you can use it in your program like an
assembler directive or assembler mnemonic.
When the assembler encounters a macro, it looks up the macros definition, and inserts
the lines that the macro represents as if they were included in the source file at that
position.
Macros perform simple text substitution effectively, and you can control what they
substitute by supplying parameters to them.
Defining a macro
You define a macro with the statement:
macroname MACRO [,arg] [,arg]
Here macroname is the name you are going to use for the macro, and arg is an
argument for values that you want to pass to the macro when it is expanded.
For example, you could define a macro ERROR as follows:
errmac
EXTERN
MACRO
BL
DATA
DC8
ENDM
abort
text
abort
text,0
This macro uses a parameter text to set up an error message for a routine abort.
You would call the macro with a statement such as:
CODE32
errmac
END
abort
'Disk not ready',0
If you omit a list of one or more arguments, the arguments you supply when calling
the macro are called \1 to \9 and \A to \Z.
The previous example could therefore be written as follows:
errmac
60 Reference Guide
AARM-6
EXTERN
MACRO
abort
Assembler directives
BL
DATA
DC8
ENDM
abort
\1,0
Use LOCAL to create symbols local to a macro. The LOCAL directive must be used
before the symbol is used.
Each time that a macro is expanded, new instances of local symbols are created by the
LOCAL directive. Therefore, it is legal to use local symbols in recursive macros.
MACRO op
CMP op
ENDM
You can redefine the macro quote characters with the -M command line option; see
-M, page 17.
DO_ADD
RSEG ICODE
MACRO
IF _args == 3
61
AARM-6
ADD \1,\2,\3
ELSE
ADD \1,\1,\2
ENDIF
ENDM
main:
RSEG ICODE
DO_ADD R1,#5
DO_ADD R1,R2,#6
END
2
2.1
2
3
4
5
13
14
15
15.1
15.2
15.3
15.4
15.5
15.6
16
16.1
16.2
16.3
16.4
16.5
16.6
17
18
62 Reference Guide
AARM-6
00000000
ORG 0x00
; reset vector
; address
00000000
00000000
00000000
00000000 ........
00000004
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000 051081E2
00000004
00000004
00000004
00000004
00000004 061082E2
00000008
00000008
00000008
00000008
00000008
00000008
CODE32
ALIGNROM 2
CODE32
B main
; ARM mode
RSEG ICODE
main:
RSEG ICODE
DO_ADD R1,#5
IF _args == 3
ADD R1,#5,
ELSE
ADD R1,R1,#5
ENDIF
ENDM
DO_ADD R1,R2,#6
IF _args == 3
ADD R1,R2,#6
ELSE
ADD R1,R1,R2
ENDIF
ENDM
END
; ARM mode
Assembler directives
The assembler performs scanning and saving of macro definitions. The text
between MACRO and ENDM is saved but not syntax checked. Include-file references
$file are recorded and will be included during macro expansion.
A macro call forces the assembler to invoke the macro processor (expander). The
macro expander switches (if not already in a macro) the assembler input stream
from a source file to the output from the macro expander. The macro expander
takes its input from the requested macro definition.
The macro expander has no knowledge of assembler symbols since it only deals
with text substitutions at source level. Before a line from the called macro
definition is handed over to the assembler, the expander scans the line for all
occurrences of symbolic macro arguments, and replaces them with their expansion
arguments.
The expanded line is then processed as any other assembler source line. The input
stream to the assembler will continue to be the output from the macro processor,
until all lines of the current macro definition have been read.
Repeating statements
Use the REPT...ENDR structure to assemble the same block of instructions a number
of times. If expr evaluates to 0 nothing will be generated.
Use REPTC to assemble a block of instructions once for each character in a string. If
the string contains a comma it should be enclosed in quotation marks.
Use REPTI to assemble a block of instructions once for each string in a series of
strings. Strings containing commas should be enclosed in quotation marks.
EXAMPLES
This section gives examples of the different ways in which macros can make
assembler programming easier.
EQU 0x0100
DATA
ASEG
ORG 0
63
AARM-6
start:
DC32 main
buffer
RSEG DATASEG
DATA
DS8 512
main:
done:
RSEG CODESEG(2)
CODE32
BL play
B done
; reset vector
; Reserve a buffer of
; 512 bytes
play:
LDR R1,=buffer
LDR R2,=IO_PORT
LDR R3,=512
ADD R3,R3,R1
LDRB R4,[R1],#1
STRB R4,[R2]
CMP
R1, R3
BNE loop
MOV PC,LR
END main
; Use R1 as pointer
; into buffer
; Use R2 as pointer
; to the port
; Buffersize in R3
; R3 = one past the
; buffer loop:
; Get byte data in R4,
; increment pointer
; into buffer
; Write to the address
; pointed to by R2
; Compare R1 to the
; address
; one past the buffer
; NOT EQUAL --> repeat
; return
;
;
;
;
;
;
;
Use R1 as pointer
into buffer
Use R2 as pointer
to the port
Buffersize in R3
R3 = one past the
buffer
loop:
LDRB R4,[R1],#1
64 Reference Guide
AARM-6
Assembler directives
IO_PORT
start:
buffer:
STRB R4,[R2]
; Write to the
; address
; pointed to by R2
CMP
;
;
;
;
R1, R3
BNE loop
ENDM
EQU 0x0100
DATA
ASEG
ORG 0
B main
RSEG DATASEG
DATA
DS8 512
Compare R1 to the
address
one past the buffer
NOT EQUAL -->repeat
; Reserve a buffer of
; 512 bytes
RSEG CODESEG(2)
CODE32
main:
done:
play buffer,512,IO_PORT
B done
END main
Notice the use of the LOCAL directive to make the label loop local to the macro;
otherwise an error will be generated if the macro is used twice, as the loop label will
already exist.
65
AARM-6
00000000
00000000
00000000
00000000
00000000
00000000
00000000
7
8
8.1
00000000
00000000
00000000 5700A0E3
8.2
8.3
00000004 ........
00000008 6500A0E3
8.4
8.5
0000000C ........
00000010 6C00A0E3
8.6
8.7
00000014 ........
00000018 6300A0E3
8.8
8.9
0000001C ........
00000020 6F00A0E3
NAME signon
EXTERN plotc
CODE32
ALIGNRAM 2
banner
66 Reference Guide
AARM-6
EQU 0xFFFFF100
EQU 0xFFFFF200
EQU 0xFFFFF300
Assembler directives
CODE32
main
PUBLIC
MOV
REPTI
LDR
STRB
ENDR
main
R0, #0
a, base, count, init
R1, =a
R0, [R1, #0]
B .
END main
00000000
00000000
00000000
00000000
00000000 00E0
00000002
FFFFF100
FFFFF200
FFFFF300
00000002
00000002
00000002FFFFF
00000004
00000004
00000000
00000004 0000A0E3
00000008
00000008
00000008
00000008
00000008 14109FE5
0000000C 0000C1E5
00000010 10109FE5
00000014 0000C1E5
00000018 0C109FE5
0000001C 0000C1E5
00000020
00000020 FEFFFFEA
00000024
00000024
00000024
00000024 00F1FFFF
00000028 00F2FFFF
NAME repti
ASEG
DATA
ORG 0
B
main
base
count
init
EQU 0xFFFFF100
EQU 0xFFFFF200
EQU 0xFFFFF300
CODE32
ALIGNRAM 2
main
PUBLIC
MOV
REPTI
LDR
STRB
ENDR
LDR
STRB
LDR
STRB
LDR
STRB
main
R0,#0
a, base, count, init
R1,=a
R0,[R1,#0]
R1,= base
R0,[R1,#0]
R1,= count
R0,[R1,#0]
R1,= init
R0,[R1,#0]
B .
END main
TABLE
Reference on line 19
Reference on line 19
67
AARM-6
23.4
23.5
0000002C 00F3FFFF
00000030
Reference on line 19
END (including table)
Description
COL
LSTCND
LSTCOD
LSTEXP
LSTMAC
LSTOUT
LSTPAG
LSTREP
LSTXRF
PAGE
PAGSIZ
SYNTAX
COL columns
LSTCND{+ | -}
LSTCOD{+ | -}
LSTEXP{+ | -}
LSTMAC{+ | -}
LSTOUT{+ | -}
LSTPAG{+ | -}
LSTREP{+ | -}
LSTXRF{+ | -}
PAGE
PAGSIZ lines
PARAMETERS
68 Reference Guide
AARM-6
columns
lines
Assembler directives
DESCRIPTION
Turning the listing on or off
Use LSTOUT- to disable all list output except error messages. This directive overrides
all other listing control directives.
The default is LSTOUT+, which lists the output (if a list file was specified).
69
AARM-6
EXAMPLES
Turning the listing on or off
To disable the listing of a debugged section of program:
LSTOUT; Debugged section
LSTOUT+
; Not yet debugged
debug
begin
begin2
NAME
CODE32
EXTERN
lstcndtst
RSEG
prom
SET
IF
BL
ENDIF
AARM-6
0
debug
print
LSTCND+
IF
debug
BL
print
NOP
ENDIF
END
70 Reference Guide
Assembler directives
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
debug
begin
NAME lstcndtst
CODE32
ALIGNRAM 2
EXTERN print
RSEG prom
SET 0
IF debug
BL print
ENDIF
LSTCND+
begin2
IF debug
ENDIF
END
The following example shows the effect of LSTCOD- on the generated code by a DATA
directive:
NAME lstcodtst
DATA
table1: DC32 1,10,100,1000,10000
LSTCODtable2: DC32 1,10,100,1000,10000
END
5
6
7
00000000
00000000
00000000
00000000 010000000A00 table1:
000064000000
E80300001027
0000
00000014
00000014 010000000A00*table2:
00000028
NAME lstcodtst
DATA
DC32 1,10,100,1000,10000
LSTCODDC32 1,10,100,1000,10000
END
71
AARM-6
CODE32
MACRO arg
ADD R1,R1,#-arg
ADD R1,R1,#-arg
ENDM
LSTMAC-
inc2
MACRO arg
ADD R1,R1,#arg
ADD R1,R1,#arg
ENDM
begin:
dec2 127
LSTEXPinc2 0x20
END begin
72 Reference Guide
AARM-6
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000 7F1041E2
00000004 7F1041E2
00000008
00000008
00000008
00000010
00000004
00000004
00000004
00000008
00000008
00000008
CODE32
ALIGNRAM 2
LSTMACbegin:
dec2 127
ADD R1,R1,#-127
ADD R1,R1,#-127
ENDM
LSTEXPinc2 0x20
END begin
LSTEXPinc2
0x20
END
begin
Assembler directives
; Page size
Description
#define
#elif
#else
#endif
#error
Generates an error.
#if
#ifdef
#ifndef
#include
Includes a file.
#message
#undef
Undefines a label.
SYNTAX
#define label text
#elif condition
#else
#endif
#error "message"
#if condition
73
AARM-6
#ifdef label
#ifndef label
#include {"filename" | <filename>}
#message "message"
#undef label
PARAMETERS
condition
string1=string
string1<>string2
filename
label
message
Text to be displayed.
text
Value to be assigned.
DESCRIPTION
Defining and undefining labels
Use #define to define a temporary label.
#define label value
is similar to:
label VAR value
Use #undef to undefine a label; the effect is as if it had not been defined.
74 Reference Guide
AARM-6
Assembler directives
Conditional directives
Use the #if...#else...#endif directives to control the assembly process at assembly
time. If the condition following the #if directive is not true, the subsequent
instructions will not generate any code (i.e. it will not be assembled or syntax checked)
until a #endif or #else directive is found.
All assembler directives (except for END) and file inclusion may be disabled by the
conditional directives. Each #if directive must be terminated by a #endif directive.
The #else directive is optional and, if used, it must be inside a #if...#endif block.
#if...#endif and #if...#else...#endif blocks may be nested to any level.
Use #ifdef to assemble instructions up to the next #else or #endif directive only
if a symbol is defined.
Use #ifndef to assemble instructions up to the next #else or #endif directive only
if a symbol is undefined.
Displaying errors
Use #error to force the assembler to generate an error, such as in a user-defined test.
75
AARM-6
The following example illustrates some problems that may occur when assembler
comments are used in the C-style preprocessor:
#define five 5 ; comment
MOV R0,five+addr ; syntax error!
; expanded to "MOV R0,5 ; comment+addr"
LDR R0,[R1,#five]
; syntax error!
; expanded to "LDR R0,[R1,#5 ; comment]"
END
EXAMPLES
Using conditional directives
The following example uses #ifdef to check that a certain symbol is defined and in
that case use two internally defined symbols. Otherwise, the same symbols are
declared EXTERN and a message displayed by #message. The STAND_ALONE symbol
can, for example, be defined on the command line via the -D option, see -D, page 13.
PROGRAM target
CODE32
PUBLIC main
#ifdef
alpha
beta
#else
STAND_ALONE
EQU 0x20
EQU 0x22
R1,#alpha
R2,#beta
R2,R2,R1
R1,R1,R2
main
76 Reference Guide
AARM-6
Assembler directives
MOV a,b
MOV b,c
ENDM
Description
DC8
DC16
DC24
DC32
DCB
DCD
DCW
DF32
DF64
DS8
DS16
DS24
DS32
SYNTAX
DC8 expr [,expr] ...
DC16 expr [,expr] ...
DC24 expr [,expr] ...
DC32 expr [,expr] ...
77
AARM-6
DCB expr[,expr]
DCD expr[,expr]
DCW expr[,expr]
DF32 constant[,constant]
DF64 constant[,constant]
DS16 expr [,expr] ...
DS24 expr [,expr] ...
DS32 expr [,expr] ...
DS8 expr [,expr] ...
PARAMETERS
expr
DESCRIPTION
Use DC8, DC16, DC24, DC32, DCB, DCD, DCW, DF32, or DF64 to reserve and initialize
memory space.
Use DS8, DS16, DS24, or DS32 to reserve uninitialized memory space.
EXAMPLES
Generating lookup table
The following example generates a lookup table of addresses to routines:
78 Reference Guide
AARM-6
ADD_SELECTOR
SUB_SELECTOR
DIV_SELECTOR
MUL_SELECTOR
DEFINE
DEFINE
DEFINE
DEFINE
0
4
8
12
start
NAME table
CODE32
EXTERN add_f, sub_f, div_f, mul_f
ASEG
ORG 0
B
main
; RESET vector
table:
PI:
RSEG DATASEG(2)
DATA
; pointer table to floating point
; routines
DC32 add_f, sub_f, div_f, mul_f
DC32 3.1415927
Assembler directives
radius:
DC32 1.3e2
RSEG CODESEG(2)
CODE32
main:
LDR R1, =PI
LDR
LDR
LDR
MOV
END
;
;
R2, =radius
;
;
R0, =table
;
;
;
R0, [R0,#MUL_SELECTOR] ;
;
;
PC,R0
;
main
Read up
address to P1
Do the same
with radius...
Put base
address to
table in R0
Read address
to mul_f from
table
goto mul_f
Defining strings
To define a string:
mymsg
Reserving space
To reserve space for 0xA bytes:
table
DS8
0xA
79
AARM-6
Description
Includes a file.
/*comment*/
//
CASEOFF
CASEON
INCLUDE
Includes a file.
LTORG
RADIX
SYNTAX
$filename
/*comment*/
//comment
CASEOFF
CASEON
INCLUDE filename
LTORG
RADIX expr
PARAMETERS
comment
expr
filename
DESCRIPTION
Use $ to insert the contents of a file into the source file at a specified point.
Use RADIX to set the default base for use in conversion of constants from ASCII
source to the internal binary format.
80 Reference Guide
AARM-6
Assembler directives
To reset the base from 16 to 10, expr must be written in hexadecimal format, for
example:
RADIX
0x0A
Use LTORG to direct the current literal pool to be assembled. This is done by default
at every END, ENDMOD, and RSEG directive.
Defining comments
Use /* ... */ to comment sections of the assembler listing.
Use // to mark the rest of the line as comment.
EXAMPLES
Including a source file
The following example uses $ to include a file defining macros into the source file.
For example, the following macros could be defined in mymacros.s79:
; exchange a and b using c as temporary
xch
MACRO a,b, c
MOV
MOV
MOV
c, a
a, b
b, c
ENDM
The macro definitions can be included with a $ directive, as
in:
NAME
include
CODE32
; standard macro definitions
$mymacros.s79
; program
main:
xch
R0,R1,R2
81
AARM-6
END
main
Defining comments
The following example shows how /*...*/ can be used for a multi-line comment:
/*
Program to read serial input.
Version 4: 19.9.01
Author: mjp
*/
NOP
BL
NOP
; Stored as "LABEL"
LABEL
NOP
NOP
END
82 Reference Guide
AARM-6
Assembler directives
Description
CFI BASEADDRESS
CFI BLOCK
CFI CODEALIGN
CFI COMMON
CFI CONDITIONAL
CFI DATAALIGN
CFI ENDBLOCK
CFI ENDCOMMON
CFI ENDNAMES
CFI FRAMECELL
CFI FUNCTION
CFI INVALID
CFI NAMES
CFI NOFUNCTION
CFI PICKER
CFI REMEMBERSTATE
CFI RESOURCE
Declares a resource.
CFI RESOURCEPARTS
CFI RESTORESTATE
CFI RETURNADDRESS
CFI STACKFRAME
CFI VIRTUALRESOURCE
CFI cfa
CFI resource
83
AARM-6
SYNTAX
The syntax definitions below show the syntax of each directive. The directives are
grouped according to usage.
NAMES name
ENDNAMES name
RESOURCE resource : bits [, resource : bits]
VIRTUALRESOURCE resource : bits [, resource : bits]
RESOURCEPARTS resource part, part [, part]
STACKFRAME cfa resource type [, cfa resource type]
STATICOVERLAYFRAME cfa segment [, cfa segment]
BASEADDRESS cfa type [, cfa type]
84 Reference Guide
AARM-6
Assembler directives
CFI
CFI
CFI
CFI
CFI
CFI
PARAMETERS
align
bits
cell
cfa
cfiexpr
commonblock
constant
label
A function label.
name
namesblock
offset
part
resource
segment
size
type
85
AARM-6
DESCRIPTIONS
The Call Frame Information directives (CFI directives) are an extension to the
debugging format of the IAR C-SPY Debugger. The CFI directives are used to define
the backtrace information for the instructions in a program. The compiler normally
generates this information, but for library functions and other code written purely in
assembler language, backtrace information has to be added if you want to use the call
frame stack in the debugger.
The backtrace information is used to keep track of the contents of resources, such as
registers or memory cells, in the assembler code. This information is used by the IAR
C-SPY Debugger to go back in the call stack and show the correct values of registers
or other resources before entering the function. In contrast with traditional
approaches, this permits the debugger to run at full speed until it reaches a breakpoint,
stop at the breakpoint, and retrieve backtrace information at that point in the program.
The information can then be used to compute the contents of the resources in any of
the calling functionsassuming they have call frame information as well.
The resource columns keep track of where the original value of a resource can be
found.
The canonical frame address columns (CFA columns) keep track of the top of the
function frames.
The return address column keeps track of the location of the return address.
There is always exactly one return address column and usually only one CFA column,
although there may be more than one.
86 Reference Guide
AARM-6
Assembler directives
Inside a names block, four different kinds of declarations may appear: a resource
declaration, a stack frame declaration, a static overlay frame declaration, or a base
address declaration:
The parameters are the name of the resource and the size of the resource in bits. A
virtual resource is a logical concept, in contrast to a physical resource such as a
processor register. Virtual resources are usually used for the return address.
More than one resource can be declared by separating them with commas.
A resource may also be a composite resource, made up of at least two parts. To
declare the composition of a composite resource, use the directive:
CFI RESOURCEPARTS resource part, part,
The parts are separated with commas. The resource and its parts must have been
previously declared as resources, as described above.
The parameters are the name of the stack frame CFA, the name of the associated
resource (the stack pointer), and the segment type (to get the address space). More
than one stack frame CFA can be declared by separating them with commas.
When going back in the call stack, the value of the stack frame CFA is copied
into the associated stack pointer resource to get a correct value for the previous
function frame.
The parameters are the name of the CFA and the name of the segment where the
static overlay for the function is located. More than one static overlay frame CFA
can be declared by separating them with commas.
The parameters are the name of the CFA and the segment type. More than one base
address CFA can be declared by separating them with commas.
A base address CFA is used to conveniently handle a CFA. In contrast to the stack
frame CFA, there is no associated stack pointer resource to restore.
87
AARM-6
where namesblock is the name of the existing names block and name is the name of
the new extended block. The extended block must end with the directive:
CFI ENDNAMES name
where name is the name of the new block and namesblock is the name of a
previously defined names block.
Declare the return address column with the directive:
CFI RETURNADDRESS resource type
88 Reference Guide
AARM-6
Assembler directives
where name is the name of the new extended block, commonblock is the name of the
existing common block, and namesblock is the name of a previously defined names
block. The extended block must end with the directive:
CFI ENDCOMMON name
where name is the name of the new block and commonblock is the name of a
previously defined common block.
If the piece of code is part of a defined function, specify the name of the function with
the directive:
CFI FUNCTION label
89
AARM-6
SIMPLE RULES
To describe the tracking information for individual columns, there is a set of simple
rules with specialized syntax:
CFI
CFI
CFI
CFI
These simple rules can be used both in common blocks to describe the initial
information for resources and CFAs, and inside data blocks to describe changes to the
information for resources or CFAs.
In those rare cases where the descriptive power of the simple rules are not enough, a
full CFI expression can be used to describe the information (see CFI expressions, page
92). However, whenever possible, you should always use a simple rule instead of a
CFI expression.
There are two different sets of simple rules: one for resources and one for CFAs.
To declare that a resource is temporarily stored in another resource, use the resource
name as its location. For example, to declare that a register REG1 is temporarily
located in a register REG2 (and should be restored from that register), use the directive:
CFI REG1 REG2
90 Reference Guide
AARM-6
Assembler directives
For a composite resource there is one additional location, CONCAT, which declares that
the location of the resource can be found by concatenating the resource parts for the
composite resource. For example, consider a composite resource RET with resource
parts RETLO and RETHI. To declare that the value of RET can be found by
investigating and concatenating the resource parts, use the directive:
CFI RET CONCAT
This requires that at least one of the resource parts has a definition, using the rules
described above.
To declare that a CFA has an address that is offset relative the value of a resource,
specify the resource and the offset. For example, to declare that the CFA with the
name CFA_SP can be obtained by adding 4 to the value of the SP resource, use the
directive:
CFI CFA_SP SP + 4
For static overlay frame CFAs, there are only two possible declarations inside
common and data blocks: USED and NOTUSED.
91
AARM-6
CFI EXPRESSIONS
Call Frame Information expressions (CFI expressions) can be used when the
descriptive power of the simple rules for resources and CFAs is not enough. However,
you should always use a simple rule when one is available.
CFI expressions consist of operands and operators. Only the operators described
below are allowed in a CFI expression. In most cases, they have an equivalent operator
in the regular assembler expressions.
In the operand descriptions, cfiexpr denotes one of the following:
Unary operators
Overall syntax: OPERATOR(operand)
Operator
Operand
Description
UMINUS
cfiexpr
NOT
cfiexpr
COMPLEMENT
cfiexpr
LITERAL
expr
Binary operators
Overall syntax: OPERATOR(operand1,operand2)
Operator
Operands
Description
ADD
cfiexpr,cfiexpr
Addition
SUB
cfiexpr,cfiexpr
Subtraction
MUL
cfiexpr,cfiexpr
Multiplication
DIV
cfiexpr,cfiexpr
Division
MOD
cfiexpr,cfiexpr
Modulo
AND
cfiexpr,cfiexpr
Bitwise AND
OR
cfiexpr,cfiexpr
Bitwise OR
92 Reference Guide
AARM-6
Assembler directives
Operator
Operands
Description
XOR
cfiexpr,cfiexpr
Bitwise XOR
EQ
cfiexpr,cfiexpr
Equal
NE
cfiexpr,cfiexpr
Not equal
LT
cfiexpr,cfiexpr
Less than
LE
cfiexpr,cfiexpr
GT
cfiexpr,cfiexpr
Greater than
GE
cfiexpr,cfiexpr
LSHIFT
cfiexpr,cfiexpr
RSHIFTL
cfiexpr,cfiexpr
RSHIFTA
cfiexpr,cfiexpr
Ternary operators
Overall syntax: OPERATOR(operand1,operand2,operand3)
Operator Operands
Description
FRAME
cfa,size,offset
IF
cond,true,false
93
AARM-6
Operator Operands
Description
LOAD
size,type,addr
EXAMPLE
The following is a generic example and not an example specific to the ARM core. This
will simplify the example and clarify the usage of the CFI directives. A target-specific
example can be obtained by generating assembler output when compiling a C source
file.
Consider a generic processor with a stack pointer SP, and two registers R0 and R1.
Register R0 will be used as a scratch register (the register is destroyed by the function
call), whereas register R1 has to be restored after the function call. For reasons of
simplicity, all instructions, registers, and addresses will have a width of 16 bits.
Consider the following short code sample with the corresponding backtrace rows and
columns. At entry, assume that the stack contains a 16-bit return address. The stack
grows from high addresses towards zero. The CFA denotes the top of the call frame,
that is, the value of the stack pointer after returning from the function.
Address
CFA
0000
SP + 2
0002
SP + 4
SP
R0
R1
RET
Assembler code
SAME
CFA - 2
func1: PUSH R1
CFA - 4
0004
000A
R1,#4
CALL func2
0006
0008
MOV
SP + 2
POP
R0
R0
MOV
R1,R0
SAME
RET
Each backtrace row describes the state of the tracked resources before the execution
of the instruction. As an example, for the MOV R1,R0 instruction the original value of
the R1 register is located in the R0 register and the top of the function frame (the CFA
column) is SP + 2. The backtrace row at address 0000 is the initial row and the result
of the calling convention used for the function.
94 Reference Guide
AARM-6
Assembler directives
The SP column is empty since the CFA is defined in terms of the stack pointer. The
RET column is the return address columnthat is, the location of the return address.
The R0 column has a in the first line to indicate that the value of R0 is undefined
and does not need to be restored on exit from the function. The R1 column has SAME
in the initial row to indicate that the value of the R1 register will be restored to the
same value it already has.
Note: SP may not be changed using a CFI directive since it is the resource associated
with CFA.
CODE:CODE
BLOCK func1block USING trivialCommon
FUNCTION func1
R1
CFA SP + 4
R1 FRAME(CFA,-4)
R1,#4
func2
R0
R1 R0
95
AARM-6
CFI
CFA SP + 2
MOV
R1,R0
CFI
R1 SAMEVALUE
RET
CFI ENDBLOCK func1block
Note that the CFI directives are placed after the instruction that affects the backtrace
information.
96 Reference Guide
AARM-6
Assembler
pseudo-instructions
The ARM IAR Assembler accepts a number of pseudo-instructions, which are
translated into correct code. This chapter lists the pseudo-instructions and
gives examples of their use.
Summary
The following table shows a summary of the available pseudo-instructions:
Pseudo-instruction
Mode
Translated to
Description
ADR
ARM
ADD, SUB
ADR
Thumb
ADD, SUB
ADRL
ARM
ADD, SUB
_BLF
ARM
BL
_BLF
Thumb
BL
LDR
ARM
LDR
Thumb
MOV
Thumb
ADD
NOP
ARM
MOV
NOP
Thumb
MOV
97
AARM-6
Descriptions of pseudo-instructions
The following section gives reference information about each pseudo-instruction.
Parameters
{condition}
Can be one of the following: EQ, NE, CS, CC , MI, PL, VS, VC , HI, LS, GE,
LT, GT, LE, and AL.
register
expression
Description
ADR always assembles to one instruction. The assembler attempts to produce a single
ADD or SUB instruction to load the address:
CODE32
ADR r0,thumb ; => ADD r0,pc,#1
BX r0
CODE16
thumb
Parameters
register
expression
Description
In Thumb mode, ADR can generate word-aligned addresses only (i. e. addresses
divisible by 4). Use the ALIGNROM directive to ensure that the address is aligned
(unless DC32 is used, because it is always word aligned):
ADR r0,my_data ; => ADD r0,pc,#4
98 Reference Guide
AARM-6
Assembler pseudo-instructions
ADD r0,r0,r1
BX lr
DATA
ALIGNROM
my_data DC32 0xABCD19
Parameters
{condition}
Can be one of the following: EQ, NE, CS, CC , MI, PL, VS, VC , HI, LS, GE,
LT, GT, LE, and AL.
register
expression
Description
The ADRL pseudo-instruction loads a program-relative address into a register. It is
similar to the ADR pseudo-instruction. ADRL can load a wider range of addresses than
ADR because it generates two data processing instructions. ADRL always assembles to
two instructions. Even if the address can be reached in a single instruction, a second,
redundant instruction is produced. If the assembler cannot construct the address in two
instructions, it generates an error message and the assembly fails.
Note: ADRL is not available when assembling Thumb instructions. Use it only in ARM
code.
Example
ADRL r1,my_data+0x2345
DATA
my_data: DC32 0
99
AARM-6
Parameters
condition
label1
Direct label.
label2
Alternative label.
Description
The instruction is used by the compiler when calling functions that may be far away
or in Thumb mode. If the first label is within range of a BL instruction, and is in ARM
mode, a BL instruction to that label is produced. Otherwise a BL instruction to the
second label is produced:
ext_fun
EQU 1
; Odd label (Thumb mode)
_BLF ext_fun,relay_fun ; => BL relay_fun
relay_fun LDR r0,=ext_fun
BX r0
Parameters
label1
Direct label.
label2
Alternative label.
Description
If the first label is within range of a BL instruction, and is in Thumb mode, a BL
instruction to that label is produced. Otherwise a BL instruction to the second label is
produced:
_BLF ext_fun,relay_fun
or
LDR{condition} register,expression2
AARM-6
Assembler pseudo-instructions
Parameters
condition
register
expression1
expression2
Description
The first form of the LDR pseudo-instruction loads a register with any 32-bit
expression. The second form of the instruction reads a 32-bit value from an address
specified by the expression. Note that there is also a true LDR instruction.
If the value of expression1 is within the range of a MOV or MVN instruction, the
assembler generates the appropriate instruction. If the value of expression1 is not
within the range of a MOV or MVN instruction, or if the expression1 is unsolved, the
assembler places the constant in a literal pool and generates a program-relative LDR
instruction that reads the constant from the literal pool. The offset from the program
location counter to the constant must be less than 4 Kbytes. See also the LTORG
directive in the section Assembler control directives, page 80, for more information.
Example
LDR
r1,=0x12345678
LDR
r2,my_data
my_data
DATA
DC32 0xFFEEDDCC
LTORG
or
LDR register, expression2
101
AARM-6
Parameters
register
The register to be loaded. LDR can access the low registers (R0R7) only.
expression1
expression2
Description
As in ARM mode, the first form of the LDR pseudo-instruction in Thumb mode loads
a register with any 32-bit expression. The second form of the instruction reads a 32-bit
value from an address specified by the expression. However, the offset from the
program location counter to the constant must be positive and less than 1 Kbyte.
Example
LDR
NOP
LDR
NOP
DATA
my_data
LTORG
r1,=ext_label
r2,my_data
DC32 0xFFEEDDCC
Parameters
Rd
Rs
Description
The Thumb MOV pseudo-instruction moves the value of a low register to another low
register (R0-R7). The Thumb MOV instruction cannot move values from one low
register to another.
Note: The ADD immediate instruction generated by the assembler has the side-effect
of updating the condition codes.
The MOV pseudo-instruction uses an ADD immediate instruction with a zero immediate
value.
AARM-6
Assembler pseudo-instructions
Example
MOV r2,r3
Description
NOP generates the preferred ARM no-operation code:
MOV r0,r0
Description
NOP generates the preferred Thumb no-operation code:
MOV r8,r8
103
AARM-6
Descriptions of pseudo-instructions
AARM-6
Assembler diagnostics
This chapter describes the format of the diagnostic messages and explains how
diagnostic messages are divided into different levels of severity.
Message format
All diagnostic messages are issued as complete, self-explanatory messages. A typical
diagnostic message from the assembler is produced in the form:
filename,linenumber level[tag]: message
where filename is the name of the source file in which the error was encountered;
linenumber is the line number at which the assembler detected the error; level is
the level of seriousness of the diagnostic; tag is a unique tag that identifies the
diagnostic message; message is a self-explanatory message, possibly several lines
long.
Diagnostic messages are displayed on the screen, as well as printed in the optional list
file.
Severity levels
The diagnostic messages produced by the ARM IAR Assembler reflect problems or
errors that are found in the source code or occur at assembly time.
105
AARM-6
Severity levels
AARM-6
Introduction
The ARM IAR Assembler (AARM) was designed using the same look and feel as
other IAR assemblers, while still making it easy to translate source code written for
the TASM assembler from Advanced RISC Machines Ltd.
When the option -j (Allow alternative register names, mnemonics and operands)
is selected, the instruction syntax is the same in AARM as in TASM. Many features,
such as directives and macros, are, however, incompatible and cause syntax errors.
There are also differences in Thumb code labels that may cause problems without
generating errors or warnings. Be extra careful when you use such labels in situations
other than jumps.
Note: For new code, use the ARM IAR Assembler register names, mnemonics and
operators.
DD
CODE32
ADR
MOV
DATA
R0,T+1
R1,#T-.
107
AARM-6
DCD
CODE16
NOP
Rewrite instructions like this to make them portable (i.e. have the same effect when
assembled using both AARM and TASM). Note that ADR is equivalent to an ADD with
PC.
DD
CODE32
ADD
MOV
DATA
DCD
CODE16
NOP
R0,PC,#(T-.-8) :OR: 1
R1,#(T-.) :AND: 0xFFFFFFFE
T
A1
R0
A2
R1
A3
R2
A4
R3
V1
R4
V2
R5
V3
R6
V4
R7
V5
R8
V6
R9
V7
R10
SB
R9
SL
R10
FP
R11
IP
R12
AARM-6
Alternative mnemonics
A number of mnemonics used by other assemblers will be translated by the ARM IAR
Assembler when the option -j is specified. These alternative mnemonics are allowed
in Thumb mode only. The following table lists the alternative mnemonics:
Alternative mnemonic
ADCS
ADC
ADDS
ADD
ANDS
AND
ASLS
LSL
ASRS
ASR
BICS
BIC
BNCC
BCS
BNCS
BCC
BNEQ
BNE
BNGE
BLT
BNGT
BLE
BNHI
BLS
BNLE
BGT
BNLO
BCS
BNLS
BHI
BNLT
BGE
BNMI
BPL
BNNE
BEQ
BNPL
BMI
BNVC
BVS
BNVS
BVC
CMN{cond}S
CMN{cond}
CMP{cond}S
CMP{cond}
EORS
EOR
LSLS
LSL
109
AARM-6
Operator synonyms
Alternative mnemonic
LSRS
LSR
MOVS
MOV
MULS
MUL
MVNS
MVN
NEGS
NEG
ORRS
ORR
RORS
ROR
SBCS
SBC
SUBS
SUB
TEQ{cond}S
TEQ{cond}
TST{cond}S
TST{cond}
Refer to the ARM Architecture Reference Manual (Prentice-Hall) for full descriptions
of the mnemonics.
Operator synonyms
A number of operators used by other assemblers will be translated by the ARM IAR
Assembler when the option -j is specified. The following operator synonyms are
allowed in both ARM and Thumb modes:
Operator synonym
:AND:
&
:EOR:
:LAND:
&&
:LEOR:
XOR
:LNOT:
:LOR:
||
:MOD:
:NOT:
:OR:
:SHL:
<<
:SHR:
>>
AARM-6
Note: ARM IAR Assembler operators and operator synonyms have different
precedence levels. For further descriptions of the operators, see the chapter Assembler
operators, page 23.
Warning messages
Unless the option -j is specified, the ARM IAR Assembler will issue warning
messages when the alternative names are used, or when illegal combinations of
operands are encountered. The following sections list the warning messages:
111
AARM-6
Warning messages
AARM-6
Index
A
AARM_INC (environment variable) . . . . . . . . . . . . . . . . . 10
absolute segments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
ADD (assembler instruction) . . . . . . . . . . . . . . . . . . . . . . . 98
ADD (CFI operator). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
addition (assembler operator). . . . . . . . . . . . . . . . . . . . . . . 26
addresses, loading into a register . . . . . . . . . . . . . . . . . 9899
ADR (ARM) (pseudo-instruction) . . . . . . . . . . . . . . . . . . . 98
ADR (Thumb) (pseudo-instruction). . . . . . . . . . . . . . . . . . 98
ADRL (ARM) (pseudo-instruction). . . . . . . . . . . . . . . . . . 99
ALIAS (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 53
alignment, of segments. . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
ALIGNRAM (assembler directive) . . . . . . . . . . . . . . . . . . 48
ALIGNROM (assembler directive) . . . . . . . . . . . . . . . . . . 48
:AND: (assembler operator). . . . . . . . . . . . . . . . . . . . . . . . 29
AND (CFI operator). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
architecture, ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
ASCII character constants . . . . . . . . . . . . . . . . . . . . . . . . . . 4
ASEG (assembler directive). . . . . . . . . . . . . . . . . . . . . . . . 48
ASEGN (assembler directive) . . . . . . . . . . . . . . . . . . . . . . 48
asm (file extension) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
ASMARM (environment variable) . . . . . . . . . . . . . . . . . . 10
assembler control directives . . . . . . . . . . . . . . . . . . . . . . . . 80
assembler diagnostics. . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
assembler directives
ALIAS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
ALIGNRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
ALIGNROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
ASEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
ASEGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
assembler control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
ASSIGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
call frame information. . . . . . . . . . . . . . . . . . . . . . . . . . 83
CASEOFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
CASEON. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
CFI directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
CODE16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
CODE32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Index
COL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
comments, using . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
COMMON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
conditional assembly. . . . . . . . . . . . . . . . . . . . . . . . . . . 57
See also C-style preprocessor directives
C-style preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
DATA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
data definition or allocation . . . . . . . . . . . . . . . . . . . . . 77
DCB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DCD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DC16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DC24 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DC32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DC8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DEFINE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
DF32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DF64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DS16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DS24 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DS32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DS8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
ELSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
ELSEIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
END. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
ENDIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
ENDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
ENDMOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
ENDR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
EQU. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
EVEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
EXITM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
EXPORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
EXTERN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
IF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
IMPORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
INCLUDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
labels, using. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
LIBRARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
113
AARM-6
LIMIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
list file control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
LOCAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
LSTCND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
LSTCOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
LSTEXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
LSTMAC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
LSTOUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
LSTPAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
LSTREP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
LSTXRF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
LTORG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
MACRO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
macro processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
MODULE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
module control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
NAME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
ODD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
ORG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
PAGE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
PAGSIZ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
PROGRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
PUBLIC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
RADIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
REPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
REPTC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
REPTI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
REQUIRE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
RSEG. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
RTMODEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
segment control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
SET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
SETA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
STACK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
symbol control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
value assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
AARM-6
VAR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
#define. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
#elif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
#else. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
#endif. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
#error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
#if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
#ifdef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
#ifndef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
#include . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
#message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
#undef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
$. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
/*...*/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
//. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
assembler expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
assembler instructions
ADD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
BL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
BX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
LDR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
MOV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
MVN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
SUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
assembler labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
assembler directives, using with . . . . . . . . . . . . . . . . . . 41
defining and undefining . . . . . . . . . . . . . . . . . . . . . . . . 74
format of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
in Thumb code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
assembler list files
conditional code and strings . . . . . . . . . . . . . . . . . . . . . 69
conditions, specifying . . . . . . . . . . . . . . . . . . . . . . . . . . 12
cross-references
generating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
table, generating . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
disabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
enabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
filename, specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Index
format, specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
generated lines, controlling . . . . . . . . . . . . . . . . . . . . . . 69
generating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
header section, omitting . . . . . . . . . . . . . . . . . . . . . . . . 17
lines per page, specifying . . . . . . . . . . . . . . . . . . . . . . . 18
macro execution information, including . . . . . . . . . . . . 12
macro-generated lines, controlling . . . . . . . . . . . . . . . . 69
tab spacing, specifying . . . . . . . . . . . . . . . . . . . . . . . . . 19
using directives to format . . . . . . . . . . . . . . . . . . . . . . . 70
#include files, specifying. . . . . . . . . . . . . . . . . . . . . . . . 15
assembler macros
arguments, passing to . . . . . . . . . . . . . . . . . . . . . . . . . . 61
defining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
generated lines, controlling in list file. . . . . . . . . . . . . . 69
in-line routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
predefined symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
quote characters, specifying . . . . . . . . . . . . . . . . . . . . . 17
special characters, using . . . . . . . . . . . . . . . . . . . . . . . . 61
assembler object file, specifying filename . . . . . . . . . . . . . 17
assembler operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
BYTE1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
BYTE2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
BYTE3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
BYTE4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
DATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
HIGH. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
HWRD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
in expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
LOW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
LWRD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
precedence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
SFB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
SFE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
SIZEOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
synonyms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
UGT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
ULT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
!= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
& . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
&&. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2627
/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
:AND: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
:EOR:. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
:LAND: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
:LEOR: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
:LNOT: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
:LOR:. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
:MOD: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
:NOT:. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
:OR: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
:SHL: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
:SHR:. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
< . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
<< . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
<= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
<> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
== . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
>= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
>> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
^. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
| . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
|| . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
~. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
assembler options
command line, setting . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
extended command file, setting. . . . . . . . . . . . . . . . . . . . 9
summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
typographic convention . . . . . . . . . . . . . . . . . . . . . . . . . . x
-B. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
115
AARM-6
-b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
-c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
-D. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
-E . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
-e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
-endian. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
-f . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 14
-G. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
-I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
-i . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
-j . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
-L . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
-l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
-M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
-N. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
-O. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
-o . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
-p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
-r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
-S . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
-s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
-t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
-U. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
-v . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
-w. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
-x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
assembler output format. . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
assembler output, including debug information. . . . . . . . . 18
assembler pseudo-instructions . . . . . . . . . . . . . . . . . . . . . . 97
assembler source code, porting . . . . . . . . . . . . . . . . . . . . . 47
assembler source files, including . . . . . . . . . . . . . . . . . 75, 81
assembler source format. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
assembler symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
exporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
importing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
in relocatable expressions . . . . . . . . . . . . . . . . . . . . . . . . 2
local . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
predefined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
undefining. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
AARM-6
redefining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
assembly error messages . . . . . . . . . . . . . . . . . . . . . . . . . 105
assembly warning messages. . . . . . . . . . . . . . . . . . . . . . . 105
disabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
ASSIGN (assembler directive). . . . . . . . . . . . . . . . . . . . . . 53
assumptions (programming experience) . . . . . . . . . . . . . . ix
B
-B (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
-b (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
backtrace information, defining . . . . . . . . . . . . . . . . . . . . . 83
_ _BIG_ENDIAN_ _ (predefined symbol) . . . . . . . . . . . . . 5
bitwise AND (assembler operator) . . . . . . . . . . . . . . . . . . 29
bitwise exclusive OR (assembler operator) . . . . . . . . . . . . 30
bitwise NOT (assembler operator) . . . . . . . . . . . . . . . . . . . 29
bitwise OR (assembler operator) . . . . . . . . . . . . . . . . . . . . 29
BL (assembler instruction). . . . . . . . . . . . . . . . . . . . . . . . 100
BX (assembler instruction) . . . . . . . . . . . . . . . . . . . . . . . . 46
byte order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
BYTE1 (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . 30
BYTE2 (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . 30
BYTE3 (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . 30
BYTE4 (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . 30
C
-c (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
call frame information directives . . . . . . . . . . . . . . . . . . . . 83
case sensitive user symbols . . . . . . . . . . . . . . . . . . . . . . . . 19
case sensitivity, controlling . . . . . . . . . . . . . . . . . . . . . . . . 81
CASEOFF (assembler directive) . . . . . . . . . . . . . . . . . . . . 80
CASEON (assembler directive) . . . . . . . . . . . . . . . . . . . . . 80
CFI directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
CFI expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
CFI operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
character constants, ASCII. . . . . . . . . . . . . . . . . . . . . . . . . . 4
CODE16 (assembler directive) . . . . . . . . . . . . . . . . . . . . . 46
CODE32 (assembler directive) . . . . . . . . . . . . . . . . . . . . . 46
Index
D
-D (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
data allocation directives . . . . . . . . . . . . . . . . . . . . . . . . . . 77
data definition directives . . . . . . . . . . . . . . . . . . . . . . . . . . 77
DATA (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 46
data, defining in Thumb code segment . . . . . . . . . . . . . . . 47
_ _DATE_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 5
DATE (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . 31
DCB (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . 77
DCD (assembler directive). . . . . . . . . . . . . . . . . . . . . . . . . 77
DCW (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 77
DC8 (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . 77
DC16 (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 77
E
-E (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
edition notice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
efficient coding techniques. . . . . . . . . . . . . . . . . . . . . . . . . . 7
#elif (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . 73
#else (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . 73
ELSE (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 57
ELSEIF (assembler directive) . . . . . . . . . . . . . . . . . . . . . . 57
END (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . 42
endianess. See byte order
#endif (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 73
ENDIF (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 57
ENDM (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 59
ENDMOD (assembler directive) . . . . . . . . . . . . . . . . . . . . 42
ENDR (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 59
environment variables
AARM_INC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
ASMARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
:EOR: (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . 30
EQ (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
EQU (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . 53
equal (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . 28
117
AARM-6
F
-f (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 14
false value, in assembler expressions. . . . . . . . . . . . . . . . . . 2
fatal errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
_ _FILE_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . . . 5
file extensions
asm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
msa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
r79 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
s79 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
xcl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 14
file types
assembler source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
extended command line. . . . . . . . . . . . . . . . . . . . . . . 9, 14
#include . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
filenames, specifying for assembler object file . . . . . . 1718
first byte (assembler operator) . . . . . . . . . . . . . . . . . . . . . . 30
floating-point constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
formats
assembler output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
assembler source code. . . . . . . . . . . . . . . . . . . . . . . . . . . 1
fourth byte (assembler operator) . . . . . . . . . . . . . . . . . . . . 30
fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
FRAME (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
AARM-6
G
-G (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
GE (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
global value, defining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
greater than or equal (assembler operator). . . . . . . . . . . . . 28
greater than (assembler operator). . . . . . . . . . . . . . . . . . . . 28
GT (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
H
header files, SFR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
header section, omitting from assembler list file . . . . . . . . 17
high byte (assembler operator). . . . . . . . . . . . . . . . . . . . . . 31
high word (assembler operator) . . . . . . . . . . . . . . . . . . . . . 31
HIGH (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . 31
HWRD (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . 31
I
-I (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
-i (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
_ _IAR_SYSTEMS_ASM_ _ (predefined symbol). . . . . . . 6
#if (assembler directive). . . . . . . . . . . . . . . . . . . . . . . . . . . 73
IF (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
IF (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
#ifdef (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 73
#ifndef (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 73
IMPORT (assembler directive) . . . . . . . . . . . . . . . . . . . . . 45
#include files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
#include (assembler directive) . . . . . . . . . . . . . . . . . . . . . . 73
include paths, specifying . . . . . . . . . . . . . . . . . . . . . . . . . . 15
INCLUDE (assembler directive) . . . . . . . . . . . . . . . . . . . . 80
instruction set, ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
integer constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
internal errors, assembler . . . . . . . . . . . . . . . . . . . . . . . . . 106
in-line coding, using macros . . . . . . . . . . . . . . . . . . . . . . . 63
iomacros.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Index
L
-L (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
-l (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
labels. See assembler labels
:LAND: (assembler operator) . . . . . . . . . . . . . . . . . . . . . . 29
LDR (ARM) (pseudo-instruction) . . . . . . . . . . . . . . . . . . 100
LDR (assembler instruction) . . . . . . . . . . . . . . . . . . . . . . 101
LDR (Thumb) (pseudo-instruction) . . . . . . . . . . . . . . . . . 101
LE (CFI operator). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
:LEOR: (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . 36
less than or equal (assembler operator) . . . . . . . . . . . . . . . 27
less than (assembler operator) . . . . . . . . . . . . . . . . . . . . . . 27
library modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
creating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
LIBRARY (assembler directive) . . . . . . . . . . . . . . . . . . . . 42
LIMIT (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 53
_ _LINE_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . . . 6
lines per page, in assembler list file . . . . . . . . . . . . . . . . . . 18
listing control directives . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
literal pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
LITERAL (CFI operator). . . . . . . . . . . . . . . . . . . . . . . . . . 92
_ _LITTLE_ENDIAN_ _ (predefined symbol) . . . . . . . . . . 6
:LNOT: (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . 32
LOAD (CFI operator). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
local value, defining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
LOCAL (assembler directive) . . . . . . . . . . . . . . . . . . . . . . 59
logical AND (assembler operator) . . . . . . . . . . . . . . . . . . . 29
logical exclusive OR (assembler operator) . . . . . . . . . . . . 36
logical NOT (assembler operator) . . . . . . . . . . . . . . . . . . . 32
logical OR (assembler operator) . . . . . . . . . . . . . . . . . . . . 32
logical shift left (assembler operator) . . . . . . . . . . . . . . . . 34
logical shift right (assembler operator) . . . . . . . . . . . . . . . 34
:LOR: (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . 32
low byte (assembler operator) . . . . . . . . . . . . . . . . . . . . . . 32
low register values, moving . . . . . . . . . . . . . . . . . . . . . . . 102
low word (assembler operator). . . . . . . . . . . . . . . . . . . . . . 32
LOW (assembler operator). . . . . . . . . . . . . . . . . . . . . . . . . 32
LSHIFT (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
M
-M (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
macro execution information, including in list file . . . . . . 12
macro processing directives . . . . . . . . . . . . . . . . . . . . . . . . 59
macro quote characters. . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
MACRO (assembler directive). . . . . . . . . . . . . . . . . . . . . . 59
macros. See assembler macros
memory, reserving space in . . . . . . . . . . . . . . . . . . . . . . . . 77
#message (assembler directive) . . . . . . . . . . . . . . . . . . . . . 73
messages, excluding from standard output stream. . . . . . . 19
migration to the ARM IAR Assembler . . . . . . . . . . . . . . 107
alternative mnemonics. . . . . . . . . . . . . . . . . . . . . . . . . 109
alternative register names . . . . . . . . . . . . . . . . . . . . . . 108
operator synonyms . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
warning messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
:MOD: (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . 32
MOD (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
mode control directives . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
module consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
module control directives . . . . . . . . . . . . . . . . . . . . . . . . . . 42
MODULE (assembler directive) . . . . . . . . . . . . . . . . . . . . 42
modules, terminating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
modulo (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . 32
MOV (assembler instruction). . . . . . . . . . . . . . . . . . . . . . 101
MOV (Thumb) (pseudo-instruction) . . . . . . . . . . . . . . . . 102
msa (file extension) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
119
AARM-6
N
-N (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
NAME (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 42
NE (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
NOP (ARM) (pseudo-instruction) . . . . . . . . . . . . . . . . . . 103
NOP (Thumb) (pseudo-instruction) . . . . . . . . . . . . . . . . . 103
:NOT: (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . 29
not equal (assembler operator) . . . . . . . . . . . . . . . . . . . . . . 28
NOT (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
no-operation code, generating . . . . . . . . . . . . . . . . . . . . . 103
O
-O (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
-o (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
ODD (assembler directive). . . . . . . . . . . . . . . . . . . . . . . . . 48
operands
format of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
in assembler expressions . . . . . . . . . . . . . . . . . . . . . . . . . 1
operations, format of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
operation, silent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
operators. See assembler operators
option summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
:OR: (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . 29
OR (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
ORG (assembler directive). . . . . . . . . . . . . . . . . . . . . . . . . 48
output format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
P
-p (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
PAGE (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 68
PAGSIZ (assembler directive) . . . . . . . . . . . . . . . . . . . . . . 68
parameters
AARM-6
in assembler directives . . . . . . . . . . . . . . . . . . . . . . . . . 41
typographic convention . . . . . . . . . . . . . . . . . . . . . . . . . . x
porting assembler source code . . . . . . . . . . . . . . . . . . . . . . 47
precedence, of assembler operators . . . . . . . . . . . . . . . . . . 23
predefined register symbols . . . . . . . . . . . . . . . . . . . . . . . . . 7
predefined symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
in assembler macros . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
undefining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
_ _BIG_ENDIAN_ _. . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
_ _DATE_ _. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
_ _FILE_ _ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
_ _IAR_SYSTEMS_ASM_ _ . . . . . . . . . . . . . . . . . . . . . 6
_ _LINE_ _ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
_ _LITTLE_ENDIAN_ _ . . . . . . . . . . . . . . . . . . . . . . . . 6
_ _TID_ _ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
_ _TIME_ _ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
_ _VER_ _. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
preprocessor symbol, defining . . . . . . . . . . . . . . . . . . . . . . 13
prerequisites (programming experience) . . . . . . . . . . . . . . ix
processor configuration, specifying . . . . . . . . . . . . . . . . . . 13
processor mode, directives . . . . . . . . . . . . . . . . . . . . . . . . . 46
program location counter (PLC) . . . . . . . . . . . . . . . . . . . 1, 3
setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
program modules, beginning . . . . . . . . . . . . . . . . . . . . . . . 43
PROGRAM (assembler directive) . . . . . . . . . . . . . . . . . . . 42
programming experience, required . . . . . . . . . . . . . . . . . . ix
programming hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
pseudo-instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
ADR (ARM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
ADR (Thumb) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
ADRL (ARM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
LDR (ARM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
LDR (Thumb) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
MOV (Thumb) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
NOP (ARM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
NOP (Thumb) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
_BLF (ARM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
_BLF (Thumb) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
PUBLIC (assembler directive) . . . . . . . . . . . . . . . . . . . . . . 45
Index
R
-r (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
RADIX (assembler directive). . . . . . . . . . . . . . . . . . . . . . . 80
reference information, typographic convention . . . . . . . . . . x
registered trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
alternative names of . . . . . . . . . . . . . . . . . . . . . . . . . . 108
relocatable expressions, using symbols in . . . . . . . . . . . . . . 2
relocatable segments, beginning . . . . . . . . . . . . . . . . . . . . 49
repeating statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
REPT (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 59
REPTC (assembler directive). . . . . . . . . . . . . . . . . . . . . . . 59
REPTI (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 59
REQUIRE (assembler directive) . . . . . . . . . . . . . . . . . . . . 45
RSEG (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 48
RSHIFTA (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . 93
RSHIFTL (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . 93
RTMODEL (assembler directive) . . . . . . . . . . . . . . . . . . . 42
rules, in CFI directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
runtime model attributes, declaring . . . . . . . . . . . . . . . . . . 44
S
-S (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
-s (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
second byte (assembler operator). . . . . . . . . . . . . . . . . . . . 30
segment begin (assembler operator). . . . . . . . . . . . . . . . . . 33
segment control directives . . . . . . . . . . . . . . . . . . . . . . . . . 48
segment end (assembler operator) . . . . . . . . . . . . . . . . . . . 33
segment size (assembler operator) . . . . . . . . . . . . . . . . . . . 35
segments
absolute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
aligning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
common, beginning. . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
relocatable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
stack, beginning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
SET (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . 53
SETA (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 53
SFB (assembler operator). . . . . . . . . . . . . . . . . . . . . . . . . . 33
T
-t (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
tab spacing, specifying in assembler list file . . . . . . . . . . . 19
target core, specifying. See processor configuration
target processor, specifying . . . . . . . . . . . . . . . . . . . . . . . . 13
TASM assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
temporary values, defining . . . . . . . . . . . . . . . . . . . . . . 54, 77
third byte (assembler operator) . . . . . . . . . . . . . . . . . . . . . 30
121
AARM-6
U
-U (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
UGT (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . 35
ULT (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . 35
UMINUS (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . 92
unary minus (assembler operator) . . . . . . . . . . . . . . . . . . . 26
unary plus (assembler operator) . . . . . . . . . . . . . . . . . . . . . 26
#undef (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 73
unsigned greater than (assembler operator) . . . . . . . . . . . . 35
unsigned less than (assembler operator) . . . . . . . . . . . . . . 35
user symbols, case sensitive . . . . . . . . . . . . . . . . . . . . . . . . 19
V
-v (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
value assignment directives . . . . . . . . . . . . . . . . . . . . . . . . 53
values, defining temporary . . . . . . . . . . . . . . . . . . . . . . . . . 77
VAR (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . 53
_ _VER_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . . . 6
W
-w (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
disabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
X
-x (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
xcl (file extension) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 14
XOR (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . 36
XOR (CFI operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
AARM-6
Symbols
! (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
!= (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
#define (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 73
#elif (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . 73
#else (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . 73
#endif (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 73
#error (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 73
#if (assembler directive). . . . . . . . . . . . . . . . . . . . . . . . . . . 73
#ifdef (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 73
#ifndef (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 73
#include files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
#include (assembler directive) . . . . . . . . . . . . . . . . . . . . . . 73
#message (assembler directive) . . . . . . . . . . . . . . . . . . . . . 73
#undef (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 73
$ (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
$ (program location counter) . . . . . . . . . . . . . . . . . . . . . . . . 3
% (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
& (assembler operator). . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
&& (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . 29
* (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
+ (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
- (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . 2627
-B (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
-b (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
-c (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
-D (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
-E (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
-e (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
-f (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 14
-G (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
-I (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
-i (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
-j (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
-L (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
-l (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
-M (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
-N (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Index
-O (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
-o (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
-p (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
-r (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
-S (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
-s (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
-t (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
-U (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
-v (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
-w (assembler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
-x (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
--endian (assembler option) . . . . . . . . . . . . . . . . . . . . . . . . 14
/ (assembler operator). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
/*...*/ (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 80
// (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
< (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
<< (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
<= (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
<> (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
= (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
= (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
== (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
> (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
>= (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
>> (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
^ (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
_ _BIG_ENDIAN_ _ (predefined symbol) . . . . . . . . . . . . . 5
_ _DATE_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 5
_ _FILE_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . . . 5
_ _IAR_SYSTEMS_ASM_ _ (predefined symbol). . . . . . . 6
_ _LINE_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . . . 6
_ _LITTLE_ENDIAN_ _ (predefined symbol) . . . . . . . . . . 6
_ _TID_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 67
_ _TIME_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 6
_ _VER_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . . . 6
_args, predefined macro symbol . . . . . . . . . . . . . . . . . . . . 61
_BLF ( ARM) (pseudo-instruction) . . . . . . . . . . . . . . . . . 100
_BLF (Thumb) (pseudo-instruction) . . . . . . . . . . . . . . . . 100
| (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
|| (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
~ (assembler operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Numerics
32-bit expressions, loading in register . . . . . . . . . . . 100101
123
AARM-6
AARM-6