Arm® Compiler armasm User Guide

Version 6.11


Table of Contents

Preface
About this book
Using this book
Glossary
Typographic conventions
Feedback
Other information
1 Overview of the Assembler
1.1 About the Arm® Compiler toolchain assemblers
1.2 Key features of the armasm assembler
1.3 How the assembler works
1.4 Directives that can be omitted in pass 2 of the assembler
1.5 Support level definitionsSupport level definitions
2 Structure of Assembly Language Modules
2.1 Syntax of source lines in assembly language
2.2 Literals
2.3 ELF sections and the AREA directive
2.4 An example armasm syntax assembly language module
3 Writing A32/T32 Assembly Language
3.1 About the Unified Assembler Language
3.2 Syntax differences between UAL and A64 assembly language
3.3 Register usage in subroutine calls
3.4 Load immediate values
3.5 Load immediate values using MOV and MVN
3.6 Load immediate values using MOV32
3.7 Load immediate values using LDR Rd, =const
3.8 Literal pools
3.9 Load addresses into registers
3.10 Load addresses to a register using ADR
3.11 Load addresses to a register using ADRL
3.12 Load addresses to a register using LDR Rd, =label
3.13 Other ways to load and store registers
3.14 Load and store multiple register instructions
3.15 Load and store multiple register instructions in A32 and T32
3.16 Stack implementation using LDM and STM
3.17 Stack operations for nested subroutines
3.18 Block copy with LDM and STM
3.19 Memory accesses
3.20 The Read-Modify-Write operation
3.21 Optional hash with immediate constants
3.22 Use of macros
3.23 Test-and-branch macro example
3.24 Unsigned integer division macro example
3.25 Instruction and directive relocations
3.26 Symbol versions
3.27 Frame directives
3.28 Exception tables and Unwind tables
4 Using armasm
4.1 armasm command-line syntax
4.2 Specify command-line options with an environment variable
4.3 Using stdin to input source code to the assembler
4.4 Built-in variables and constants
4.5 Identifying versions of armasm in source code
4.6 Diagnostic messages
4.7 Interlocks diagnostics
4.8 Automatic IT block generation in T32 code
4.9 T32 branch target alignment
4.10 T32 code size diagnostics
4.11 A32 and T32 instruction portability diagnostics
4.12 T32 instruction width diagnostics
4.13 Two pass assembler diagnostics
4.14 Using the C preprocessor
4.15 Address alignment in A32/T32 code
4.16 Address alignment in A64 code
4.17 Instruction width selection in T32 code
5 armasm Command-line Options
5.1 --16
5.2 --32
5.3 --apcs=qualifier…qualifier
5.4 --arm
5.5 --arm_only
5.6 --bi
5.7 --bigend
5.8 --brief_diagnostics, --no_brief_diagnostics
5.9 --checkreglist
5.10 --cpreproc
5.11 --cpreproc_opts=option[,option,…]
5.12 --cpu=list
5.13 --cpu=name
5.14 --debug
5.15 --depend=dependfile
5.16 --depend_format=string
5.17 --diag_error=tag[,tag,…]
5.18 --diag_remark=tag[,tag,…]
5.19 --diag_style={arm|ide|gnu}
5.20 --diag_suppress=tag[,tag,…]
5.21 --diag_warning=tag[,tag,…]
5.22 --dllexport_all
5.23 --dwarf2
5.24 --dwarf3
5.25 --errors=errorfile
5.26 --exceptions, --no_exceptions
5.27 --exceptions_unwind, --no_exceptions_unwind
5.28 --execstack, --no_execstack
5.29 --execute_only
5.30 --fpmode=model
5.31 --fpu=list
5.32 --fpu=name
5.33 -g
5.34 --help
5.35 -idir[,dir, …]
5.36 --keep
5.37 --length=n
5.38 --li
5.39 --library_type=lib
5.40 --list=file
5.41 --list=
5.42 --littleend
5.43 -m
5.44 --maxcache=n
5.45 --md
5.46 --no_code_gen
5.47 --no_esc
5.48 --no_hide_all
5.49 --no_regs
5.50 --no_terse
5.51 --no_warn
5.52 -o filename
5.53 --pd
5.54 --predefine "directive"
5.55 --reduce_paths, --no_reduce_paths
5.56 --regnames
5.57 --report-if-not-wysiwyg
5.58 --show_cmdline
5.59 --thumb
5.60 --unaligned_access, --no_unaligned_access
5.61 --unsafe
5.62 --untyped_local_labels
5.63 --version_number
5.64 --via=filename
5.65 --vsn
5.66 --width=n
5.67 --xref
6 Symbols, Literals, Expressions, and Operators
6.1 Symbol naming rules
6.2 Variables
6.3 Numeric constants
6.4 Assembly time substitution of variables
6.5 Register-relative and PC-relative expressions
6.6 Labels
6.7 Labels for PC-relative addresses
6.8 Labels for register-relative addresses
6.9 Labels for absolute addresses
6.10 Numeric local labels
6.11 Syntax of numeric local labels
6.12 String expressions
6.13 String literals
6.14 Numeric expressions
6.15 Syntax of numeric literals
6.16 Syntax of floating-point literals
6.17 Logical expressions
6.18 Logical literals
6.19 Unary operators
6.20 Binary operators
6.21 Multiplicative operators
6.22 String manipulation operators
6.23 Shift operators
6.24 Addition, subtraction, and logical operators
6.25 Relational operators
6.26 Boolean operators
6.27 Operator precedence
6.28 Difference between operator precedence in assembly language and C
7 Directives Reference
7.1 Alphabetical list of directives
7.2 About assembly control directives
7.3 About frame directives
7.4 ALIAS
7.5 ALIGN
7.6 AREA
7.7 ARM or CODE32 directive
7.8 ASSERT
7.9 ATTR
7.10 CN
7.11 CODE16 directive
7.12 COMMON
7.13 CP
7.14 DATA
7.15 DCB
7.16 DCD and DCDU
7.17 DCDO
7.18 DCFD and DCFDU
7.19 DCFS and DCFSU
7.20 DCI
7.21 DCQ and DCQU
7.22 DCW and DCWU
7.23 END
7.24 ENDFUNC or ENDP
7.25 ENTRY
7.26 EQU
7.27 EXPORT or GLOBAL
7.28 EXPORTAS
7.29 FIELD
7.30 FRAME ADDRESS
7.31 FRAME POP
7.32 FRAME PUSH
7.33 FRAME REGISTER
7.34 FRAME RESTORE
7.35 FRAME RETURN ADDRESS
7.36 FRAME SAVE
7.37 FRAME STATE REMEMBER
7.38 FRAME STATE RESTORE
7.39 FRAME UNWIND ON
7.40 FRAME UNWIND OFF
7.41 FUNCTION or PROC
7.42 GBLA, GBLL, and GBLS
7.43 GET or INCLUDE
7.44 IF, ELSE, ENDIF, and ELIF
7.45 IMPORT and EXTERN
7.46 INCBIN
7.47 INFO
7.48 KEEP
7.49 LCLA, LCLL, and LCLS
7.50 LTORG
7.51 MACRO and MEND
7.52 MAP
7.53 MEXIT
7.54 NOFP
7.55 OPT
7.56 QN, DN, and SN
7.57 RELOC
7.58 REQUIRE
7.59 REQUIRE8 and PRESERVE8
7.60 RLIST
7.61 RN
7.62 ROUT
7.63 SETA, SETL, and SETS
7.64 SPACE or FILL
7.65 THUMB directive
7.66 TTL and SUBT
7.67 WHILE and WEND
7.68 WN and XN
8 armasm-Specific Instruction Set Features
8.1 armasm support for the CSDB instruction
8.2 A32 and T32 pseudo-instruction summary
8.3 ADRL pseudo-instruction
8.4 CPY pseudo-instruction
8.5 LDR pseudo-instruction
8.6 MOV32 pseudo-instruction
8.7 NEG pseudo-instruction
8.8 UND pseudo-instruction
9 Via File Syntax
9.1 Overview of via files
9.2 Via file syntax rules

