ARM® Compiler v5.04 for µVision armasm User Guide

Version 5


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 assembler
1.3 How the assembler works
1.4 Directives that can be omitted in pass 2 of the assembler
2 Overview of the ARM Architecture
2.1 About the ARM architecture
2.2 ARM, Thumb, and ThumbEE instruction sets
2.3 Changing between ARM, Thumb, and ThumbEE state
2.4 Processor modes, and privileged and unprivileged software execution
2.5 Processor modes in ARMv6-M and ARMv7-M
2.6 VFP hardware
2.7 ARM registers
2.8 General-purpose registers
2.9 Register accesses
2.10 Predeclared core register names
2.11 Predeclared extension register names
2.12 Predeclared coprocessor names
2.13 Program Counter
2.14 Application Program Status Register
2.15 The Q flag
2.16 Current Program Status Register
2.17 Saved Program Status Registers
2.18 ARM and Thumb instruction set overview
2.19 Access to the inline barrel shifter
3 Structure of Assembly Language Modules
3.1 Syntax of source lines in assembly language
3.2 Literals
3.3 ELF sections and the AREA directive
3.4 An example ARM assembly language module
4 Writing ARM Assembly Language
4.1 About the Unified Assembler Language
4.2 Register usage in subroutine calls
4.3 Load 32-bit immediates into registers
4.4 Load immediate values using MOV and MVN
4.5 Load 32-bit values to a register using MOV32
4.6 Load 32-bit immediate values to a register using LDR Rd, =const
4.7 Literal pools
4.8 Load addresses into registers
4.9 Load addresses to a register using ADR
4.10 Load addresses to a register using ADRL
4.11 Load addresses to a register using LDR Rd, =label
4.12 Other ways to load and store registers
4.13 Load and store multiple register instructions
4.14 Load and store multiple register instructions in ARM and Thumb
4.15 Stack implementation using LDM and STM
4.16 Stack operations for nested subroutines
4.17 Block copy with LDM and STM
4.18 Memory accesses
4.19 The Read-Modify-Write operation
4.20 Optional hash with immediate constants
4.21 About macros
4.22 Test-and-branch macro example
4.23 Unsigned integer division macro example
4.24 Instruction and directive relocations
4.25 Frame directives
4.26 Exception tables and Unwind tables
4.27 Assembly language changes after RVCT v2.1
5 Condition Codes
5.1 Conditional instructions
5.2 Conditional execution in ARM state
5.3 Conditional execution in Thumb state
5.4 Updates to the condition flags
5.5 Condition code suffixes
5.6 Comparison of condition code meanings
5.7 Benefits of using conditional execution
5.8 Illustration of the benefits of using conditional instructions
5.9 Optimization for execution speed
6 Using the Assembler
6.1 Assembler command-line syntax
6.2 Specify command-line options with an environment variable
6.3 Overview of via files
6.4 Via file syntax rules
6.5 Using stdin to input source code to the assembler
6.6 Built-in variables and constants
6.7 Identifying versions of armasm in source code
6.8 Diagnostic messages
6.9 Interlocks diagnostics
6.10 Automatic IT block generation
6.11 Thumb branch target alignment
6.12 Thumb code size diagnostics
6.13 ARM and Thumb instruction portability diagnostics
6.14 Instruction width
6.15 Two pass assembler diagnostics
6.16 Conditional assembly
6.17 Using the C preprocessor
6.18 Address alignment
6.19 Instruction width selection in Thumb
7 Symbols, Literals, Expressions, and Operators
7.1 Symbol naming rules
7.2 Variables
7.3 Numeric constants
7.4 Assembly time substitution of variables
7.5 Register-relative and PC-relative expressions
7.6 Labels
7.7 Labels for PC-relative addresses
7.8 Labels for register-relative addresses
7.9 Labels for absolute addresses
7.10 Numeric local labels
7.11 Syntax of numeric local labels
7.12 String expressions
7.13 String literals
7.14 Numeric expressions
7.15 Syntax of numeric literals
7.16 Syntax of floating-point literals
7.17 Logical expressions
7.18 Logical literals
7.19 Unary operators
7.20 Binary operators
7.21 Multiplicative operators
7.22 String manipulation operators
7.23 Shift operators
7.24 Addition, subtraction, and logical operators
7.25 Relational operators
7.26 Boolean operators
7.27 Operator precedence
7.28 Difference between operator precedence in assembly language and C
8 VFP Programming
8.1 Architecture support for VFP
8.2 Half-precision extension
8.3 Fused Multiply-Add extension
8.4 Extension register bank mapping
8.5 VFP views of the extension register bank
8.6 Load values to VFP registers
8.7 Conditional execution of VFP instructions
8.8 Floating-point exceptions
8.9 VFP data types
8.10 Extended notation
8.11 VFP system registers
8.12 Flush-to-zero mode
8.13 When to use flush-to-zero mode
8.14 The effects of using flush-to-zero mode
8.15 Operations not affected by flush-to-zero mode
8.16 VFP vector mode
8.17 Vectors in the VFP extension register bank
8.18 VFP vector wrap-around
8.19 VFP vector stride
8.20 Restriction on vector length
8.21 Control of scalar, vector, and mixed operations
8.22 Overview of VFP directives and vector notation
8.23 Pre-UAL VFP syntax and mnemonics
8.24 Vector notation
8.25 VFPASSERT SCALAR
8.26 VFPASSERT VECTOR
9 Assembler Command-line Options
9.1 --16
9.2 --32
9.3 --apcs=qualifier…qualifier
9.4 --arm
9.5 --arm_only
9.6 --bi
9.7 --bigend
9.8 --brief_diagnostics, --no_brief_diagnostics
9.9 --checkreglist
9.10 --compatible=name
9.11 --cpreproc
9.12 --cpreproc_opts=options
9.13 --cpu=list
9.14 --cpu=name
9.15 --debug
9.16 --depend=dependfile
9.17 --depend_format=string
9.18 --diag_error=tag[,tag,…]
9.19 --diag_remark=tag[,tag,…]
9.20 --diag_style={arm|ide|gnu}
9.21 --diag_suppress=tag[,tag,…]
9.22 --diag_warning=tag[,tag,…]
9.23 --dllexport_all
9.24 --dwarf2
9.25 --dwarf3
9.26 --errors=errorfile
9.27 --execstack, --no_execstack
9.28 --execute_only
9.29 --exceptions, --no_exceptions
9.30 --exceptions_unwind, --no_exceptions_unwind
9.31 --fpmode=model
9.32 --fpu=list
9.33 --fpu=name
9.34 -g
9.35 --help
9.36 -idir{,dir, …}
9.37 --keep
9.38 --length=n
9.39 --li
9.40 --library_type=lib
9.41 --licretry
9.42 --list=file
9.43 --list=
9.44 --littleend
9.45 -m
9.46 --maxcache=n
9.47 --md
9.48 --no_code_gen
9.49 --no_esc
9.50 --no_hide_all
9.51 --no_regs
9.52 --no_terse
9.53 --no_warn
9.54 -o filename
9.55 --pd
9.56 --predefine "directive"
9.57 --reduce_paths, --no_reduce_paths
9.58 --regnames=none
9.59 --regnames=callstd
9.60 --regnames=all
9.61 --report-if-not-wysiwyg
9.62 --show_cmdline
9.63 --split_ldm
9.64 --thumb
9.65 --thumbx
9.66 --unaligned_access, --no_unaligned_access
9.67 --unsafe
9.68 --untyped_local_labels
9.69 --version_number
9.70 --via=filename
9.71 --vsn
9.72 --width=n
9.73 --xref
10 ARM and Thumb Instructions
10.1 ARM and Thumb instruction summary
10.2 Instruction width specifiers
10.3 Flexible second operand (Operand2)
10.4 Syntax of Operand2 as a constant
10.5 Syntax of Operand2 as a register with optional shift
10.6 Shift operations
10.7 Saturating instructions
10.8 Condition codes
10.9 ADC
10.10 ADD
10.11 ADR (PC-relative)
10.12 ADR (register-relative)
10.13 ADRL pseudo-instruction
10.14 AND
10.15 ASR
10.16 B
10.17 BFC
10.18 BFI
10.19 BIC
10.20 BKPT
10.21 BL
10.22 BLX
10.23 BX
10.24 BXJ
10.25 CBZ and CBNZ
10.26 CDP and CDP2
10.27 CLREX
10.28 CLZ
10.29 CMP and CMN
10.30 CPS
10.31 CPY pseudo-instruction
10.32 DBG
10.33 DMB
10.34 DSB
10.35 EOR
10.36 ERET
10.37 ISB
10.38 IT
10.39 LDC and LDC2
10.40 LDM
10.41 LDR (immediate offset)
10.42 LDR (PC-relative)
10.43 LDR (register offset)
10.44 LDR (register-relative)
10.45 LDR pseudo-instruction
10.46 LDR, unprivileged
10.47 LDREX
10.48 LSL
10.49 LSR
10.50 MAR
10.51 MCR and MCR2
10.52 MCRR and MCRR2
10.53 MIA, MIAPH, and MIAxy
10.54 MLA
10.55 MLS
10.56 MOV
10.57 MOV32 pseudo-instruction
10.58 MOVT
10.59 MRA
10.60 MRC and MRC2
10.61 MRRC and MRRC2
10.62 MRS (PSR to general-purpose register)
10.63 MRS (system coprocessor register to ARM register)
10.64 MSR (ARM register to system coprocessor register)
10.65 MSR (general-purpose register to PSR)
10.66 MUL
10.67 MVN
10.68 NEG pseudo-instruction
10.69 NOP
10.70 ORN (Thumb only)
10.71 ORR
10.72 PKHBT and PKHTB
10.73 PLD, PLDW, and PLI
10.74 POP
10.75 PUSH
10.76 QADD
10.77 QADD8
10.78 QADD16
10.79 QASX
10.80 QDADD
10.81 QDSUB
10.82 QSAX
10.83 QSUB
10.84 QSUB8
10.85 QSUB16
10.86 RBIT
10.87 REV
10.88 REV16
10.89 REVSH
10.90 RFE
10.91 ROR
10.92 RRX
10.93 RSB
10.94 RSC
10.95 SADD8
10.96 SADD16
10.97 SASX
10.98 SBC
10.99 SBFX
10.100 SDIV
10.101 SEL
10.102 SETEND
10.103 SEV
10.104 SHADD8
10.105 SHADD16
10.106 SHASX
10.107 SHSAX
10.108 SHSUB8
10.109 SHSUB16
10.110 SMC
10.111 SMLAxy
10.112 SMLAD
10.113 SMLAL
10.114 SMLALD
10.115 SMLALxy
10.116 SMLAWy
10.117 SMLSD
10.118 SMLSLD
10.119 SMMLA
10.120 SMMLS
10.121 SMMUL
10.122 SMUAD
10.123 SMULxy
10.124 SMULL
10.125 SMULWy
10.126 SMUSD
10.127 SRS
10.128 SSAT
10.129 SSAT16
10.130 SSAX
10.131 SSUB8
10.132 SSUB16
10.133 STC and STC2
10.134 STM
10.135 STR (immediate offset)
10.136 STR (register offset)
10.137 STR, unprivileged
10.138 STREX
10.139 SUB
10.140 SUBS pc, lr
10.141 SVC
10.142 SWP and SWPB
10.143 SXTAB
10.144 SXTAB16
10.145 SXTAH
10.146 SXTB
10.147 SXTB16
10.148 SXTH
10.149 SYS
10.150 TBB and TBH
10.151 TEQ
10.152 TST
10.153 UADD8
10.154 UADD16
10.155 UASX
10.156 UBFX
10.157 UDIV
10.158 UHADD8
10.159 UHADD16
10.160 UHASX
10.161 UHSAX
10.162 UHSUB8
10.163 UHSUB16
10.164 UMAAL
10.165 UMLAL
10.166 UMULL
10.167 UND pseudo-instruction
10.168 UQADD8
10.169 UQADD16
10.170 UQASX
10.171 UQSAX
10.172 UQSUB8
10.173 UQSUB16
10.174 USAD8
10.175 USADA8
10.176 USAT
10.177 USAT16
10.178 USAX
10.179 USUB8
10.180 USUB16
10.181 UXTAB
10.182 UXTAB16
10.183 UXTAH
10.184 UXTB
10.185 UXTB16
10.186 UXTH
10.187 WFE
10.188 WFI
10.189 YIELD
11 ThumbEE Instructions
11.1 ThumbEE instruction differences
11.2 Instruction summary
11.3 CHKA
11.4 ENTERX and LEAVEX
11.5 HB, HBL, HBLP, and HBP
12 VFP Instructions
12.1 Summary of VFP instructions
12.2 VABS (floating-point)
12.3 VADD (floating-point)
12.4 VCMP, VCMPE
12.5 VCVT (between single-precision and double-precision)
12.6 VCVT (between floating-point and integer)
12.7 VCVT (between floating-point and fixed-point)
12.8 VCVTB, VCVTT (half-precision extension)
12.9 VDIV
12.10 VFMA, VFMS, VFNMA, VFNMS
12.11 VLDM
12.12 VLDR
12.13 VLDR (post-increment and pre-decrement)
12.14 VLDR pseudo-instruction
12.15 VMLA (floating-point)
12.16 VMLS (floating-point)
12.17 VMOV (floating-point)
12.18 VMOV (between one ARM register and single precision VFP)
12.19 VMOV (between two ARM registers and an extension register)
12.20 VMRS
12.21 VMSR
12.22 VMUL (floating-point)
12.23 VNEG (floating-point)
12.24 VNMLA (floating-point)
12.25 VNMLS (floating-point)
12.26 VNMUL (floating-point)
12.27 VPOP
12.28 VPUSH
12.29 VSQRT
12.30 VSTM
12.31 VSTR
12.32 VSTR (post-increment and pre-decrement)
12.33 VSUB (floating-point)
13 Directives Reference
13.1 Alphabetical list of directives
13.2 About assembly control directives
13.3 About frame directives
13.4 ALIAS
13.5 ALIGN
13.6 AREA
13.7 ARM, THUMB, THUMBX, CODE16, and CODE32
13.8 ASSERT
13.9 ATTR
13.10 CN
13.11 COMMON
13.12 CP
13.13 DATA
13.14 DCB
13.15 DCD and DCDU
13.16 DCDO
13.17 DCFD and DCFDU
13.18 DCFS and DCFSU
13.19 DCI
13.20 DCQ and DCQU
13.21 DCW and DCWU
13.22 END
13.23 ENTRY
13.24 EQU
13.25 EXPORT or GLOBAL
13.26 EXPORTAS
13.27 FRAME ADDRESS
13.28 FRAME POP
13.29 FRAME PUSH
13.30 FRAME REGISTER
13.31 FRAME RESTORE
13.32 FRAME RETURN ADDRESS
13.33 FRAME SAVE
13.34 FRAME STATE REMEMBER
13.35 FRAME STATE RESTORE
13.36 FRAME UNWIND ON
13.37 FRAME UNWIND OFF
13.38 FUNCTION or PROC
13.39 ENDFUNC or ENDP
13.40 FIELD
13.41 GBLA, GBLL, and GBLS
13.42 GET or INCLUDE
13.43 IF, ELSE, ENDIF, and ELIF
13.44 IMPORT and EXTERN
13.45 INCBIN
13.46 INFO
13.47 KEEP
13.48 LCLA, LCLL, and LCLS
13.49 LTORG
13.50 MACRO and MEND
13.51 MAP
13.52 MEXIT
13.53 NOFP
13.54 OPT
13.55 DN and SN
13.56 RELOC
13.57 REQUIRE
13.58 REQUIRE8 and PRESERVE8
13.59 RLIST
13.60 RN
13.61 ROUT
13.62 SETA, SETL, and SETS
13.63 SPACE or FILL
13.64 TTL and SUBT
13.65 WHILE and WEND

