ARM Developer Suite Assembler Guide

3y ago
59 Views
2 Downloads
1.57 MB
354 Pages
Last View : 17d ago
Last Download : 3m ago
Upload by : Josiah Pursley
Transcription

ARM Developer Suite Version 1.2Assembler GuideCopyright 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B

ARM Developer SuiteAssembler GuideCopyright 2000, 2001 ARM Limited. All rights reserved.Release InformationThe following changes have been made to this book.Change HistoryDateIssueChangeNovember 2000ARelease 1.1November 2001BRelease 1.2Proprietary NoticeWords and logos marked with or are registered trademarks or trademarks owned by ARM Limited. Otherbrands 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 documentmay be adapted or reproduced in any material form except with the prior written permission of the copyrightholder.The product described in this document is subject to continuous developments and improvements. Allparticulars 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, orfitness for purpose, are excluded.This document is intended only to assist the reader in the use of the product. ARM Limited shall not be liablefor any loss or damage arising from the use of any information in this document, or any error or omission insuch information, or any incorrect use of the product.iiCopyright 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B

ContentsARM Developer Suite Assembler GuidePrefaceAbout this book . viFeedback . ixChapter 1Introduction1.1Chapter 2Writing ARM and Thumb Assembly Language2.12.22.32.42.52.62.72.82.92.102.11Chapter 3Introduction . 2-2Overview of the ARM architecture . 2-3Structure of assembly language modules . 2-12Using the C preprocessor . 2-19Conditional execution . 2-20Loading constants into registers . 2-25Loading addresses into registers . 2-30Load and store multiple register instructions . 2-39Using macros . 2-48Describing data structures with MAP and FIELD directives . 2-51Using frame directives . 2-66Assembler Reference3.1ARM DUI 0068BAbout the ARM Developer Suite assemblers . 1-2Command syntax . 3-2Copyright 2000, 2001 ARM Limited. All rights reserved.iii

Contents3.23.33.43.53.6Chapter 4ARM Instruction Reference4.14.24.34.44.54.64.74.84.9Chapter 5Thumb memory access instructions . 5-4Thumb arithmetic instructions . 5-15Thumb general data processing instructions . 5-22Thumb branch instructions . 5-31Thumb software interrupt and breakpoint instructions . 5-37Thumb pseudo-instructions . 5-39Vector Floating-point Programming6.16.26.36.46.56.66.76.86.9Chapter 7Conditional execution . 4-4ARM memory access instructions . 4-6ARM general data processing instructions . 4-23ARM multiply instructions . 4-39ARM saturating arithmetic instructions . 4-54ARM branch instructions . 4-56ARM coprocessor instructions . 4-61Miscellaneous ARM instructions . 4-70ARM pseudo-instructions . 4-76Thumb Instruction Reference5.15.25.35.45.55.6Chapter 6Format of source lines . 3-8Predefined register and coprocessor names . 3-9Built-in variables . 3-10Symbols . 3-12Expressions, literals, and operators . 3-18The vector floating-point coprocessor . 6-4Floating-point registers . 6-5Vector and scalar operations . 6-7VFP and condition codes . 6-8VFP system registers . 6-10Flush-to-zero mode . 6-13VFP instructions . 6-15VFP pseudo-instruction . 6-36VFP directives and vector notation . 6-37Directives Reference7.17.27.37.47.57.67.7Alphabetical list of directives . 7-2Symbol definition directives . 7-3Data definition directives . 7-13Assembly control directives . 7-26Frame description directives . 7-33Reporting directives . 7-44Miscellaneous directives . 7-49GlossaryivCopyright 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B

PrefaceThis preface introduces the documentation for the ARM Developer Suite (ADS)assemblers and assembly language. It contains the following sections: About this book on page vi Feedback on page ix.ARM DUI 0068BCopyright 2000, 2001 ARM Limited. All rights reserved.v