List of Figures

1-1 Integration boundaries in Arm Compiler 6.

List of Tables

3-1 Syntax differences between UAL and A64 assembly language
3-2 A32 state immediate values (8-bit)
3-3 A32 state immediate values in MOV instructions
3-4 32-bit T32 immediate values
3-5 32-bit T32 immediate values in MOV instructions
3-6 Stack-oriented suffixes and equivalent addressing mode suffixes
3-7 Suffixes for load and store multiple instructions
4-1 Built-in variables
4-2 Built-in Boolean constants
4-3 Predefined macros
4-4 armclang equivalent command-line options
5-1 Supported Arm architectures
5-2 Severity of diagnostic messages
5-3 Specifying a command-line option and an AREA directive for GNU-stack sections
6-1 Unary operators that return strings
6-2 Unary operators that return numeric or logical values
6-3 Multiplicative operators
6-4 String manipulation operators
6-5 Shift operators
6-6 Addition, subtraction, and logical operators
6-7 Relational operators
6-8 Boolean operators
6-9 Operator precedence in Arm assembly language
6-10 Operator precedence in C
7-1 List of directives
7-2 OPT directive settings
8-1 Summary of pseudo-instructions
8-2 Range and encoding of expr

Release Information

Document History
Issue Date Confidentiality Change
A 14 March 2014 Non-Confidential Arm Compiler v6.00 Release
B 15 December 2014 Non-Confidential Arm Compiler v6.01 Release
C 30 June 2015 Non-Confidential Arm Compiler v6.02 Release
D 18 November 2015 Non-Confidential Arm Compiler v6.3 Release
E 24 February 2016 Non-Confidential Arm Compiler v6.4 Release
F 29 June 2016 Non-Confidential Arm Compiler v6.5 Release
G 04 November 2016 Non-Confidential Arm Compiler v6.6 Release
0607-00 05 April 2017 Non-Confidential Arm Compiler v6.7 Release. Document numbering scheme has changed.
0608-00 30 July 2017 Non-Confidential Arm Compiler v6.8 Release.
0609-00 25 October 2017 Non-Confidential Arm Compiler v6.9 Release.
0610-00 14 March 2018 Non-Confidential Arm Compiler v6.10 Release.
0610-01 01 June 2018 Non-Confidential Document update to include the CSDB instruction for the Arm Compiler v6.10 Release.
0611-00 25 October 2018 Non-Confidential Arm Compiler v6.11 Release. Removed the A32/T32 and A64 instruction set descriptions.

