

LDR X0, loads the 64-bit integer at the address 00000100 into register X0.At the start of each of these, the register X1 contains the address 00000100. To understand these, it’s useful to work through some examples.
Arm assembly readwrite code#
Label – PC relative, which is used for accessing values defined in the code by a label. ,offset – post-indexed, which works like an offset, but as a result of this instruction the address in the register is updated by adding the offset at the end of execution this is commonly used for popping values from the stack ! – pre-indexed, which works like an offset, but before use the address in the register has the offset added to it this is commonly used for loading or storing values in an array – base register with an offset, in which the effective address is the sum of the address in the base register and the offset – base register, which can include SP to use the stack pointer The reg item in those instructions can use any of five different addressing modes: Instructions more commonly use the first operand to specify the destination of the result STR is an important exception. Note how the direction of movement differs in the two: LDR loads the first operand as the destination, whereas STR stores what’s in the first operand as the source. STR X0, stores what’s in register X0 to the address in reg, such as register X1.LDR X0, loads what’s at the address in reg, such as register X1, into register X0.

There are two basic instructions for transferring data between memory and registers, LDR which loads into a register, and STR which stores into memory.

I ended with a cliffhanger, promising to explain how arguments can be accessed from pointers passed to a routine. In the previous article, I explained the basic architecture of the registers of the ARM64 processor, and explained how they can be used by an assembly language routine to access and return values.