PrefaceAbout this bookThis book provides tutorial and reference information for the ADS assemblers (armasm,the free-standing assembler, and inline assemblers in the C and C compilers). Itdescribes the command-line options to the assembler, the pseudo-instructions anddirectives available to assembly language programmers, and the ARM, Thumb , andVector Floating-point (VFP) instruction sets.Intended audienceThis book is written for all developers who are producing applications using ADS. Itassumes that you are an experienced software developer and that you are familiar withthe ARM development tools as described in ADS Getting Started.Using this bookThis book is organized into the following chapters:Chapter 1 IntroductionRead this chapter for an introduction to the ADS version 1.2 assemblersand assembly language.Chapter 2 Writing ARM and Thumb Assembly LanguageRead this chapter for tutorial information to help you use the ARMassemblers and assembly language.Chapter 3 Assembler ReferenceRead this chapter for reference material about the syntax and structure ofthe language provided by the ARM assemblers.Chapter 4 ARM Instruction ReferenceRead this chapter for reference material on the ARM instruction set.Chapter 5 Thumb Instruction ReferenceRead this chapter for reference material on the Thumb instruction set.Chapter 6 Vector Floating-point ProgrammingRead this chapter for reference material on the VFP instruction set, andother VFP-specific assembly language information.Chapter 7 Directives ReferenceRead this chapter for reference material on the assembler directivesavailable in the ARM assembler, armasm.viCopyright 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B

PrefaceTypographical conventionsThe following typographical conventions are used in this book:monospaceDenotes text that can be entered at the keyboard, such as commands, fileand program names, and source code.monospaceDenotes a permitted abbreviation for a command or option. Theunderlined text can be entered instead of the full command or optionname.monospace italicDenotes arguments to commands and functions where the argument is tobe replaced by a specific value.monospace boldDenotes language keywords when used outside example code.italicHighlights important notes, introduces special terminology, denotesinternal cross-references, and citations.boldHighlights interface elements, such as menu names. Also used foremphasis in descriptive lists, where appropriate, and for ARM processorsignal names.Further readingThis section lists publications from both ARM Limited and third parties that provideadditional information on developing code for the ARM family of processors.ARM periodically provides updates and corrections to its documentation. Seehttp://www.arm.com for current errata sheets and addenda.See also the ARM Frequently Asked Questions list at:http://www.arm.com/DevSupp/Sales Support/faq.htmlARM publicationsThis book contains reference information that is specific to development tools suppliedwith ADS. Other publications included in the suite are:ARM DUI 0068B ADS Installation and License Management Guide (ARM DUI 0139) Getting Started (ARM DUI 0064) ADS Compilers and Libraries Guide (ARM DUI 0067)Copyright 2000, 2001 ARM Limited. All rights reserved.vii

Preface ADS Linker and Utilities Guide (ARM DUI 0151) CodeWarrior IDE Guide (ARM DUI 0065) AXD and armsd Debuggers Guide (ARM DUI 0066) ADS Debug Target Guide (ARM DUI 0058) ADS Developer Guide (ARM DUI 0056) ARM Applications Library Programmer’s Guide (ARM DUI 0081).The following additional documentation is provided with the ARM Developer Suite: ARM Architecture Reference Manual (ARM DDI 0100). This is supplied inDynaText format as part of the online books, and in PDF format ininstall directory\PDF\ARM-DDI0100B armarm.pdf. ARM ELF specification (SWS ESPC 0003). This is supplied in PDF format ininstall directory\PDF\specs\ARMELF.pdf. TIS DWARF 2 specification. This is supplied in PDF format ininstall directory\PDF\specs\TIS-DWARF2.pdf. ARM/Thumb Procedure Call Specification (SWS ESPC 0002). This is supplied inPDF format in install directory\PDF\specs\ATPCS.pdf.In addition, refer to the following documentation for specific information relating toARM products: ARM Reference Peripheral Specification (ARM DDI 0062) the ARM datasheet or technical reference manual for your hardware device.Other publicationsThe following book gives general information about the ARM architecture: viiiARM System-on-chip Architecture, Furber, S., (2nd Edition, 2000). AddisonWesley Longman, Harlow, England. ISBN 0-201-67519-6.Copyright 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B

PrefaceFeedbackARM Limited welcomes feedback on both ADS and the documentation.Feedback on the ARM Developer SuiteIf you have any problems with ADS, please contact your supplier. To help them providea rapid and useful response, please give: your name and company the serial number of the product details of the release you are using details of the platform you are running on, such as the hardware platform,operating system type and version a small standalone sample of code that reproduces the problem a clear explanation of what you expected to happen, and what actually happened the commands you used, including any command-line options sample output illustrating the problem the version string of the tools, including the version number and build numbers.Feedback on this bookIf you have any problems with this book, please send email to errata@arm.com giving: the document title the document number the page number(s) to which your comments apply a concise explanation of the problem.General suggestions for additions and improvements are also welcome.ARM DUI 0068BCopyright 2000, 2001 ARM Limited. All rights reserved.ix