List of Figures

2-1 Organization of general-purpose registers and Program Status Registers
8-1 Extension register bank
8-2 VFPv2 register banks
8-3 VFPv3 register banks
10-1 ASR #3
10-2 LSR #3
10-3 LSL #3
10-4 ROR #3
10-5 RRX

List of Tables

2-1 ARM processor modes
2-2 Predeclared core registers
2-3 Predeclared extension registers
2-4 Predeclared coprocessor registers
2-5 Instruction groups
4-1 ARM state immediate values (8-bit)
4-2 ARM state immediate values in MOV instructions
4-3 32-bit Thumb immediate values
4-4 32-bit Thumb immediate values in MOV instructions
4-5 Stack-oriented suffixes and equivalent addressing mode suffixes
4-6 Suffixes for load and store multiple instructions
4-7 Changes from earlier ARM assembly language
4-8 Relaxation of requirements
4-9 Differences between pre-UAL Thumb syntax and UAL syntax
5-1 Condition code suffixes
5-2 Condition codes
5-3 Conditional branches only
5-4 All instructions conditional
6-1 Built-in variables
6-2 Built-in Boolean constants
6-3 Predefined macros
6-4 {TARGET_ARCH_ARM} in relation to {TARGET_ARCH_THUMB}
6-5 Command-line options
6-6 armcc equivalent command-line options
7-1 Unary operators that return strings
7-2 Unary operators that return numeric or logical values
7-3 Multiplicative operators
7-4 String manipulation operators
7-5 Shift operators
7-6 Addition, subtraction, and logical operators
7-7 Relational operators
7-8 Boolean operators
7-9 Operator precedence in ARM assembly language
7-10 Operator precedence in C
8-1 VFP data type specifiers
8-2 Pre-UAL VFP mnemonics
8-3 Floating-point values for use with FCONST
9-1 Compatible processor or architecture combinations
9-2 Supported ARM architectures
9-3 Severity of diagnostic messages
9-4 Specifying a command-line option and an AREA directive for GNU-stack sections
10-1 Summary of ARM and Thumb instructions
10-2 Condition code suffixes
10-3 PC-relative offsets
10-4 Register-relative offsets
10-5 B instruction availability and range
10-6 BL instruction availability and range
10-7 BLX instruction availability and range
10-8 BX instruction availability and range
10-9 BXJ instruction availability and range
10-10 Offsets and architectures, LDR, word, halfword, and byte
10-11 PC-relative offsets
10-12 Options and architectures, LDR (register offsets)
10-13 Register-relative offsets
10-14 Offsets and architectures, LDR (User mode)
10-15 Offsets and architectures, STR, word, halfword, and byte
10-16 Options and architectures, STR (register offsets)
10-17 Offsets and architectures, STR (User mode)
10-18 Range and encoding of expr
11-1 ThumbEE LDR/STR (immediate offset) offsets and availability
11-2 ThumbEE LDR/STR (register offset) offsets and availability
11-3 ThumbEE LDR (register-relative) offsets
11-4 Additional ThumbEE instructions
12-1 Summary of VFP instructions
13-1 List of directives
13-2 OPT directive settings

Release Information

Document History
Issue Date Confidentiality Change
A May 2007 Non-Confidential Release for RVCT v3.1 for µVision
B December 2008 Non-Confidential Release for RVCT v4.0 for µVision
C June 2011 Non-Confidential Release for ARM Compiler v4.1 for µVision
D July 2012 Non-Confidential Release for ARM Compiler v5.02 for µVision
E 30 May 2014 Non-Confidential Release for ARM Compiler v5.04 for µVision

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 signed written agreement covering this document with ARM, then the 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.
Copyright © [2007, 2008, 2011, 2012, 2014], 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 versionARM DUI0379E
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.