ARM® Compiler Software Development Guide

Version 5.04

Table of Contents

About this book
Using this book
Typographic conventions
Feedback on this product
Feedback on content
1 Key Features of ARM Architecture Versions
1.1 About the ARM architectures
1.2 Multiprocessing systems
1.3 Considerations when designing software for a multiprocessing system
1.4 Tightly coupled memory
1.5 Memory management
1.6 Thumb-2 technology
1.7 ARM and Thumb floating-point build options (ARMv6 and earlier)
1.8 ARM and Thumb floating-point build options (ARMv7 and later)
1.9 ARM architecture profiles
1.10 ARM architecture v4T
1.11 ARM architecture v5TE
1.12 ARM architecture v6
1.13 ARM architecture v6-M
1.14 ARM architecture v7-A
1.15 ARM architecture v7-R
1.16 ARM architecture v7-M
2 Embedded Software Development
2.1 About embedded software development
2.2 Default compilation tool behavior
2.3 C library structure
2.4 Default memory map
2.5 Application startup
2.6 Tailoring the C library to your target hardware
2.7 Tailoring the image memory map to your target hardware
2.8 About the scatter-loading description syntax
2.9 Root regions
2.10 Placing the stack and heap
2.11 Run-time memory models
2.12 Scatter file with link to bit-band objects
2.13 Reset and initialization
2.14 The vector table
2.15 ROM and RAM remapping
2.16 Local memory setup considerations
2.17 Stack pointer initialization
2.18 Hardware initialization
2.19 Execution mode considerations
2.20 Target hardware and the memory map
2.21 Execute-only memory
2.22 Building applications for execute-only memory
3 Mixing C, C++, and Assembly Language
3.1 Instruction intrinsics, inline and embedded assembler
3.2 Access to C global variables from assembly code
3.3 Including system C header files from C++
3.4 Including your own C header files from C++
3.5 Mixed-language programming
3.6 Rules for calling between C, C++, and assembly language
3.7 Rules for calling C++ functions from C and assembly language
3.8 Information specific to C++
3.9 Calls to assembly language from C
3.10 Calls to C from assembly language
3.11 Calls to C from C++
3.12 Calls to assembly language from C++
3.13 Calls to C++ from C
3.14 Calls to C++ from assembly language
3.15 Passing a reference between C and C++
3.16 Calls to C++ from C or assembly language
4 Interworking ARM and Thumb
4.1 About interworking
4.2 When to use interworking
4.3 Assembly language interworking
4.4 C and C++ interworking
4.5 Pointers to functions in Thumb state
4.6 Using two versions of the same function
4.7 Assembly language interworking example
4.8 Interworking using veneers
4.9 C and C++ language interworking
4.10 C, C++, and assembly language interworking using veneers
5 Handling Processor Exceptions
5.1 About processor exceptions
5.2 Exception handling process
5.3 Types of exception in ARMv6 and earlier, ARMv7-A and ARMv7-R profiles
5.4 Vector table for ARMv6 and earlier, ARMv7-A and ARMv7-R profiles
5.5 Processor modes and registers in ARMv6 and earlier, ARMv7-A and ARMv7-R profiles
5.6 Use of System mode for exception handling
5.7 The processor response to an exception
5.8 Return from an exception handler
5.9 Reset handlers
5.10 Data Abort handler
5.11 Interrupt handlers and levels of external interrupt
5.12 Reentrant interrupt handlers
5.13 Single-channel DMA transfer
5.14 Dual-channel DMA transfer
5.15 Interrupt prioritization
5.16 Context switch
5.17 Determining the SVC to be called
5.18 Determining the instruction set state from an SVC handler
5.19 SVC handlers in assembly language
5.20 SVC handlers in C and assembly language
5.21 Using SVCs in Supervisor mode
5.22 Calling SVCs from an application
5.23 Calling SVCs dynamically from an application
5.24 Prefetch Abort handler
5.25 Undefined instruction handlers
5.26 ARMv6-M and ARMv7-M profiles
5.27 Main and Process stacks
5.28 Types of exceptions in the microcontroller profiles
5.29 Vector table for ARMv6-M and ARMv7-M profiles
5.30 Vector Table Offset Register (ARMv7-M only)
5.31 Writing the exception table for ARMv6-M and ARMv7-M profiles
5.32 The Nested Vectored Interrupt Controller
5.33 Handling an exception
5.34 Configuring the System Control Space registers
5.35 Configuring individual IRQs
5.36 Supervisor calls
5.37 System timer
5.38 Configuring SysTick
6 Debug Communications Channel
6.1 About the Debug Communications Channel
6.2 DCC communication between target and host debug tools
6.3 Interrupt-driven debug communications
6.4 Access from Thumb state
7 What is Semihosting?
7.1 What is semihosting?
7.2 The semihosting interface
7.3 Can I change the semihosting operation numbers?
7.4 Debug agent interaction SVCs
7.5 angel_SWIreason_EnterSVC (0x17)
7.6 angel_SWIreason_ReportException (0x18)
7.7 SYS_CLOSE (0x02)
7.8 SYS_CLOCK (0x10)
7.9 SYS_ELAPSED (0x30)
7.10 SYS_ERRNO (0x13)
7.11 SYS_FLEN (0x0C)
7.12 SYS_GET_CMDLINE (0x15)
7.13 SYS_HEAPINFO (0x16)
7.14 SYS_ISERROR (0x08)
7.15 SYS_ISTTY (0x09)
7.16 SYS_OPEN (0x01)
7.17 SYS_READ (0x06)
7.18 SYS_READC (0x07)
7.19 SYS_REMOVE (0x0E)
7.20 SYS_RENAME (0x0F)
7.21 SYS_SEEK (0x0A)
7.22 SYS_SYSTEM (0x12)
7.23 SYS_TICKFREQ (0x31)
7.24 SYS_TIME (0x11)
7.25 SYS_TMPNAM (0x0D)
7.26 SYS_WRITE (0x05)
7.27 SYS_WRITEC (0x03)
7.28 SYS_WRITE0 (0x04)
A Software Development Guide Document Revisions
A.1 Revisions for Software Development Guide

