Before we start to write an assembly language subroutine, we need an idea of what the function has to achieve. The best way to specify this is to first write the function in a high-level language, such as C, and then translate the C code into assembly language line by line. Some experienced assembly language programmers argue that this is inefficient, but the technique produces well-documented code that can be optimized in further iterations of the design.
To translate the C code, we need to be familiar with both the instruction set and the addressing modes that are used by the Cortex-M4. Details of the instruction set can be found in ARM's Architecture Reference Manual and also in the ARM Cortex-M4 Generic User Guide (http://infocenter.arm.com/). Addressing modes are fundamental to a general understanding of computer architecture, but they are of practical interest to compiler writers and those writing assembly language. The following paragraph...