Modern Assembly Language Programming with the ARM Processor
()
About this ebook
Modern Assembly Language Programming with the ARM Processor is a tutorial-based book on assembly language programming using the ARM processor. It presents the concepts of assembly language programming in different ways, slowly building from simple examples towards complex programming on bare-metal embedded systems.
The ARM processor was chosen as it has fewer instructions and irregular addressing rules to learn than most other architectures, allowing more time to spend on teaching assembly language programming concepts and good programming practice. In this textbook, careful consideration is given to topics that students struggle to grasp, such as registers vs. memory and the relationship between pointers and addresses, recursion, and non-integral binary mathematics. A whole chapter is dedicated to structured programming principles. Concepts are illustrated and reinforced with a large number of tested and debugged assembly and C source listings. The book also covers advanced topics such as fixed and floating point mathematics, optimization, and the ARM VFP and NEONTM extensions. PowerPoint slides and a solutions manual are included.
This book will appeal to professional embedded systems engineers, as well as computer engineering students taking a course in assembly language using the ARM processor.
- Concepts are illustrated and reinforced with a large number of tested and debugged assembly and C source listing
- Intended for use on very low-cost platforms, such as the Raspberry Pi or pcDuino, but with the support of a full Linux operating system and development tools
- Includes discussions of advanced topics, such as fixed and floating point mathematics, optimization, and the ARM VFP and NEON extensions
Larry D Pyeatt
Larry Pyeatt earned his doctorate in Computer Science, focusing on Artificial Intelligence, from Colorado State University in 1999. He spent 13 years as a professor at Texas Tech University before moving to the South Dakota School of Mines and Technology in 2012. He has programmed in over 15 assembly languages, from mainframes to 8-bit embedded systems, and teaches a variety of courses including assembly language, operating systems, computer architecture, and probabilistic artificial intelligence.
Related to Modern Assembly Language Programming with the ARM Processor
Related ebooks
ARM 64-Bit Assembly Language Rating: 4 out of 5 stars4/5Definitive Guide to Arm Cortex-M23 and Cortex-M33 Processors Rating: 5 out of 5 stars5/5The Art of Assembly Language Programming Using PIC® Technology: Core Fundamentals Rating: 0 out of 5 stars0 ratingsReal-Time Embedded Systems Rating: 0 out of 5 stars0 ratingsEmbedded C Programming: Techniques and Applications of C and PIC MCUS Rating: 3 out of 5 stars3/5ARM-based Microcontroller Projects Using mbed Rating: 5 out of 5 stars5/5GNU/Linux Rapid Embedded Programming Rating: 0 out of 5 stars0 ratingsARM Microcontrollers Programming for Embedded Systems Rating: 5 out of 5 stars5/5Fast and Effective Embedded Systems Design: Applying the ARM mbed Rating: 5 out of 5 stars5/5The Definitive Guide to the ARM Cortex-M3 Rating: 4 out of 5 stars4/5ARM-Based Microcontroller Multitasking Projects: Using the FreeRTOS Multitasking Kernel Rating: 5 out of 5 stars5/5The Designer's Guide to the Cortex-M Processor Family: A Tutorial Approach Rating: 5 out of 5 stars5/5Blue Fox: Arm Assembly Internals and Reverse Engineering Rating: 0 out of 5 stars0 ratingsLearning Linux Binary Analysis Rating: 4 out of 5 stars4/5PIC Microcontrollers: An Introduction to Microelectronics Rating: 5 out of 5 stars5/5Exploring BeagleBone: Tools and Techniques for Building with Embedded Linux Rating: 4 out of 5 stars4/5Design Recipes for FPGAs: Using Verilog and VHDL Rating: 2 out of 5 stars2/5C Programming for the Pc the Mac and the Arduino Microcontroller System Rating: 0 out of 5 stars0 ratingsSD Card Projects Using the PIC Microcontroller Rating: 0 out of 5 stars0 ratingsEmbedded Computing and Mechatronics with the PIC32 Microcontroller Rating: 5 out of 5 stars5/5AVR RISC Microcontroller Handbook Rating: 0 out of 5 stars0 ratingsFPGAs: Instant Access Rating: 0 out of 5 stars0 ratingsOperational Amplifiers Rating: 4 out of 5 stars4/5Serial Port Complete: COM Ports, USB Virtual COM Ports, and Ports for Embedded Systems Rating: 4 out of 5 stars4/5Assembly Programming:Simple, Short, And Straightforward Way Of Learning Assembly Language Rating: 5 out of 5 stars5/5Mastering Embedded Linux Programming Rating: 5 out of 5 stars5/5ARM® Cortex® M4 Cookbook Rating: 4 out of 5 stars4/5Mastering C Pointers: Tools for Programming Power Rating: 2 out of 5 stars2/5A Guide to Kernel Exploitation: Attacking the Core Rating: 0 out of 5 stars0 ratings
Hardware For You
Programming Arduino: Getting Started with Sketches Rating: 4 out of 5 stars4/5CompTIA A+ Complete Review Guide: Exam Core 1 220-1001 and Exam Core 2 220-1002 Rating: 5 out of 5 stars5/5Creative Selection: Inside Apple's Design Process During the Golden Age of Steve Jobs Rating: 5 out of 5 stars5/5Chip War: The Fight for the World's Most Critical Technology Rating: 4 out of 5 stars4/5CompTIA A+ Complete Review Guide: Core 1 Exam 220-1101 and Core 2 Exam 220-1102 Rating: 5 out of 5 stars5/5Build Your Own PC Do-It-Yourself For Dummies Rating: 4 out of 5 stars4/5Upgrading and Fixing Computers Do-it-Yourself For Dummies Rating: 4 out of 5 stars4/5iPhone For Seniors For Dummies: Updated for iPhone 12 models and iOS 14 Rating: 4 out of 5 stars4/5Dancing with Qubits: How quantum computing works and how it can change the world Rating: 5 out of 5 stars5/5Computer Science: A Concise Introduction Rating: 4 out of 5 stars4/5Mastering ChatGPT Rating: 0 out of 5 stars0 ratingsSo you want to build a computer... Rating: 5 out of 5 stars5/5iPhone Photography: A Ridiculously Simple Guide To Taking Photos With Your iPhone Rating: 0 out of 5 stars0 ratingsiPhone X Hacks, Tips and Tricks: Discover 101 Awesome Tips and Tricks for iPhone XS, XS Max and iPhone X Rating: 3 out of 5 stars3/5Exploring Apple Mac - Ventura Edition: The Illustrated, Practical Guide to Using MacOS Rating: 0 out of 5 stars0 ratingsRaspberry Pi Electronics Projects for the Evil Genius Rating: 3 out of 5 stars3/5Apple Watch Series 4: Your Ultimate Guide to Using the Apple Watch Like A Pro Rating: 5 out of 5 stars5/5iPhone 14 Pro Max User Guide for Beginners and Seniors Rating: 0 out of 5 stars0 ratingsWindows 11 For Seniors For Dummies Rating: 0 out of 5 stars0 ratingsKindle Paperwhite For Dummies Rating: 0 out of 5 stars0 ratingsCompTIA A+ Complete Review Guide: Exams 220-901 and 220-902 Rating: 5 out of 5 stars5/5Evernote Essentials Guide (Boxed Set): Evernote Guide For Beginners for Organizing Your Life Rating: 3 out of 5 stars3/5Raspberry Pi Cookbook for Python Programmers Rating: 0 out of 5 stars0 ratingsiPhone 12, iPhone Pro, and iPhone Pro Max For Senirs: A Ridiculously Simple Guide to the Next Generation of iPhone and iOS 14 Rating: 0 out of 5 stars0 ratingsMacs All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsLinux All-in-One For Dummies Rating: 3 out of 5 stars3/5Samsung Galaxy S23 Ultra User Guide for Beginners and Seniors Rating: 3 out of 5 stars3/5INSTANT PLC Programming with RSLogix 5000 Rating: 4 out of 5 stars4/5
Reviews for Modern Assembly Language Programming with the ARM Processor
0 ratings0 reviews
Book preview
Modern Assembly Language Programming with the ARM Processor - Larry D Pyeatt
book.
Part I
Assembly as a Language
Chapter 1
Introduction
Abstract
This chapter first gives a very high-level description of the major components of function of a computer system. It then motivates the reader by giving reasons why learning assembly language is important for Computer Scientists and Computer Engineers. It then explains why the ARM processor is a good choice for a first assembly language. Next it explains binary data representations, including various integer formats, ASCII, and Unicode. Finally, it describes the memory sections for a typical program during execution. By the end of the chapter, the groundwork has been laid for learning to program in assembly language.
Keywords
Instruction; Instruction stream; Central processing unit; Memory; Input/output device; High-level language; Assembly language; ARM processor; Binary; Hexadecimal; Decimal; Radix or base system; Base conversion; Sign magnitude; Unsigned; Complement; Excess-n; ASCII; Unicode; UTF-8; Stack; Heap; Data section; Text section
Chapter Outline
1.1 Reasons to Learn Assembly 4
1.2 The ARM Processor 8
1.3 Computer Data 9
1.3.1 Representing Natural Numbers 9
1.3.2 Base Conversion 11
1.3.3 Representing Integers 15
1.3.4 Representing Characters 20
1.4 Memory Layout of an Executing Program 28
1.5 Chapter Summary 31
An executable computer program is, ultimately, just a series of numbers that have very little or no meaning to a human being. We have developed a variety of human-friendly languages in which to express computer programs, but in order for the program to execute, it must eventually be reduced to a stream of numbers. Assembly language is one step above writing the stream of numbers. The stream of numbers is called the instruction stream. Each number in the instruction stream instructs the computer to perform one (usually small) operation. Although each instruction does very little, the ability of the programmer to specify any sequence of instructions and the ability of the computer to perform billions of these small operations every second makes modern computers very powerful and flexible tools. In assembly language, one line of code usually gets translated into one machine instruction. In high-level languages, a single line of code may generate many machine instructions.
A simplified model of a computer system, as shown in Fig. 1.1, consists of memory, input/output devices, and a central processing unit (CPU), connected together by a system bus. The bus can be thought of as a roadway that allows data to travel between the components of the computer system. The CPU is the part of the system where most of the computation occurs, and the CPU controls the other devices in the system.
Figure 1.1 Simplified representation of a computer system.
Memory can be thought of as a series of mailboxes. Each mailbox can hold a single postcard with a number written on it, and each mailbox has a unique numeric identifier. The identifier, x is called the memory address, and the number stored in the mailbox is called the contents of address x. Some of the mailboxes contain data, and others contain instructions which control what actions are performed by the CPU.
The CPU also contains a much smaller set of mailboxes, which we call registers. Data can be copied from cards stored in memory to cards stored in the CPU, or vice-versa. Once data has been copied into one of the CPU registers, it can be used in computation. For example, in order to add two numbers in memory, they must first be copied into registers on the CPU. The CPU can then add the numbers together and store the result in one of the CPU registers. The result of the addition can then be copied back into one of the mailboxes in the memory.
Modern computers execute instructions sequentially. In other words, the next instruction to be executed is at the memory address immediately following the current instruction. One of the registers in the CPU, the program counter (PC), keeps track of the location from which the next instruction is to be fetched. The CPU follows a very simple sequence of actions. It fetches an instruction from memory, increments the PC, executes the instruction, and then repeats the process with the next instruction. However, some instructions may change the PC, so that the next instruction is fetched from a non-sequential address.
1.1 Reasons to Learn Assembly
There are many high-level programming languages, such as Java, Python, C, and C++ that have been designed to allow programmers to work at a high level of abstraction, so that they do not need to understand exactly what instructions are needed by a particular CPU. For compiled languages, such as C and C++, a compiler handles the task of translating the program, written in a high-level language, into assembly language for the particular CPU on the system. An assembler then converts the program from assembly language into the binary codes that the CPU reads as instructions.
High-level languages can greatly enhance programmer productivity. However, there are some situations where writing assembly code directly is desirable or necessary. For example, assembly language may be the best choice when writing
• the first steps in booting the computer,
• code to handle interrupts,
• low-level locking code for multi-threaded programs,
• code for machines where no compiler exists,
• code which needs to be optimized beyond the limits of the compiler,
• on computers with very limited memory, and
• code that requires low-level access to architectural and/or processor features.
Aside from sheer necessity, there are several other reasons why it is still important for computer scientists to learn assembly language.
One example where knowledge of assembly is indispensable is when designing and implementing compilers for high-level languages. As shown in Fig. 1.2, a typical compiler for a high-level language must generate assembly language as its output. Most compilers are designed to have multiple stages. In the input stage, the source language is read and converted into a graph representation. The graph may be optimized before being passed to the output, or code generation, stage where it is converted to assembly language. The assembly is then fed into the system’s assembler to generate an object file. The object file is linked with other object files (which are often combined into libraries) to create an executable program.
Figure 1.2 Stages of a typical compilation sequence.
The code generation stage of a compiler must traverse the graph and emit assembly code. The quality of the assembly code that is generated can have a profound influence on the performance of the executable program. Therefore, the programmer responsible for the code generation portion of the compiler must be well versed in assembly programming for the target CPU.
Some people believe that a good optimizing compiler will generate better assembly code than a human programmer. This belief is not justified. Highly optimizing compilers have lots of clever algorithms, but like all programs, they are not perfect. Outside of the cases that they were designed for, they do not optimize well. Many newer CPUs have instructions which operate on multiple items of data at once. However, compilers rarely make use of these powerful single instruction multiple data ( SIMD) instructions. Instead, it is common for programmers to write functions in assembly language to take advantage of SIMD instructions. The assembly functions are assembled into object file(s), then linked with the object file(s) generated from the high-level language