List of Figures

2-1 C library structure
2-2 Default memory map
2-3 Linker placement rules
2-4 Default initialization sequence
2-5 Retargeting the C library
2-6 Scatter-loading description syntax
2-7 One-region model
2-8 Two-region model
2-9 Initialization sequence
5-1 Handling an exception
5-2 PCB layout
5-3 ARM SVC instruction
5-4 Thumb SVC instruction
5-5 Accessing the Supervisor mode stack
6-1 DCC communication between target and host debug tools
7-1 Semihosting overview

List of Tables

1-1 Key features
1-2 Useful command-line options for ARMv4T
1-3 Useful command-line options for ARMv5TE
1-4 Useful command-line options for ARMv6
1-5 One-byte alignment
1-6 Useful command-line options for ARMv6-M
1-7 Useful command-line options for ARMv7-A
1-8 Useful command-line options for ARMv7-R
1-9 Useful command-line options for ARMv7-M
1-10 Interrupt intrinsics
2-1 ARMv7-M bit-band regions and aliases
3-1 Differences between instruction intrinsics, inline and embedded assembler
5-1 Exception types in priority order for ARMv6 and earlier, ARMv7-A and ARMv7-R profiles
5-2 Exception types in priority order for the microcontroller profiles
5-3 Registers available for configuring SysTick
7-1 Hardware vector reason codes
7-2 Software reason codes
7-3 Value of mode
A-1 Differences between issue I and issue J
A-2 Differences between issue H and issue I
A-3 Differences between issue G and issue H
A-4 Differences between issue F and issue G
A-5 Differences between issue D and issue F
A-6 Differences between issue C and issue D
A-7 Differences between issue B and issue C
A-8 Differences between issue A and issue B

Release Information

Document History
Issue Date Confidentiality Change
A 28 May 2010 Non-Confidential ARM Compiler v4.1 Release
B 30 September 2010 Non-Confidential Update 1 for ARM Compiler v4.1
C 28 January 2011 Non-Confidential Update 2 for ARM Compiler v4.1 Patch 3
D 30 April 2011 Non-Confidential ARM Compiler v5.0 Release
E 29 July 2011 Non-Confidential Update 1 for ARM Compiler v5.0
F 30 September 2011 Non-Confidential ARM Compiler v5.01 Release
G 29 February 2012 Non-Confidential Document update 1 for ARM Compiler v5.01 Release
H 27 July 2012 Non-Confidential ARM Compiler v5.02 Release
I 31 January 2013 Non-Confidential ARM Compiler v5.03 Release
J 27 November 2013 Non-Confidential ARM Compiler v5.04 Release

Proprietary Notice

Words and logos marked with ® or ™ are registered trademarks or trademarks of ARM® in the EU and other countries, except as otherwise stated below in this proprietary notice. 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 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.

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 DUI0471J
Copyright © 2010-2013 ARM. All rights reserved.