Stephen Smith

Programming with 64-Bit ARM Assembly Language

Single Board Computer Development for Raspberry Pi and Mobile Devices

Stephen Smith
Gibsons, BC, Canada
ISBN 978-1-4842-5880-4e-ISBN 978-1-4842-5881-1
© Stephen Smith 2020
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.

This book is dedicated to my beloved wife and editor Cathalynn Labonté-Smith.

Introduction

Everyone seems to carry a smartphone and/or a tablet. Nearly all of these devices have one thing in common; they use an ARM central processing unit (CPU). All of these devices are computers just like your laptop or business desktop. The difference is that they need to use less power, in order to function for at least a day on one battery charge, therefore the popularity of the ARM CPU.

At the basic level, how are these computers programmed? What provides the magical foundation for all the great applications (apps) that run on them, yet use far less power than a laptop computer? This book delves into how these are programmed at the bare metal level and provides insight into their architecture.

Assembly Language is the native lowest level way to program a computer. Each processing chip has its own Assembly Language. This book covers programming the ARM 64-bit processor. If you really want to learn how a computer works, learning Assembly Language is a great way to get into the nitty-gritty details. The popularity and low cost of single board computers (SBCs) like the Raspberry Pi and NVidia Jetson Nano provide ideal platforms to learn advanced concepts in computing.

Even though all these devices are low powered and compact, they’re still sophisticated computers with a multicore processor, floating-point coprocessor, and a NEON parallel processing unit. What you learn about any one of these is directly relevant to any device with an ARM processor, which by volume is the number one processor on the market today.

In this book, we cover how to program all these devices at the lowest level, operating as close to the hardware as possible. You will learn the following:

  • The format of the instructions and how to put them together into programs, as well as details on the binary data formats they operate on

  • How to program the floating-point processor, as well as the NEON parallel processor

  • About devices running Google’s Android, Apple’s iOS, and Linux

  • How to program the hardware directly using the Raspberry Pi’s GPIO ports

The simplest way to learn this is with a Raspberry Pi running a 64-bit flavor of Linux such as Kali Linux. This provides all the tools you need to learn Assembly programming. There’s optional material that requires an Apple Mac and iPhone or iPad, as well as optional material that requires an Intel-based computer and an Android device.

This book contains many working programs that you can play with, use as a starting point, or study. The only way to learn programming is by doing, so don’t be afraid to experiment, as it is the only way you will learn.

Even if you don’t use Assembly programming in your day-to-day life, knowing how the processor works at the Assembly level and knowing the low-level binary data structures will make you a better programmer in all other areas. Knowing how the processor works will let you write more efficient C code and can even help you with your Python programming.

The book is designed to be followed in sequence, but there are chapters that can be skipped or skimmed, for example, if you aren’t interested in interfacing to hardware, you can skip Chapter 8 , “Programming GPIO Pins,” or Chapter 12 , “Floating-Point Operations,” if you will never do numerical computing.

I hope you enjoy your introduction to Assembly Language. Learning it for one processor family will help you with any other processor architectures you encounter through your career.

Source Code Location

The source code for the example code in the book is located on the Apress GitHub site at the following URL:

https://github.com/Apress/Programming-with-64-Bit-ARM-Assembly-Language

The code is organized by chapter and includes some answers to the programming exercises.

Acknowledgments

No book is ever written in isolation. I want to especially thank my wife, Cathalynn Labonté-Smith, for her support, encouragement, and expert editing.

I want to thank all the good folk at Apress who made the whole process easy and enjoyable. A special shout-out to Jessica Vakili, my coordinating editor, who kept the whole project moving quickly and smoothly. Thanks to Aaron Black, senior editor, who recruited me and got the project started. Thanks to Stewart Watkiss, my technical reviewer, who helped make this a far better book.

Table of Contents
Index 423
About the Author
Stephen Smith
../images/494415_1_En_BookFrontmatter_Figb_HTML.jpg

is also the author of the Apress titleRaspberry Pi Assembly Language Programming . He is a retired Software Architect, located in Gibsons, BC, Canada. He’s been developing software since high school, or way too many years to record. He was the Chief Architect for the Sage 300 line of accounting products for 23 years. Since retiring, he has pursued artificial intelligence, earned his Advanced HAM Radio License, and enjoys mountain biking, hiking, and nature photography. He continues to write his popular technology blog at smist08.wordpress.com and has written two science fiction novels in theInfluence series available on Amazon.com.

 
About the Technical Reviewer
Stewart Watkiss
../images/494415_1_En_BookFrontmatter_Figc_HTML.jpg
is a keen maker and programmer. He has a master’s degree in electronic engineering from the University of Hull and a master’s degree in computer science from Georgia Institute of Technology.

He has over 20 years of experience in the IT industry, working in computer networking, Linux system administration, technical support, and cyber security. While working toward Linux certification, he created the web site www.penguintutor.com . The web site originally provided information for those studying toward certification but has since added information on electronics, projects, and learning computer programming.

Stewart often gives talks and runs workshops at local Raspberry Pi events. He is also a STEM Ambassador and Code Club volunteer helping to support teachers and children learning programming.

 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.36.30