Non-Confidential Proprietary Notice

This document is protected by copyright and other related rights and the practice or implementation of the information contained in this document may be protected by one or more patents or pending patent applications. No part of this document may be reproduced in any form by any means without the express prior written permission of Arm. No license, express or implied, by estoppel or otherwise to any intellectual property rights is granted by this document unless specifically stated.

Your access to the information in this document is conditional upon your acceptance that you will not use or permit others to use the information for the purposes of determining whether implementations infringe any third party patents.

THIS DOCUMENT IS PROVIDED “AS IS”. ARM PROVIDES NO REPRESENTATIONS AND NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY, NON-INFRINGEMENT OR FITNESS FOR A PARTICULAR PURPOSE WITH RESPECT TO THE DOCUMENT. For the avoidance of doubt, Arm makes no representation with respect to, and has undertaken no analysis to identify or understand the scope and content of, third party patents, copyrights, trade secrets, or other rights.

This document may include technical inaccuracies or typographical errors.

TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL ARM BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF ANY USE OF THIS DOCUMENT, EVEN IF ARM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

This document consists solely of commercial items. You shall be responsible for ensuring that any use, duplication or disclosure of this document complies fully with any relevant export laws and regulations to assure that this document or any portion thereof is not exported, directly or indirectly, in violation of such export laws. Use of the word “partner” in reference to Arm’s customers is not intended to create or refer to any partnership relationship with any other company. Arm may make changes to this document at any time and without notice.

If any of the provisions contained in these terms conflict with any of the provisions of any click through or signed written agreement covering this document with Arm, then the click through or signed written agreement prevails over and supersedes the conflicting provisions of these terms. This document may be translated into other languages for convenience, and you agree that if there is any conflict between the English version of this document and any translation, the terms of the English version of the Agreement shall prevail.

The Arm corporate logo and words marked with ® or ™ are registered trademarks or trademarks of Arm Limited (or its subsidiaries) in the US and/or elsewhere. All rights reserved. Other brands and names mentioned in this document may be the trademarks of their respective owners. Please follow Arm’s trademark usage guidelines at http://www.arm.com/company/policies/trademarks.

Copyright © 2014–2018 Arm Limited (or its affiliates). All rights reserved.

Arm Limited. Company 02557590 registered in England.

110 Fulbourn Road, Cambridge, England CB1 9NJ.

LES-PRE-20349

Confidentiality Status

This document is Non-Confidential. The right to use, copy and disclose this document may be subject to license restrictions in accordance with the terms of the agreement entered into by Arm and the party that Arm delivered this document to.

Unrestricted Access is an Arm internal classification.

Product Status

The information in this document is Final, that is for a developed product.

Web Address

Non-ConfidentialPDF file icon PDF version100069_0611_00_en
Copyright © 2014–2018 Arm Limited or its affiliates. All rights reserved.