Gravitational plate of three masses and a slashed discABC0Static engraved plate. Three-dimensional view is unavailable or reduced motion is requested.

← back to fieldarchive

archiveFeb 10, 2021

ARM Data Transfer: Pre/Post-Index and STR/LDR

How ARM moves data between registers and memory with LDR/STR, and how pre-index versus post-index addressing updates the base register.

Store and load instructions

  • ARM does not allow memory-to-memory data processing.
  • You move data with register ↔ memory transfer instructions.

Load

  • Memory → Register

Store

  • Register → Memory

./STR-LDR.png
./STR-LDR.png

Single-register data transfer

<LDR | STR> {<cond>} {<size>} Rd, <address>
  • LDR, STR, LDRB, STRB (size: WORD, BYTE)

Pre- and post-index addressing

Pre-index method

  • After the transfer, the base register is unchanged.
  • Append ! to write the computed address back into the base register.

./Pre-Index.png
./Pre-Index.png

Post-index method

  • After the transfer, the base register is updated with base + offset.

./Post-Index.png
./Post-Index.png

  • In the example, base register r1 becomes 0x100 + 0xc.

related

  1. Feb 10, 2021/archiveARM: Loading Addresses into Registers
  2. Feb 10, 2021/archiveARM LDR Rd, =const
  3. Feb 10, 2021/archiveARM: loading constants into registers

graphfeed