PrefacexCopyright 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B

Chapter 1IntroductionThis chapter introduces the assemblers provided with ARM Developer Suite (ADS)version 1.2. It contains the following sections: About the ARM Developer Suite assemblers on page 1-2.ARM DUI 0068BCopyright 2000, 2001 ARM Limited. All rights reserved.1-1

Introduction1.1About the ARM Developer Suite assemblersARM Developer Suite (ADS) has: a freestanding assembler, armasm an optimizing inline assembler built into the C and C compilers.The language that these assemblers take as input is basically the same. However, thereare limitations on what features of the language you can use in the inline assemblers.Refer to the Mixing C, C , and Assembly Language chapter in ADS Developer Guidefor further information on the inline assemblers.The remainder of this book relates mainly to armasm.1-2Copyright 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B

Chapter 2Writing ARM and Thumb Assembly LanguageThis chapter provides an introduction to the general principles of writing ARM andThumb assembly language. It contains the following sections: Introduction on page 2-2 Overview of the ARM architecture on page 2-3 Structure of assembly language modules on page 2-12 Using the C preprocessor on page 2-19 Conditional execution on page 2-20 Loading constants into registers on page 2-25 Loading addresses into registers on page 2-30 Load and store multiple register instructions on page 2-39 Using macros on page 2-48 Describing data structures with MAP and FIELD directives on page 2-51 Using frame directives on page 2-66.ARM DUI 0068BCopyright 2000, 2001 ARM Limited. All rights reserved.2-1

Writing ARM and Thumb Assembly Language2.1IntroductionThis chapter gives a basic, practical understanding of how to write ARM and Thumbassembly language modules. It also gives information on the facilities provided by theARM assembler (armasm).This chapter does not provide a detailed description of the ARM, Thumb, or VFPinstruction sets. This information can be found in Chapter 4 ARM InstructionReference, Chapter 5 Thumb Instruction Reference, and Chapter 6 VectorFloating-point Programming. Further information can be found in ARM ArchitectureReference Manual.2.1.1Code examplesThere are a number of code examples in this chapter. Many of them are supplied in theexamples\asm directory of the ADS.Follow these steps to build, link, and execute an assembly language file:1.Type armasm -g filename.s at the command prompt to assemble the file andgenerate debug tables.2.Type armlink filename.o -o filename to link the object file and generate an ELFexecutable image.3.Type armsd filename to load the image file into the debugger.4.Type go at the armsd: prompt to execute it.5.Type quit at the armsd: prompt to return to the command line.To see how the assembler converts the source code, enter:fromelf -text/c filename.oor run the module in AXD with interleaving on.See:2-2 AXD and armsd Debuggers Guide for details on armsd, and AXD. ADS Linker and Utilities Guide for details on armlink and fromelf.Copyright 2000, 2001 ARM Limited. All rights reserved.ARM DUI 0068B

Writing ARM and Thumb Assembly Language2.2Overview of the ARM architectureThis section gives a brief overview of the ARM architecture.ARM processors are typical of RISC processors in that they implement a load/storearchitecture. Only load and store instructions can access memory. Data processinginstructions operate on register contents only.2.2.1Architecture versionsThe information and examples in this book assume that you are using a processor thatimplements ARM architecture v3 or above. See ARM Architecture Reference Manualfor details of the various architecture versions.All these processors have a 32-bit addressing range.2.2.2ARM and Thumb stateARM architecture versions v4T and above define a 16-bit instruction set called theThumb instruction set. The functionality of the Thumb instruction set is a subset of thefunctionality of the 32-bit ARM instruction set. Refer to Thumb instruction set overviewon page 2-9 for more information.A processor that is executing Thumb instructions is operating in Thumb state. Aprocessor that is executing ARM instructions is operating in ARM state.A processor in ARM state cannot execute Thumb instructions, and a processor inThumb state cannot execute ARM instructions. You must ensure that the processornever receives instructions of the wrong instruction set for the current state.Each instruction set includes instructions to change processor state.You must also switch the assembler mode to produce the correct opcodes using CODE16and CODE32 directives. Refer to CODE16 and CODE32 on page 7-54 for details.ARM processors always start executing code in ARM state.ARM DUI 0068BCopyright 2000, 2001 ARM Limited. All rights reserved.2-3

