CHAPTER 6Memory Access Instructions

The Arm architecture is a load–store architecture, which means that data processing instructions don't directly operate on data in memory. Instead, if a program wants to modify data stored in memory, it must first load that data from memory into processor registers using a load instruction, modify them using data‐processing instructions, and then store the result back to memory using a store instruction. Each Armv8‐A instruction set offers a variety of load and store instruction forms, which we will cover in this chapter.

There are a lot of different types of load and store instructions in the Arm instruction sets, including a few more complicated forms. In the first part of this chapter, we will look at different addressing modes and offset forms supported by these instructions. The second part covers the logic and their syntax.

Instructions Overview

Let's start with the basic load and store instructions. The load register (LDR) instruction loads a 32‐bit value from a memory address into a register, as shown in Figure 6.1. Register R1 holds the memory address to load from, and the loaded 32‐bit value is placed into register R0.

An illustration of LDR instruction.

Figure 6.1: LDR instruction

The memory address loaded or written to is specified via the operand inside the square brackets. In this case, the memory address is the value held in R1. Memory operands are derived ...

Get Blue Fox now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.