ARM Assembly Language

Here are two training courses originally written to introduce my former colleagues at Picsel (external link) to the joys of programming in ARM (external link) assembly language. They are:

Introduction to ARM
The first course introduces the reader to ARM assembly language. It goes on to explain the development of the ARM architecture and the capabilities of the various ARM CPU cores.
After reading this you should be able to understand ARM code well enough to understand the examples in the following course...
Efficient C for ARM
The second course is about tuning. It looks at how we can produce efficient ARM code by altering the way we write our C code.

The courses were presented to over 70 engineers in the UK (Glasgow, Edinburgh, Reading offices), Malaysia (Kuala Lumpur) and Korea (Seoul).

Each course would usually take three hours to deliver. The course would be presented sandwich style: two lecture parts and a delicious centre filling where the student gets to experiment with some small routines.

Some caveats

The courses have been (manually) converted across from the PowerPoint slides and separate trainer’s notes I used when presenting the courses. This may show in the terseness of some of the pages. Some detail is sacrificed for the sake of making a point.

Some closely related sections have been merged together, some were left separate. Some of the pages are of substantially different lengths.

Over time I’ll rework the content to better suit its new format.

Toolchains

The courses were written for an environment where the ARM Developer Suite (external link) (ADS) was available, so all of the assembler examples are in ADS format. If you intend to try the examples on a more affordable compiler, such as GCC (external link), you will need to use GNU ARM assembler syntax (external link).

Assembler examples were compiled with (the now rather old pair of) ADS 1.2’s armcc and GCC 2.95.2. You will find that other compilers produce different code, of varying quality. (In my experience WinCE’s compiler in particular generates some particularly poor code).

Changelog

The most recent changes are listed first.

29th November 2010
Many adjustments and clarifications to the first half of Introduction to ARM.
9th December 2009
Various minor tweaks to the text.
24th November 2009
Added a note about implementation-defined behaviour to the barrel shifter page. (sbrodie (external link))
Fixed the factorial task answer to Task Two: its MOVEQ pc,r14 should have been MOVEQ r0,#1 to return the correct result for 0!. (sbrodie)
19th November 2009
New logo throughout (its font (external link)).
Assembler syntax colouring has been improved. It no longer highlights things inside of comments.
October/November 2009
Various changes I’ve forgotten to note properly, including...
The C code examples are now automatically syntax coloured using Syntax-Highlight-Engine-Kate (external link).
Assembler examples coloured too, using a not very good script of my own.
25th October 2009
Changelog started. :-)
Darkened the text colour of <CODE> elements. (joty)
Syntax coloured the code in Task One using Vim (:tohtml). (tlsa)
ASR != << — cut and paste error. (jmb)

Credits

Many thanks go to the following kind souls for reviewing the content and making suggestions:

  • Alex Macfarlane Smith
  • Christopher Bazley
  • Graham Borland
  • John Tytgat
  • John-Mark Bell
  • Justin Fletcher
  • Matt Holgate
  • Michael Drake
  • Robin Watts
  • Stewart Brodie

Acknowledgements

ARM® is a trademark of ARM Limited (external link).

Comments

If you have any suggestions for improving these pages you can email me at webmaster at davespace dot co dot uk.