ebook img

Assembly Language Raspberry Pi PDF

569 Pages·15.429 MB·
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Assembly Language Raspberry Pi

Assembly Language using the Raspberry Pi: A Hardware Software Bridge Copyright © 2017 by Robert Dunne. All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means without the prior written permission of the copyright owner and publisher. Published in the United States of America by Gaul Communications, Downers Grove, Illinois. ISBN 978-0-9701124-1-5 (paperback) ISBN 978-0-9701124-0-8 (digital) This book refers to and uses the GNU software and Raspian Linux kernel distributed for the Raspberry Pi. See the GNU General Public License for details which is available from the Free Software Foundation, Inc., Boston, Massachusetts. Assembly Language Using the Raspberry Pi: A Hardware Software Bridge is an independent publication and has not been authorized, sponsored, or endorsed by any of the hardware or software rights holders described herein. The publisher makes no warranty, express or implied, with respect to the material contained herein. The program listings, examples, and other information presented in this book are distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this book, neither the author nor Gaul Communications shall have any liability regarding its use. 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 Assembly Language Using the Raspberry Pi A Hardware Software Bridge Robert Dunne To the four ladies in my life Carol Shannon Robyn Kelly Contents Preface 0 Introduction - Computer Basics 1 Compile, Link, Execute 2 Arithmetic Logic Unit 3 Subroutines and ASCII Output 4 True and False 5 Display Numbers in Binary 6 Display Numbers in Hexadecimal 7 Display Numbers in Decimal 8 Data Types and Storage 9 Disassembler 10 Fixed Point 11 Binary Point 12 Floating Point Display 13 Floating Point Coprocessor 14 Precision 15 Performance Using Vectors 16 Text and Logical Input 17 Integer Input 18 Floating Point Input 19 Model View Controller Epilogue Appendix A: Raspberry Pi Setup Appendix B: Binary Numbers Appendix C: Hexadecimal Numbers Appendix D: ASCII Appendix E: Text Editors Appendix F: ARM Instructions Appendix G: Vector & Floating Point Instructions Appendix H: Assembler Directives Appendix I: Linux Service Calls Appendix J: GDB Debugger Commands Appendix K: Command Lines Appendix L: C Programming Appendix M: Electronic Interfaces Appendix N: Thumb Code Answers to Selected Questions Preface H ow do you use your Raspberry Pi? That’s a question I ask my students as well as people I meet in the business world. Some use it for games and entertainment. Some use it as part of a workstation in a network of computers. Some don’t even use it, but bought one simply because the price was very reasonable. I primarily use the Raspberry Pi as part of instruction in electronics and computer science. Education was the principal motive for the development of the Raspberry Pi, and you can learn about its creation through the Raspberry Pi Foundation, a registered charity in the United Kingdom that promotes computer literacy and enthusiasm. Assembly language is the computer programming language closest to a CPU’s (Central Processing Unit) “machine language.” Programs written in assembly language are unique to a particular CPU design and are not portable from one CPU manufacturer or model to another. Programs written in higher level languages like Java, Python, C++, and Lisp are generally independent of the native hardware architecture of the CPU on which they will eventually run. Audience for This Book This book is part of a lecture and lab course in embedded systems. Embedded systems are internal computers that control almost everything today: automobile engines, television sets, furnaces, vacuum cleaners, cell phones, etc. The objective of this book is to introduce the novice to both CPU hardware and professional software development methods by working through sample assembly language programs. The intended audience is the following: Anyone wanting to learn assembly language, especially individuals interested in the Raspberry Pi, the ARM CPU, VFPv3 floating point coprocessor, and NEON coprocessor architectures in particular. Someone who already has assembly language experience, but now wants to become familiar with the ARM CPU, VFPv3 IEEE 754 floating point processor, and NEON vector processor resident in the Raspberry Pi. Electronics engineers who want to bridge the gap toward software development, and software engineers who want to bridge the gap toward CPU hardware operation. College students enrolled in embedded systems and computer architecture courses. Expected background for someone reading this book to learn assembly language using the Raspberry Pi: Most of my electronics students have no programming experience. Some have had limited encounters with Basic, C++, or Java. Students should be able to start a Raspberry Pi and get it into Linux command line mode. I have included an appendix that should be adequate for most people needing some assitance. Note: Although I refer to the Raspberry Pi, almost any Linux or Unix system along with GNU utilities for an ARM processor will be adequate for most of the chapters in this book. My embedded systems students have already taken a course in digital electronics. In other words, they will be familiar with binary, hexadecimal, ASCII, and hardware concepts like registers. For those needing assistance or refreshing in these areas, I have included appendices. With students having the above background, the approach taken in this book is to be very thorough in providing detailed programming examples and not very thorough in explaining binary, hexadecimal, and ASCII. I have taken this approach based upon several years of feedback from electronics students of embedded systems indicating where they want more detail and where they need less. Readers with a strong background in computer programming may find I develop coding examples more slowly than they might prefer, and others might say I didn’t explain binary and hexadecimal adequately (although I do provide several appendices explaining a variety of background issues). Why Did I Write a Book for Learning Assembly Language? I’ve seen a lot of poorly written programs over the years, and I mean production code, not just classroom programming. The vast majority of it comes from people who have learned the elements of a programming language, but not how to develop software. It’s comparable to an auto mechanic learning how to use wrenches, vacuum gauges, and oscilloscopes without knowing how an engine works. It’s also like a soldier being taught to use a weapon but without being given the rules of engagement. In this book, I do introduce the “mechanics” of the ARM CPU and floating point processor within the Raspberry Pi, but I do it while subtly introducing software design patterns, object oriented design principles, and software development life cycles. This book is characterized by the following: Independent Study: Although this book is part of my embedded systems course, it does not rely on additional material presented in the course. It is expected that the student will learn assembly language by working through the examples in this book, and we’ll focus on electronic interfaces and feedback control methods during class. Complete examples: Rather than provide just snippets of code, this book contains complete working programs. An emphasis on software design methods: Design patterns and program development life cycles are as important for assembly language application development as for higher level language development. Learn by doing: Prototype programs appear at the beginning of each chapter to get the readers’ “feet wet” before diving into the principles to be learned. Flowcharts: Many students have stated they understand the concepts better when they can visually see the program flow. Review questions and exercises: Every chapter ends with a series of suggested exercises and review questions to augment the understanding of the material presented. Answers to some of the review questions are in the back of the book, but many questions are left unanswered and are available for classroom assignments. Why the Raspberry Pi? So, why did I specifically target this book at the Raspberry Pi when other development environments have been available to college students for years? ARM Processor: The ARM processor is not only a very interesting CPU architecture, but it is also one of the most popular CPUs currently in production. Floating Point Processor: I wanted my embedded systems students to be both knowledgeable and comfortable with measured analog data ranging from microvolts to hundreds of volts. This range of values is best represented in floating point numbers, and the Raspberry Pi SoC (System on Chip) design comes standard with a floating point processor. Several chapters are devoted to programming the VFPv3 and NEON coprocessors. Professional Quality: My students are in a curriculum to learn to produce industrial strength products. The hardware architecture (ARM CPU) and software (Linux and associated

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.