</>EmbeddedInterview

Do ARM64 registers X0, X1 and X2 contain data or memory addresses?

EasyMicrocontrollers & ARM Cortex-M

ARM64 general-purpose registers X0, X1 and X2 contain 64-bit bit patterns. They have no inherent C data type: the instruction decides whether a value is interpreted as data or an address.

1. Register used for data

MOV X0, #10
MOV X1, #20
ADD X2, X0, X1

X2 now contains the integer value 30.

2. Register used as address

// X1 already contains a valid readable address.
LDR X0, [X1]

X1 holds the effective base address; the CPU reads eight bytes using the applicable memory translation and attributes, placing the loaded value in X0.

X1 = 0x1000 --> memory at 0x1000 contains 50
                  LDR X0, [X1]
X0 = 50

The address in a normal Linux process is virtual and must be mapped with suitable permissions.

3. W-register relationship

W0 names the low 32 bits of X0. Writing W0 clears the upper 32 bits of X0. LDR W0 loads a 32-bit value; LDR X0 loads a 64-bit value.

Interview takeaway: Registers can hold integers, addresses, masks or other bit patterns. The instruction and software convention determine interpretation.