Table Of Contentffffiirrss..iinndddd ii 0033--1122--22001133 1122::1144::1122
PROFESSIONAL
EMBEDDED ARM DEVELOPMENT
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxi
➤ PART I ARM SYSTEMS AND DEVELOPMENT
CHAPTER 1 The History of ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
CHAPTER 2 ARM Embedded Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
CHAPTER 3 ARM Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
CHAPTER 4 ARM Assembly Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
CHAPTER 5 First Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
CHAPTER 6 Thumb Instruction Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
CHAPTER 7 Assembly Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
CHAPTER 8 NEON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
CHAPTER 9 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
CHAPTER 10 Writing Optimized C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
➤ PART II REFERENCE
APPENDIX A Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
APPENDIX B ARM Architecture Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
APPENDIX C ARM Core Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
APPENDIX D NEON Intrinsics and Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
APPENDIX E Assembly Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
ffffiirrss..iinndddd ii 0033--1122--22001133 1122::1144::1122
ffffiirrss..iinndddd iiii 0033--1122--22001133 1122::1144::1122
PROFESSIONAL
Embedded ARM Development
ffffiirrss..iinndddd iiiiii 0033--1122--22001133 1122::1144::1122
ffffiirrss..iinndddd iivv 0033--1122--22001133 1122::1144::1122
PROFESSIONAL
Embedded ARM Development
James A. Langbridge
ffffiirrss..iinndddd vv 0033--1122--22001133 1122::1144::1133
Professional Embedded ARM Development
Published by
John Wiley & Sons, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2014 by John Wiley & Sons, Inc., Indianapolis, Indiana
ISBN: 978-1-118-78894-3
ISBN: 978-1-118-78901-8 (ebk)
ISBN: 978-1-118-88782-0 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108
of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization
through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers,
MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the
Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011,
fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect
to the accuracy or completeness of the contents of this work and specifi cally disclaim all warranties, including without
limitation warranties of fi tness for a particular purpose. No warranty may be created or extended by sales or promotional
materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the
understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional
assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author
shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation
and/or a potential source of further information does not mean that the author or the publisher endorses the information the
organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web
sites listed in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with
standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to
media such as a CD or DVD that is not included in the version you purchased, you may download this material
at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.
Trademarks: Wiley, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or
registered trademarks of John Wiley & Sons, Inc. and/or its affi liates, in the United States and other countries, and may
not be used without written permission. All other trademarks are the property of their respective owners. John Wiley &
Sons, Inc., is not associated with any product or vendor mentioned in this book.
ACQUISITIONS EDITOR EDITORIAL MANAGER BUSINESS MANAGER PROOFREADER
Mary James Mary Beth Wakefi eld Amy Knies Nancy Carrasco
PROJECT EDITOR FREELANCER EDITORIAL VICE PRESIDENT AND TECHNICAL PROOFREADER
Christina Haviland MANAGER EXECUTIVE GROUP Stephan Cadene
Rosemarie Graham PUBLISHER
TECHNICAL EDITORS INDEXER
Richard Swadley
Jean-Michel Hautbois ASSOCIATE DIRECTOR Robert Swanson
Chris Shore OF MARKETING ASSOCIATE PUBLISHER
COVER DESIGNER
David Mayhew Jim Minatel
PRODUCTION EDITOR Ryan Sneed
Christine Mugnolo MARKETING MANAGER PROJECT
COVER IMAGE
Ashley Zurcher COORDINATOR, COVER
COPY EDITOR Background: PhotoAlto
Patrick Redmond
San Dee Phillips Images/Fotosearch
ffffiirrss..iinndddd vvii 0033--1122--22001133 1122::1144::1144
For my loving girlfriend, Anne-Laure, who put up
with entire weekends spent on my PC (while she spent
her weekend on her laptop, sending me encouraging
electronic messages). Thank you for supporting me
when I should have been paying attention to you.
For my wonderful daughter, Eléna. Thank you for
letting daddy work when I really should have spent
more time playing with you, and despite what I might
have said at the time, thank you for unplugging my
computer when I ignored you for too long. Your smiles
and fi rst words are what powered me through the late
nights and tight deadlines.
ffffiirrss..iinndddd vviiii 0033--1122--22001133 1122::1144::1144
ABOUT THE AUTHOR
JAMES A. LANGBRIDGE does not like talking about himself in the third person, but he will try
anyway. James was born in Singapore, and followed his parents to several countries before settling
down in Nantes, France, where he lives with his partner and their daughter.
James is an embedded systems consultant and has worked for more than 15 years on industrial,
military, mobile telephony, and aviation security systems. He works primarily on low-level
development, creating bootloaders or optimizing routines in assembly, making the most of small
processors. When not on contract, James trains engineers on embedded systems, or he makes new
gizmos, much to the dismay of his partner.
James wrote his fi rst computer program at age six and has never stopped tinkering since. He began
using Apple IIs, ZX80s and ZX81s, before moving on to BBC Micros and the Amiga, before fi nally
having no other option but to use PCs.
ABOUT THE TECHNICAL EDITORS
CHRIS SHORE is the Training and Education Manager at ARM Ltd, based in Cambridge, UK. He
has been responsible for training ARM’s global customer base for over 13 years, delivering nearly
200 training courses per year on everything from chip design to software optimization. Chris has
taught classes on every continent except Antarctica — opportunities there are limited, but surely it’s
only a matter of time! He is a regular speaker at industry conferences.
Following graduation with his degree in Computer Science from Cambridge University, Chris worked
as a software consultant for over 15 years, primarily in embedded real-time systems, before moving
to ARM in 1999. He is a Chartered Engineer and Member of the Institute of Engineering and
Technology, and he sits on the Industry Advisory Board of Queen Mary College, London. In his free
time he keeps bees, tries to play the guitar, and is always looking for ways to visit new countries.
JEAN-MICHEL HAUTBOIS lives in France and has been developing software professionally, or as
a hobbyist, for more than 15 years. He is currently employed as an embedded Linux consultant
with Vodalys, and is the architect of his company’s main video product which was developed on
an ARM-based SoC. He is involved in the decision-making process when a new hardware product
needs to be created and performance is critical. In his free time Jean-Michel likes to travel, and he
enjoys spending time with his wife and newborn son.
ffffiirrss..iinndddd vviiiiii 0033--1122--22001133 1122::1144::1144
Description:A practical Wrox guide to ARM programming for mobile devicesWith more than 90 percent of mobile phones sold in recent years using ARM-based processors, developers are eager to master this embedded technology. If you know the basics of C programming, this guide will ease you into the world of embedde