Writing ARM and Thumb Assembly Language2.2.3Processor modeARM processors support up to seven processor modes, depending on the architectureversion. These are: User FIQ - Fast Interrupt Request IRQ - Interrupt Request Supervisor Abort Undefined System (ARM architecture v4 and above).All modes except User mode are referred to as privileged modes.Applications that require task protection usually execute in User mode. Someembedded applications might run entirely in Supervisor or System modes.Modes other than User mode are entered to service exceptions, or to access privilegedresources. Refer to the Handling Processor Exceptions chapter in ADS DeveloperGuide, and ARM Architecture Reference Manual for more information.2.2.4RegistersARM processors have 37 registers. The registers are arranged in partially overlappingbanks. There is a different register bank for each processor mode. The banked registersgive rapid context switching for dealing with processor exceptions and privilegedoperations. Refer to ARM Architecture Reference Manual for a detailed description ofhow registers are banked.The following registers are available in ARM architecture v3 and above: 30 general-purpose, 32-bit registers The program counter (pc) on page 2-5 The Current Program Status Register (CPSR) on page 2-5 Five Saved Program Status Registers (SPSRs) on page 2-5.30 general-purpose, 32-bit registersFifteen general-purpose registers are visible at any one time, depending on the currentprocessor mode, as r0, r1, . ,r13, r14.By convention, r13 is used as a stack pointer (sp) in ARM assembly language. The Cand C compilers always use r13 as the stack pointer.2-4Copyright 2000, 2001 ARM Limited. All right

Read this chapter for an introduction to the ADS version 1.2 assemblers and assembly language. Chapter 2 Writing ARM and Thumb Assembly Language Read this chapter for tutorial information to help you use the ARM assemblers and assembly language. Chapter 3 Assembler Reference Read this chapter for reference materi al about the syntax and .

Related Documents:

Chapter 1: Getting started with Intel x86 Assembly Language & Microarchitecture 2 Remarks 2 Examples 2 x86 Assembly Language 2 x86 Linux Hello World Example 3 Chapter 2: Assemblers 6 Examples 6 Microsoft Assembler - MASM 6 Intel Assembler 6 AT&T assembler - as 7 Borland's Turbo Assembler - TASM 7 GNU assembler - gas 7 Netwide Assembler - NASM 8

The ASM86 Macro Assembler is a multi-overlay assembler. The overlays are all contained in one file: ASM86.86. The assembler can reside on and be invoked from any disk. During assembly, the ASM86 Macro Assembler creates six temporary files for its own use. These files are given temporary names by the operating system and are

Chapter 2 Assemblers--Basic Assembler Functions. Outline Basic assembler functions A simple SIC assembler Assembler algorithm and data structure. Basic assembler functions Translating mnemonic operation codes to their machine language equivalents Assigning machine addresses to symbolic

x Furniture Assembler x Metal Furniture Assembler x Table Assembler x Wood Furniture Assembler Main Duties Assemblers perform some or all of the following duties: x Prepare, sand and trim wooden furniture and fixture parts using hand, power tools and stationary machines x Assemble wooden or metal

Operation, as well as an in-depth knowledge of assembler language programming. System macros require High Level Assembler. Assembler language programming is described in the following books: v HLASM Programmer’s Guide v HLASM Language Reference Using this book also requires you to be familiar with the operating system and the

Chapter 2 Assemblers PDF created with FinePrint pdfFactory Pro trial version www.pdffactory.com. 2 Outline o 2.1 Basic Assembler Functions o 2.2 Machine-Dependent Assembler Features o 2.3 Machine-Independent Assembler Features o 2.4 Assembler Design Options o 2.5 Implementation Examples

Chapter 2 Assemblers --2.4 Assembler Design Options. Outline One-pass assemblers Multi-pass assemblers Two-pass assembler with overlay structure. Load-and-Go Assembler Load-and-go assembler generates their object code in memory for immediate execution. No object program is written out, no loader is needed.

tle introduction into state-of-the-art description logics. Before going into technicalities the remainder of this section will brie y discuss how DLs are positioned in the landscape of knowledge representation formalisms, provide some examples for modeling features of DLs, and sketch the most prominent application context: the Semantic Web. Section 2 starts the formal treatment by introducing .