The Definitive Guide to the ARM Cortex-M3

Here we introduce some of the commonly used syntax for ARM assembly code. Some of the instructions have various options such as barrel shifter; these will not be fully covered in this chapter.
One of the most basic functions in a processor is transfer of data. In the Cortex-M3, data transfers can be of one of the following types:
Moving data between register and register
Moving data between memory and register
Moving data between special register and register
Moving an immediate data value into a register
The command to move data between registers is MOV (move). For example, moving data from register R3 to register R8 looks like this:
MOV R8, R3
Another instruction can generate the negative value of the original data; it is called MVN (move negative).
The basic instructions for accessing memory are Load and Store. Load (LDR) transfers data from memory to registers, and Store transfers data from registers to memory. The transfers can be in different data sizes (byte, half word, word, and double word), as outlined in Table 4.14.
| Example | Description |
|---|---|
|
LDRB Rd, [Rn, #offset] | Read byte from memory location Rn + offset |
|
LDRH Rd, [Rn, #offset] | Read half-word from memory location Rn + offset |
|
LDR Rd, [Rn, #offset] | Read word from memory location Rn + offset |
|
LDRD Rd1,Rd2, [Rn, #offset] | Read double word from memory location Rn + offset |
|
STRB Rd, [Rn, #offset] | Store byte... |