Keil™, An ARM® Company

RealView Assembler User's Guide

RealView Assembler User's Guide

RealView® Compilation Tools for µVision Assembler Guide

Version 3.1

Proprietary Notice

Words and logos marked with ® or ™ are registered trademarks or trademarks owned by ARM Limited. Other brands and names mentioned herein may be the trademarks of their respective owners.

Neither the whole nor any part of the information contained in, or the product described in, this document may be adapted or reproduced in any material form except with the prior written permission of the copyright holder.

The product described in this document is subject to continuous developments and improvements. All particulars of the product and its use contained in this document are given by ARM in good faith. However, all warranties implied or expressed, including but not limited to implied warranties of merchantability, or fitness for purpose, are excluded.

This document is intended only to assist the reader in the use of the product. ARM Limited shall not be liable for any loss or damage arising from the use of any information in this document, or any error or omission in such information, or any incorrect use of the product.

Where the term ARM is used it means “ARM or any of its subsidiaries as appropriate”.

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.

Product Status

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

Revision History
Revision AMay 2007
Release for RVCT for µVision v3.1

Table of Contents

Preface
About this book
Intended audience
Using this book
Typographical conventions
Further reading
Feedback
Feedback on RealView Compilation Tools
Feedback on this book
1. Introduction
1.1. About the RealView Compilation Tools assemblers
1.1.1. ARM assembly language
2. Writing ARM Assembly Language
2.1. Introduction
2.2. Overview of the ARM architecture
2.2.1. Architecture versions
2.2.2. ARM, Thumb, Thumb‑2, and Thumb‑2EE instruction sets
2.2.3. ARM, Thumb, and ThumbEE state
2.2.4. Processor mode
2.2.5. Registers
2.2.6. Instruction set overview
2.2.7. Instruction capabilities
2.3. Structure of assembly language modules
2.3.1. Layout of assembly language source files
2.3.2. An example ARM assembly language module
2.3.3. Calling subroutines
2.4. Conditional execution
2.4.1. The ALU status flags
2.4.2. Conditional execution
2.4.3. Using conditional execution
2.4.4. Example of the use of conditional execution
2.4.5. The Q flag
2.5. Loading constants into registers
2.5.1. Direct loading with MOV and MVN
2.5.2. Loading with MOV32
2.5.3. Loading with LDR Rd, =const
2.6. Loading addresses into registers
2.6.1. Direct loading with ADR and ADRL
2.6.2. Loading addresses with LDR Rd, =label
2.7. Load and store multiple register instructions
2.7.1. Load and store multiple instructions available in ARM and Thumb
2.7.2. Implementing stacks with LDM and STM
2.7.3. Block copy with LDM and STM
2.8. Using macros
2.8.1. Test‑and‑branch macro example
2.8.2. Unsigned integer division macro example
2.9. Using frame directives
2.10. Assembly language changes
3. Assembler Reference
3.1. Command syntax
3.1.1. Obtaining a list of available options
3.1.2. Specifying command‑line options with an environment variable
3.1.3. AAPCS
3.1.4. Floating‑point model
3.1.5. Memory access attributes
3.1.6. Pre‑executing a SET directive
3.1.7. Splitting long LDMs and STMs
3.1.8. Listing output to a file
3.1.9. Project template options
3.1.10. Controlling the output of diagnostic messages
3.1.11. Controlling exception table generation
3.2. Format of source lines
3.3. Predefined register and coprocessor names
3.3.1. Predeclared register names
3.3.2. Predeclared extension register names
3.3.3. Predeclared coprocessor names
3.4. Built‑in variables and constants
3.5. Symbols
3.5.1. Symbol naming rules
3.5.2. Variables
3.5.3. Numeric constants
3.5.4. Assembly time substitution of variables
3.5.5. Labels
3.5.6. Local labels
3.6. Expressions, literals, and operators
3.6.1. String expressions
3.6.2. String literals
3.6.3. Numeric expressions
3.6.4. Numeric literals
3.6.5. Floating‑point literals
3.6.6. Register‑relative and program‑relative expressions
3.6.7. Logical expressions
3.6.8. Logical literals
3.6.9. Operator precedence
3.6.10. Unary operators
3.6.11. Binary operators
3.7. Diagnostic messages
3.7.1. Interlocks
3.7.2. IT block generation
3.7.3. Thumb branch target alignment
3.8. Using the C preprocessor
4. ARM and Thumb Instructions
4.1. Instruction summary
4.2. Instruction width selection in Thumb
4.2.1. Instruction width specifiers, .W and .N
4.2.2. Different behavior for some instructions
4.2.3. Diagnostic warning
4.3. Memory access instructions
4.3.1. Address alignment
4.3.2. LDR and STR (immediate offset)
4.3.3. LDR and STR (register offset)
4.3.4. LDR and STR (User mode)
4.3.5. LDR (pc‑relative)
4.3.6. ADR
4.3.7. PLD and PLI
4.3.8. LDM and STM
4.3.9. PUSH and POP
4.3.10. RFE
4.3.11. SRS
4.3.12. LDREX and STREX
4.3.13. CLREX
4.3.14. SWP and SWPB
4.4. General data processing instructions
4.4.1. Flexible second operand
4.4.2. ADD, SUB, RSB, ADC, SBC, and RSC
4.4.3. SUBS pc, LR
4.4.4. AND, ORR, EOR, BIC, and ORN
4.4.5. CLZ
4.4.6. CMP and CMN
4.4.7. MOV and MVN
4.4.8. MOVT
4.4.9. TST and TEQ
4.4.10. SEL
4.4.11. REV, REV16, REVSH, and RBIT
4.4.12. ASR, LSL, LSR, ROR, and RRX
4.4.13. IT
4.4.14. SDIV and UDIV
4.5. Multiply instructions
4.5.1. MUL, MLA, and MLS
4.5.2. UMULL, UMLAL, SMULL, and SMLAL
4.5.3. SMULxy and SMLAxy
4.5.4. SMULWy and SMLAWy
4.5.5. SMLALxy
4.5.6. SMUAD{X} and SMUSD{X}
4.5.7. SMMUL, SMMLA, and SMMLS
4.5.8. SMLAD and SMLSD
4.5.9. SMLALD and SMLSLD
4.5.10. UMAAL
4.6. Saturating instructions
4.6.1. Saturating arithmetic
4.6.2. QADD, QSUB, QDADD, and QDSUB
4.6.3. SSAT and USAT
4.7. Parallel instructions
4.7.1. Parallel add and subtract
4.7.2. USAD8 and USADA8
4.7.3. SSAT16 and USAT16
4.8. Packing and unpacking instructions
4.8.1. BFC and BFI
4.8.2. SBFX and UBFX
4.8.3. SXT, SXTA, UXT, and UXTA
4.8.4. PKHBT and PKHTB
4.9. Branch instructions
4.9.1. B, BL, BX, BLX, and BXJ
4.9.2. CBZ and CBNZ
4.9.3. TBB and TBH
4.10. Coprocessor instructions
4.10.1. CDP and CDP2
4.10.2. MCR, MCR2, MCRR, and MCRR2
4.10.3. MRC, MRC2, MRRC and MRRC2
4.10.4. LDC, LDC2, STC, and STC2
4.11. Miscellaneous instructions
4.11.1. BKPT
4.11.2. SVC
4.11.3. MRS
4.11.4. MSR
4.11.5. CPS
4.11.6. SMC
4.11.7. SETEND
4.11.8. NOP, SEV, WFE, WFI, and YIELD
4.11.9. DBG, DMB, DSB, and ISB
4.12. ThumbEE instructions
4.12.1. ENTERX and LEAVEX
4.12.2. CHKA
4.12.3. HB, HBL, HBLP, and HBP
4.13. Pseudo‑instructions
4.13.1. ADRL pseudo‑instruction
4.13.2. MOV32 pseudo‑instruction
4.13.3. LDR pseudo‑instruction
4.13.4. UND pseudo‑instruction
5. Directives Reference
5.1. Alphabetical list of directives
5.2. Symbol definition directives
5.2.1. GBLA, GBLL, and GBLS
5.2.2. LCLA, LCLL, and LCLS
5.2.3. SETA, SETL, and SETS
5.2.4. RELOC
5.2.5. RN
5.2.6. RLIST
5.2.7. CN
5.2.8. CP
5.3. Data definition directives
5.3.1. LTORG
5.3.2. MAP
5.3.3. FIELD
5.3.4. SPACE
5.3.5. DCB
5.3.6. DCD and DCDU
5.3.7. DCDO
5.3.8. DCFD and DCFDU
5.3.9. DCFS and DCFSU
5.3.10. DCI
5.3.11. DCQ and DCQU
5.3.12. DCW and DCWU
5.3.13. COMMON
5.3.14. DATA
5.4. Assembly control directives
5.4.1. Nesting directives
5.4.2. MACRO and MEND
5.4.3. MEXIT
5.4.4. IF, ELSE, ENDIF, and ELIF
5.4.5. WHILE and WEND
5.5. Frame directives
5.5.1. FRAME ADDRESS
5.5.2. FRAME POP
5.5.3. FRAME PUSH
5.5.4. FRAME REGISTER
5.5.5. FRAME RESTORE
5.5.6. FRAME RETURN ADDRESS
5.5.7. FRAME SAVE
5.5.8. FRAME STATE REMEMBER
5.5.9. FRAME STATE RESTORE
5.5.10. FRAME UNWIND ON
5.5.11. FRAME UNWIND OFF
5.5.12. FUNCTION or PROC
5.5.13. ENDFUNC or ENDP
5.6. Reporting directives
5.6.1. ASSERT
5.6.2. INFO
5.6.3. OPT
5.6.4. TTL and SUBT
5.7. Instruction set and syntax selection directives
5.7.1. ARM, THUMB, THUMBX, CODE16 and CODE32
5.8. Miscellaneous directives
5.8.1. ALIGN
5.8.2. AREA
5.8.3. END
5.8.4. ENTRY
5.8.5. EQU
5.8.6. EXPORT or GLOBAL
5.8.7. EXPORTAS
5.8.8. GET or INCLUDE
5.8.9. IMPORT and EXTERN
5.8.10. INCBIN
5.8.11. KEEP
5.8.12. NOFP
5.8.13. REQUIRE
5.8.14. REQUIRE8 and PRESERVE8
5.8.15. ROUT

List of Figures

4.1. ROR
4.2. RRX
Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0379A