2nd Edition

ARM Assembly Language Fundamentals and Techniques, Second Edition

By William Hohl, Christopher Hinds Copyright 2015
    453 Pages 150 B/W Illustrations
    by CRC Press

    Delivering a solid introduction to assembly language and embedded systems, ARM Assembly Language: Fundamentals and Techniques, Second Edition continues to support the popular ARM7TDMI, but also addresses the latest architectures from ARM, including Cortex™-A, Cortex-R, and Cortex-M processors—all of which have slightly different instruction sets, programmer’s models, and exception handling.

    Featuring three brand-new chapters, a new appendix, and expanded coverage of the ARM7™, this edition:

    • Discusses IEEE 754 floating-point arithmetic and explains how to program with the IEEE standard notation
    • Contains step-by-step directions for the use of Keil™ MDK-ARM and Texas Instruments (TI) Code Composer Studio™
    • Provides a resource to be used alongside a variety of hardware evaluation modules, such as TI’s Tiva Launchpad, STMicroelectronics’ iNemo and Discovery, and NXP Semiconductors’ Xplorer boards

    Written by experienced ARM processor designers, ARM Assembly Language: Fundamentals and Techniques, Second Edition covers the topics essential to writing meaningful assembly programs, making it an ideal textbook and professional reference.



    An Overview of Computing Systems


    History of RISC

    ARM Begins

    The Creation of ARM Ltd

    ARM Today

    The Cortex Family

    The Computing Device

    Number Systems

    Representations of Numbers and Characters

    Integer Representations

    Floating-Point Representations

    Character Representations

    Translating Bits to Commands

    The Tools

    Open Source Tools

    Keil (ARM)

    Code Composer Studio

    Useful Documentation


    The Programmer’s Model


    Data Types


    Processor Modes


    The Vector Table


    Processor Modes


    The Vector Table


    Introduction to Instruction Sets: v4T and v7-M


    ARM, Thumb, and Thumb-2 Instructions

    Program 1: Shifting Data

    Running the Code

    Examining Register and Memory Contents

    Program 2: Factorial Calculation

    Program 3: Swapping Register Contents

    Program 4: Playing with Floating-Point Numbers

    Program 5: Moving Values between Integer and Floating-Point Registers

    Programming Guidelines


    Assembler Rules and Directives


    Structure of Assembly Language Modules

    Predefined Register Names

    Frequently Used Directives

    Defining a Block of Data or Code

    Register Name Definition

    Equating a Symbol to a Numeric Constant

    Declaring an Entry Point

    Allocating Memory and Specifying Contents

    Aligning Data or Code to Appropriate Boundaries

    Reserving a Block of Memory

    Assigning Literal Pool Origins

    Ending a Source File


    Miscellaneous Assembler Features

    Assembler Operators

    Math Functions in CCS


    Loads, Stores, and Addressing



    Loads and Stores: The Instructions

    Operand Addressing

    Pre-Indexed Addressing

    Post-Indexed Addressing


    Changing Endianness

    Defining Memory Areas

    Bit-Banded Memory

    Memory Considerations


    Constants and Literal Pools


    The ARM Rotation Scheme

    Loading Constants into Registers

    Loading Constants with MOVW, MOVT

    Loading Addresses into Registers


    Integer Logic and Arithmetic


    Flags and Their Use

    The N Flag

    The V Flag

    The Z Flag

    The C Flag

    Comparison Instructions

    Data Processing Operations

    Boolean Operations

    Shifts and Rotates


    Saturated Math Operations


    Multiplication by a Constant


    DSP Extensions

    Bit Manipulation Instructions

    Fractional Notation


    Branches and Loops



    Branching (ARM7TDMI)

    Version 7-M Branches


    While Loops

    For Loops

    Do-While Loops

    Conditional Execution

    v4T Conditional Execution

    v7-M Conditional Execution: The IT Block

    Straight-Line Coding


    Introduction to Floating-Point: Basics, Data Types, and Data Transfer


    A Brief History of Floating-Point in Computing

    The Contribution of Floating-Point to the Embedded Processor

    Floating-Point Data Types

    The Space of Floating-Point Representable Values

    Floating-Point Representable Values

    Normal Values

    Subnormal Values



    Not-a-Numbers (NaNs)

    The Floating-Point Register File of the Cortex-M4

    FPU Control Registers

    The Floating-Point Status and Control Register, FPSCR

    The Coprocessor Access Control Register, CPACR

    Loading Data into Floating-Point Registers

    Floating-Point Loads and Stores: The Instructions

    The VMOV instruction

    Conversions between Half-Precision and Single-Precision

    Conversions to Non-Floating-Point Formats

    Conversions between Integer and Floating-Point

    Conversions between Fixed-Point and Floating-Point


    Introduction to Floating-Point: Rounding and Exceptions



    Introduction to Rounding Modes in the IEEE 754-2008 Specification

    The roundTiesToEven (RNE) Rounding Mode

    The Directed Rounding Modes

    Rounding Mode Summary


    Introduction to Floating-Point Exceptions

    Exception Handling

    Division by Zero

    Invalid Operation



    Inexact Result

    Algebraic Laws and Floating-Point

    Normalization and Cancelation


    Floating-Point Data-Processing Instructions


    Floating-Point Data-Processing Instruction Syntax

    Instruction Summary

    Flags and Their Use

    Comparison Instructions

    The N Flag

    The Z Flag

    The C Flag

    The V Flag

    Predicated Instructions, or the Use of the Flags

    A Word about the IT Instruction

    Two Special Modes

    Flush-to-Zero Mode

    Default NaN

    Non-Arithmetic Instructions

    Absolute Value


    Arithmetic Instructions


    Multiplication and Multiply–Accumulate

    Division and Square Root

    Putting It All Together: A Coding Example




    Integer Lookup Tables

    Floating-Point Lookup Tables

    Binary Searches


    Subroutines and Stacks


    The Stack

    LDM/STM Instructions

    PUSH and POP

    Full/Empty Ascending/Descending Stacks


    Passing Parameters to Subroutines

    Passing Parameters in Registers

    Passing Parameters by Reference

    Passing Parameters on the Stack

    The ARM APCS


    Exception Handling: ARM7TDMI



    Error Conditions

    Processor Exception Sequence

    The Vector Table

    Exception Handlers

    Exception Priorities

    Procedures for Handling Exceptions

    Reset Exceptions

    Undefined Instructions





    Exception Handling: v7-M


    Operation Modes and Privilege Levels

    The Vector Table

    Stack Pointers

    Processor Exception Sequence



    Exception Types



    Memory-Mapped Peripherals


    The LPC2104

    The UART

    The Memory Map

    Configuring the UART

    Writing the Data to the UART

    Putting the Code Together

    Running the Code

    The LPC2132

    The D/A Converter

    The Memory Map

    Configuring the D/A Converter

    Generating a Sine Wave

    Putting the Code Together

    Running the Code

    The Tiva Launchpad

    General-Purpose I/O

    The Memory Map

    Configuring the GPIO Pins

    Turning on the LEDs

    Putting the Code Together

    Running the Code


    ARM, Thumb and Thumb-2 Instructions


    ARM and 16-Bit Thumb Instructions

    Differences between ARM and 16-Bit Thumb

    Thumb Implementation

    32-Bit Thumb Instructions

    Switching between ARM and Thumb States

    How to Compile for Thumb


    Mixing C and Assembly


    Inline Assembler

    Inline Assembly Syntax

    Restrictions on Inline Assembly Operations

    Embedded Assembler

    Embedded Assembly Syntax

    Restrictions on Embedded Assembly Operations

    Calling between C and Assembly


    Appendix A: Running Code Composer Studio

    Appendix B: Running Keil Tools

    Appendix C: ASCII Character Codes

    Appendix D





    William Hohl held the position of worldwide university relations manager for ARM, based in Austin, Texas, for 10 years. In total, he was with ARM for nearly 15 years and began as a principal design engineer to help build the ARM1020 microprocessor. His travel and university lectures have taken him to over 40 countries on 5 continents, and he continues to lecture on low-power microcontrollers and assembly language programming. In addition to his engineering duties, he also held an adjunct faculty position in Austin from 1998 to 2004, teaching undergraduate mathematics. Before joining ARM, he worked at Motorola (now Freescale Semiconductor) in the ColdFire and 68040 design groups and at Texas Instruments as an applications engineer. He holds MSEE and BSEE degrees from Texas A&M University as well as six patents in the field of debug architectures.

    Christopher Hinds has worked in the microprocessor design field for over 25 years, holding design positions at Motorola (now Freescale Semiconductor), AMD, and ARM. While at ARM, he was the primary author of the ARM VFP floating-point architecture and led the design of the ARM10 VFP, the first hardware implementation of the new architecture. He recently joined the Patents Group in ARM, identifying patentable inventions within the company and assisting in patent litigation. He holds BSEE and MSEE degrees from Texas A&M University and an M.Div from Oral Roberts University, where he worked to establish the School of Engineering, creating and teaching the first digital logic and microprocessor courses. He has numerous published papers and presentations on the floating-point architecture of ARM processors, and is a named inventor on over 30 US patents in the areas of floating-point implementation, instruction set design, and circuit design.

    "Relaxed and informal, almost conversational, this writing style makes for comfortable reading that should appeal to everyone while breaking the tension of diving into the complexities of a modern multi-purpose microcontroller."
    —Andrew Mason, Michigan State University, East Lansing, USA

    "The authors are obviously authorities on the subject, and this shows clearly. The text is clearly written and easy to follow, with examples and analogies used to make understanding easier. Using Keil and the Tiva Launchpad should make it pretty easy to get the examples up and running on an actual Cortex-M as well as using a simulator."
    —Craig A. Evans, University of Leeds, UK

    "This book fills a void in the computer science literature."
    —Don Evans, Southern Methodist University, Dallas, Texas, USA

    "This text retains the ease of using the ARM7TDMI while moving the student [or reader] into the more capable Cortex-M4. …The addition of the Cortex-M4 makes this a much stronger text."
    —Ralph Tanner, Western Michigan University, Kalamazoo, USA

    "Assembly language programming is still the best way to learn about the internals of processors and this is one of a very few books that teaches that skill for ARM processors. It covers the necessary material in a well-organized manner. Updated for newer versions of ARM processors, it adds good material on floating-point arithmetic that was missing from the first edition."
    —Ronald W. Mehler, California State University, Northridge, USA

    "In general, this book contains most of the content that I generally cover in my introduction to computer organization course. It contains very nice exercises at the end of each chapter, and that is a plus when generating questions to help students grasp the concepts. …I look forward to a second edition, because I plan to continue using this book."
    —Rose M. Lowe, Clemson University, South Carolina, USA