ARM A32 ASSEMBLY LANGUAGE
About this eBook
This is a free-flow eBook. As such the on-screen formatting is almost totally decided by your eBook reader default settings.
Please remember, if you have an early generation eReader, you can obtain free eReading devices for use on PCs and Macs which are capable of rendering the formats used in this book if they do not display as intended on your particular eReader.
About the Author
Bruce Smith purchased his first computer an Acorn Atom in 1980. He was immediately hooked, becoming a regular contributor to the mainstream computer press, including Computing Today and Personal Computer World. With the arrival of the BBC Micro his magazine work expanded into books and his 1982 title Interfacing Projects for the BBC Micro (published by Addison Wesley) has become regarded as a classic of the time, as the first book showing home users how to connect the computer to the outside world. He was one of the first to write about the ARM chip when it was released on the Acorn Archimedes in 1987.
Well over 100 books later Bruce has written about all aspects of computer use. His friendly, lucid style of writing caused one reviewer to write, This is the first computer book I have read in bed for pleasure rather than to cure insomnia! Bruces books have been translated into many languages and sold across the world.
Bruce also writes about sport and his publishers have included BBC Books, Virgin Books, Rough Guides, Headline and Mainstream Publishing. He has been a regular contributor for BBC local and national radio and has appeared on Channel 4s The Big Breakfast and BBC World Service.
Follow Bruce on Twitter: @brucefsmith or Facebook: authorbrucesmith and check out his occasional blog Alan Turing Rocks which can be found on the website.
Errata
No book is perfect and I doubt this one is either. Whilst we have tried as hard as possible to ensure that this book is as accurate as possible before going to press, because of its technical and complex nature errors may exist. Thankfully due to the world of digital media they can be rectified and corrections implemented quickly. If you think something isnt quite right then please visit the book errata page at www.brucesmith.info. Select the ARM menu and then Book Resource Page option, once there locate the link to the errata page from the list of options provided you will be able to see if any issues are already known. If you do not see something covered and feel that you may have discovered an error or anomaly then please email me directly via the Contacts Page on my website. That way I can confirm or otherwise and if the former is the case, provide you with an acknowledgment and make the change.
Reviews
I am an independent publisher. I write and publish my own books. This means I can write about subjects other mainstream publishers would not normally take on. As such reviews are very important to me. Please take the time to write an honest review of this book if you are able. If you have a concern or issue please write to me at . I do my best to respond to every email I get. Your sale is important to me to ensure I can continue to write and publish books like this. Thank you.
Acknowledgements
Extra special thanks go to Richard Khoury for his help with the C segments within this book and the finer art of using GCC and GDB. His assistance with programming the GPIO is also very much appreciated.
Thanks to Mike Ginns for the concepts of several programs listed here. Some listings originate from his book Archimedes Assembly Language which was first published by Dabs Press in 1988. (A key to how old the ARM actually is!)
Thank you also to my Beta Readers who gallantly read through the page proofs and marked up errors, typos and made suggestions to further improve the book. They are, in first name order only:
Richard Costello
Robin Karpeta
Tony Palmer
Any remaining errors are entirely my fault, and if you find them please be kind enough to let me know via my website or at .
Bruce Smith
Sydney, April 2017.
Dedication
Baby La, Alice and Oliver
1: Introduction
It could be argued that ARM is the most successful company no one has heard of. Unless you are in the computer business of course. Then they are, certainly to my mind, the most innovative of the microprocessor creating juggernauts. I can remember when I first heard about the new RISC processor that Acorn Computers were creating, I was in the Acorn office in Fulbourn Road, Cambridge (UK). Then the design was for the Acorn RISC Machine. I can remember quizzing the team how can a processor with fewer instructions perform better than one with a bigger instruction set? I didnt get it then, but I soon cottoned on as the first ARM-based systems became available.
Acorn has long ceased to exist, and it is now the Advanced RISC Machine. Of course, several of the stalwarts who revolutionised the home computing market with the BBC Micro still serve ARM to this day and help push the capability boundaries of the chip.
The family of ARM chips has grown phenomenally over the past umpteen years. Each successive generation of the chip has expanded its capability and functionality. Their success has been based on several things but primarily comes down to performance and cost.
Simply, ARM chips outperform all other comparable chips and at a low production cost. It is estimated that almost 80 billion ARM chips have been produced to date. If you have an electronic device, it almost certainly has an ARM chip inside it! The ARM chip offers almost unrivalled backward capability meaning that software written for it today will run on it in the future. This combination of performance, wide offering and low cost, and compatibility make it such that you simply cant ignore ARM.
ARM licences their technology so that other companies Apple for example, and there are many others can create their own fit-for-purpose ARM chips.
Figure 1a. The Raspberry Pi Zero might be considered a disposable computer given its $5 price tag!
Architectural Cores
To most technically-minded PC users, a (micro)processor is the large chip that sits on the computer board and which controls everything that is happening on it. A core, on the other hand, of which there might be two, four, six or eight, is a part of the processor thats responsible for executing instructions. As such you could effectively have several operations running in different cores entirely separately but running concurrently. As you might imagine, this can provide a boost in speed.
With an ARM chip, it is slightly different in that manufacturers can customise the individual cores as part of their chip designs. This allows manufacturers who license the ARM chip to create amazing functionality that is specifically suited to their needs. ARM themselves design cores for their processors and these are generally grouped into named families. By combining these cores with some other function specific chips onto one piece of silicon, you can create what we now know as a System-on-a-Chip or SOC. The fact that these combined systems can share operating space can significantly speed up their performance by another notch.
The other thing to understand when negotiating the ARM world is that there is a difference between architecture and core names. The ARM architecture is based on the ARM instruction set and with each release the instruction set, is often upgraded and expanded thus bringing even more functionality.
The first ARM hardware application was as an add-on second processor for the BBC Micro. This was a unit, like that shown above, that plugged into the BBC Micro via a port called The Tube. This allowed the users to have access to the ARM and program it for whatever needs via the BBC Micro keyboard. It was a bright idea that never really caught on as the ARM capability merely accelerated past the computers it was being connected too. (In many respects the ARM Second Processor was a proof of concept device that allowed users to access the chips capabilities in much the same way as single board computers do today.)
Next page