ARM Assembly Language, 2nd Edition

Book description

This edition continues to support the popular ARM7TDMI, but also addresses the latest architectures from ARM, including the Cortex-A, Cortex-R, and Cortex-M processors. Containing three brand new chapters, a new appendix, and expanded coverage of the ARM7 this volume tackles IEEE 754 floating-point arithmetic, discusses both Keil MDK-ARM and Texas Instruments Code Composer Studio and 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.

Table of contents

  1. Preface
  2. Acknowledgments
  3. Authors
  4. Chapter 1 - An Overview of Computing Systems
    1. 1.1 Introduction
    2. 1.2 History of RISC
      1. 1.2.1 ARM Begins
      2. 1.2.2 The Creation of ARM Ltd.
      3. 1.2.3 ARM Today
      4. 1.2.4 The Cortex Family
        1. 1.2.4.1 The Cortex-A and Cortex-R Families
        2. 1.2.4.2 The Cortex-M Family
    3. 1.3 The Computing Device
    4. 1.4 Number Systems
    5. 1.5 Representations of Numbers and Characters
      1. 1.5.1 Integer Representations
      2. 1.5.2 Floating-Point Representations
      3. 1.5.3 Character Representations
    6. 1.6 Translating Bits to Commands
    7. 1.7 The Tools
      1. 1.7.1 Open Source Tools
      2. 1.7.2 Keil (ARM)
      3. 1.7.3 Code Composer Studio
      4. 1.7.4 Useful Documentation
    8. 1.8 Exercises
  5. Chapter 2 - The Programmer’s Model
    1. 2.1 Introduction
    2. 2.2 Data Types
    3. 2.3 ARM7TDMI
      1. 2.3.1 Processor Modes
      2. 2.3.2 Registers
      3. 2.3.3 The Vector Table
    4. 2.4 Cortex-M4
      1. 2.4.1 Processor Modes
      2. 2.4.2 Registers
      3. 2.4.3 The Vector Table
    5. 2.5 Exercises
  6. Chapter 3 - Introduction to Instruction Sets: v4T and v7-M
    1. 3.1 Introduction
    2. 3.2 ARM, Thumb, and Thumb-2 Instructions
    3. 3.3 Program 1: Shifting Data
      1. 3.3.1 Running the Code
      2. 3.3.2 Examining Register and Memory Contents
    4. 3.4 Program 2: Factorial Calculation
    5. 3.5 Program 3: Swapping Register Contents
    6. 3.6 Program 4: Playing with Floating-Point Numbers
    7. 3.7 Program 5: Moving Values between Integer and Floating-Point Registers
    8. 3.8 Programming Guidelines
    9. 3.9 Exercises
  7. Chapter 4 - Assembler Rules and Directives
    1. 4.1 Introduction
    2. 4.2 Structure of Assembly Language Modules
    3. 4.3 Predefined Register Names
    4. 4.4 Frequently Used Directives
      1. 4.4.1 Defining a Block of Data or Code
        1. 4.4.1.1 Keil Tools
        2. 4.4.1.2 Code Composer Studio Tools
      2. 4.4.2 Register Name Definition
        1. 4.4.2.1 Keil Tools
        2. 4.4.2.2 Code Composer Studio
      3. 4.4.3 Equating a Symbol to a Numeric Constant
        1. 4.4.3.1 Keil Tools
        2. 4.4.3.2 Code Composer Studio
      4. 4.4.4 Declaring an Entry Point
      5. 4.4.5 Allocating Memory and Specifying Contents
        1. 4.4.5.1 Keil Tools
        2. 4.4.5.2 Code Composer Studio
      6. 4.4.6 Aligning Data or Code to Appropriate Boundaries
        1. 4.4.6.1 Keil Tools
        2. 4.4.6.2 Code Composer Studio
      7. 4.4.7 Reserving a Block of Memory
        1. 4.4.7.1 Keil Tools
        2. 4.4.7.2 Code Composer Studio
      8. 4.4.8 Assigning Literal Pool Origins
      9. 4.4.9 Ending a Source File
    5. 4.5 Macros
    6. 4.6 Miscellaneous Assembler Features
      1. 4.6.1 Assembler Operators
      2. 4.6.2 Math Functions in CCS
    7. 4.7 Exercises
  8. Chapter 5 - Loads, Stores, and Addressing
    1. 5.1 Introduction
    2. 5.2 Memory
    3. 5.3 Loads and Stores: The Instructions
    4. 5.4 Operand Addressing
      1. 5.4.1 Pre-Indexed Addressing
      2. 5.4.2 Post-Indexed Addressing
    5. 5.5 Endianness
      1. 5.5.1 Changing Endianness
      2. 5.5.2 Defining Memory Areas
    6. 5.6 Bit-Banded Memory
    7. 5.7 Memory Considerations
    8. 5.8 Exercises
  9. Chapter 6 - Constants and Literal Pools
    1. 6.1 Introduction
    2. 6.2 The ARM Rotation Scheme
    3. 6.3 Loading Constants into Registers
    4. 6.4 Loading Constants with MOVW, MOVT
    5. 6.5 Loading Addresses into Registers
    6. 6.6 Exercises
  10. Chapter 7 - Integer Logic and Arithmetic
    1. 7.1 Introduction
    2. 7.2 Flags and Their Use
      1. 7.2.1 The N Flag
      2. 7.2.2 The V Flag
      3. 7.2.3 The Z Flag
      4. 7.2.4 The C Flag
    3. 7.3 Comparison Instructions
    4. 7.4 Data Processing Operations
      1. 7.4.1 Boolean Operations
      2. 7.4.2 Shifts and Rotates
      3. 7.4.3 Addition/Subtraction
      4. 7.4.4 Saturated Math Operations
      5. 7.4.5 Multiplication
      6. 7.4.6 Multiplication by a Constant
      7. 7.4.7 Division
    5. 7.5 DSP Extensions
    6. 7.6 Bit Manipulation Instructions
    7. 7.7 Fractional Notation
    8. 7.8 Exercises
  11. Chapter 8 - Branches and Loops
    1. 8.1 Introduction
    2. 8.2 Branching
      1. 8.2.1 Branching (ARM7TDMI)
      2. 8.2.2 Version 7-M Branches
    3. 8.3 Looping
      1. 8.3.1 While Loops
      2. 8.3.2 For Loops
      3. 8.3.3 Do-While Loops
    4. 8.4 Conditional Execution
      1. 8.4.1 v4T Conditional Execution
      2. 8.4.2 v7-M Conditional Execution: The IT Block
    5. 8.5 Straight-Line Coding
    6. 8.6 Exercises
  12. Chapter 9 - Introduction to Floating-Point: Basics, Data Types, and Data Transfer
    1. 9.1 Introduction
    2. 9.2 A Brief History of Floating-Point in Computing
    3. 9.3 The Contribution of Floating-Point to the Embedded Processor
    4. 9.4 Floating-Point Data Types
    5. 9.5 The Space of Floating-Point Representable Values
    6. 9.6 Floating-Point Representable Values
      1. 9.6.1 Normal Values
      2. 9.6.2 Subnormal Values
      3. 9.6.3 Zeros
      4. 9.6.4 Infinities
      5. 9.6.5 Not-a-Numbers (NaNs)
    7. 9.7 The Floating-Point Register File of the Cortex-M4
    8. 9.8 FPU Control Registers
      1. 9.8.1 The Floating-Point Status and Control Register, FPSCR
        1. 9.8.1.1 The Control and Mode Bits
        2. 9.8.1.2 The Exception Bits
      2. 9.8.2 The Coprocessor Access Control Register, CPACR
    9. 9.9 Loading Data into Floating-Point Registers
      1. 9.9.1 Floating-Point Loads and Stores: The Instructions
      2. 9.9.2 The VMOV instruction
    10. 9.10 Conversions between Half-Precision and Single-Precision
    11. 9.11 Conversions to Non-Floating-Point Formats
      1. 9.11.1 Conversions between Integer and Floating-Point
      2. 9.11.2 Conversions between Fixed-Point and Floating-Point
    12. 9.12 Exercises
  13. Chapter 10 - Introduction to Floating-Point: Rounding and Exceptions
    1. 10.1 Introduction
    2. 10.2 Rounding
      1. 10.2.1 Introduction to Rounding Modes in the IEEE 754-2008 Specification
      2. 10.2.2 The roundTiesToEven (RNE) Rounding Mode
      3. 10.2.3 The Directed Rounding Modes
        1. 10.2.3.1 The roundTowardPositive (RP) Rounding Mode
        2. 10.2.3.2 The roundTowardNegative (RM) Rounding Mode
        3. 10.2.3.3 The roundTowardZero (RZ) Rounding Mode
      4. 10.2.4 Rounding Mode Summary
    3. 10.3 Exceptions
      1. 10.3.1 Introduction to Floating-Point Exceptions
      2. 10.3.2 Exception Handling
      3. 10.3.3 Division by Zero
      4. 10.3.4 Invalid Operation
      5. 10.3.5 Overflow
      6. 10.3.6 Underflow
      7. 10.3.7 Inexact Result
    4. 10.4 Algebraic Laws and Floating-Point
    5. 10.5 Normalization and Cancelation
    6. 10.6 Exercises
  14. Chapter 11 - Floating-Point Data-Processing Instructions
    1. 11.1 Introduction
    2. 11.2 Floating-Point Data-Processing Instruction Syntax
    3. 11.3 Instruction Summary
    4. 11.4 Flags and Their Use
      1. 11.4.1 Comparison Instructions
      2. 11.4.2 The N Flag
      3. 11.4.3 The Z Flag
      4. 11.4.4 The C Flag
      5. 11.4.5 The V Flag
      6. 11.4.6 Predicated Instructions, or the Use of the Flags
      7. 11.4.7 A Word about the IT Instruction
    5. 11.5 Two Special Modes
      1. 11.5.1 Flush-to-Zero Mode
      2. 11.5.2 Default NaN
    6. 11.6 Non-Arithmetic Instructions
      1. 11.6.1 Absolute Value
      2. 11.6.2 Negate
    7. 11.7 Arithmetic Instructions
      1. 11.7.1 Addition/Subtraction
      2. 11.7.2 Multiplication and Multiply–Accumulate
        1. 11.7.2.1 Multiplication and Negate Multiplication
        2. 11.7.2.2 Chained Multiply–Accumulate
        3. 11.7.2.3 Fused Multiply–Accumulate
      3. 11.7.3 Division and Square Root
    8. 11.8 Putting It All Together: A Coding Example
    9. 11.9 Exercises
  15. Chapter 12 - Tables
    1. 12.1 Introduction
    2. 12.2 Integer Lookup Tables
    3. 12.3 Floating-Point Lookup Tables
    4. 12.4 Binary Searches
    5. 12.5 Exercises
  16. Chapter 13 - Subroutines and Stacks
    1. 13.1 Introduction
    2. 13.2 The Stack
      1. 13.2.1 LDM/STM Instructions
      2. 13.2.2 PUSH and POP
      3. 13.2.3 Full/Empty Ascending/Descending Stacks
    3. 13.3 Subroutines
    4. 13.4 Passing Parameters to Subroutines
      1. 13.4.1 Passing Parameters in Registers
      2. 13.4.2 Passing Parameters by Reference
      3. 13.4.3 Passing Parameters on the Stack
    5. 13.5 The ARM APCS
    6. 13.6 Exercises
  17. Chapter 14 - Exception Handling: ARM7TDMI
    1. 14.1 Introduction
    2. 14.2 Interrupts
    3. 14.3 Error Conditions
    4. 14.4 Processor Exception Sequence
    5. 14.5 The Vector Table
    6. 14.6 Exception Handlers
    7. 14.7 Exception Priorities
    8. 14.8 Procedures for Handling Exceptions
      1. 14.8.1 Reset Exceptions
      2. 14.8.2 Undefined Instructions
      3. 14.8.3 Interrupts
        1. 14.8.3.1 Vectored Interrupt Controllers
        2. 14.8.3.2 More Advanced VICs
      4. 14.8.4 Aborts
        1. 14.8.4.1 Prefetch Aborts
        2. 14.8.4.2 Data Aborts
      5. 14.8.5 SVCs
    9. 14.9 Exercises
  18. Chapter 15 - Exception Handling: v7-M
    1. 15.1 Introduction
    2. 15.2 Operation Modes and Privilege Levels
    3. 15.3 The Vector Table
    4. 15.4 Stack Pointers
    5. 15.5 Processor Exception Sequence
      1. 15.5.1 Entry
      2. 15.5.2 Exit
    6. 15.6 Exception Types
    7. 15.7 Interrupts
    8. 15.8 Exercises
  19. Chapter 16 - Memory-Mapped Peripherals
    1. 16.1 Introduction
    2. 16.2 The LPC2104
      1. 16.2.1 The UART
      2. 16.2.2 The Memory Map
      3. 16.2.3 Configuring the UART
      4. 16.2.4 Writing the Data to the UART
      5. 16.2.5 Putting the Code Together
      6. 16.2.6 Running the Code
    3. 16.3 The LPC2132
      1. 16.3.1 The D/A Converter
      2. 16.3.2 The Memory Map
      3. 16.3.3 Configuring the D/A Converter
      4. 16.3.4 Generating a Sine Wave
      5. 16.3.5 Putting the Code Together
      6. 16.3.6 Running the Code
    4. 16.4 The Tiva Launchpad
      1. 16.4.1 General-Purpose I/O
      2. 16.4.2 The Memory Map
      3. 16.4.3 Configuring the GPIO Pins
      4. 16.4.4 Turning on the LEDs
      5. 16.4.5 Putting the Code Together
      6. 16.4.6 Running the Code
    5. 16.5 Exercises
  20. Chapter 17 - ARM, Thumb and Thumb-2 Instructions
    1. 17.1 Introduction
    2. 17.2 ARM and 16-Bit Thumb Instructions
      1. 17.2.1 Differences between ARM and 16-Bit Thumb
      2. 17.2.2 Thumb Implementation
    3. 17.3 32-Bit Thumb Instructions
    4. 17.4 Switching Between ARM and Thumb States
    5. 17.5 How to Compile for Thumb
    6. 17.6 Exercises
  21. Chapter 18 - Mixing C and Assembly
    1. 18.1 Introduction
    2. 18.2 Inline Assembler
      1. 18.2.1 Inline Assembly Syntax
      2. 18.2.2 Restrictions on Inline Assembly Operations
    3. 18.3 Embedded Assembler
      1. 18.3.1 Embedded Assembly Syntax
      2. 18.3.2 Restrictions on Embedded Assembly Operations
    4. 18.4 Calling between C and Assembly
    5. 18.5 Exercises
  22. Appendix A: Running Code Composer Studio
    1. A.1 Introduction
    2. A.2 Running Code on the Cortex-M4
      1. A.2.1 Creating a Cortex-M4 Project and Selecting a Device
      2. A.2.2 Creating Application Code
      3. A.2.3 Building the Project and Running Code
  23. Appendix B: Running Keil Tools
    1. B.1 Introduction
    2. B.2 Working with an ARM7TDMI
      1. B.2.1 Creating an ARM7TDMI Project and Selecting a Device
      2. B.2.2 Creating Application Code
      3. B.2.3 Building the Project and Running Code
    3. B.3 Working with a Cortex-M4
      1. B.3.1 Creating a Cortex-M4 Project and Selecting a Device
      2. B.3.2 Creating Application Code
      3. B.3.3 Building the Project and Running Code
  24. Appendix C: ASCII Character Codes
  25. Appendix D
  26. Glossary
  27. References
    1. Internet

Product information

  • Title: ARM Assembly Language, 2nd Edition
  • Author(s): William Hohl, Christopher Hinds
  • Release date: October 2014
  • Publisher(s): CRC Press
  • ISBN: 9781482229868