What is a load-store architecture?
Short answer: Arithmetic normally uses registers; explicit loads and stores transfer data between registers and memory.
LDR W0, [X1]
ADD W0, W0, #1
STR W0, [X1]
1. How an increment works: Assume X1 points to a 32-bit integer containing 10. LDR reads 10 into W0; ADD produces 11; STR writes 11 back. The arithmetic instruction does not directly modify RAM.
(*p)++;
2. Access size: LDRB reads one byte, LDRH two bytes, LDR Wn four bytes and LDR Xn eight bytes. Stores have corresponding variants.
3. Concurrency: A load, add and store sequence is not atomic. Two cores can read the same old value and lose one update. Use an atomic operation when required.
Interview takeaway: Explicit load/store instructions move data between memory and registers, while the ALU normally operates on registers.
Example: increment a memory-mapped value
LDR W0, [X1] // load 32-bit value into register
ADD W0, W0, #1 // arithmetic on register
STR W0, [X1] // store 32-bit result
The ADD does not access the addressed memory; it uses register operands. This design keeps common arithmetic separate from data-transfer instructions. Instructions such as LDP/STP transfer pairs, and atomic memory instructions are additional architectural operations rather than evidence that all arithmetic directly accesses memory.
The three-instruction increment is not atomic. Two cores could load the same old value before either stores a result. For shared RAM use suitable atomics or a lock. For MMIO, an apparently simple load/add/store can be wrong if a register has read-to-clear or write-one-to-clear semantics. Use documented register operations and OS accessors.