ARM is a load/store machine — so the moment you leave the registers, you're dealing with memory. Today: how ARM measures data, why alignment matters, and the famous endianness question that trips up every beginner.
To the CPU, memory is one enormous numbered list of bytes — each byte has an address (0, 1, 2, 3 …). "Byte-addressable" means every single byte has its own address. Bigger values simply occupy several consecutive bytes.
| Name | Size | Bytes | Typical load instruction |
|---|---|---|---|
| Byte | 8 bits | 1 | LDRB |
| Halfword | 16 bits | 2 | LDRH |
| Word | 32 bits | 4 | LDR |
| Doubleword | 64 bits | 8 | LDRD / LDP (A64) |
Notice ARM's word is 32 bits, not 16 (that habit comes from older x86 docs). A "word" on ARM = 4 bytes, always. We'll meet these load/store instructions properly on Day 10.
An access is aligned when the address is a multiple of the data's size:
Aligned accesses are fast and always legal. Misaligned ones are either slower, or — depending on the core, the instruction, and a control bit — raise an alignment fault and crash. The lesson: keep your data aligned. Compilers do this for you; it matters when you cast pointers or pack structures by hand.
Think of memory as a shelf where books must start at marked slots. A 4-slot book placed neatly on a multiple-of-4 slot is grabbed in one motion. Jam it half-way between slots and the librarian either takes two trips… or refuses.
Here's the classic puzzle. Store the 32-bit value 0x12345678 at address 0x100. It needs 4 bytes — but in what order? Two valid answers exist:
ARM is bi-endian (it supports both), but in the real world it's almost always run little-endian — Linux, Android, and virtually all Cortex-M devices. Big-endian still appears in some networking gear (network byte order is big-endian).
It only matters when bytes cross a boundary — saving binary to a file, sending over a network, or casting a int* to a char*. Two machines of different endianness reading the same bytes get different numbers. That's why protocols define a byte order explicitly.
If that p[0] == 0x78 surprised you, you've just felt endianness for the first time. On a big-endian machine, p[0] would be 0x12.
0xAABBCCDD at 0x200 little-endian — what byte is at 0x200?0x1002 aligned? Why or why not?Byte (8), halfword (16), word (32), doubleword (64). Memory is byte-addressable; LDRB/LDRH/LDR load each size.
The byte order of multi-byte values. Little-endian puts the least-significant byte at the lowest address; big-endian the most-significant. ARM usually runs little-endian.
Aligned accesses (address divisible by size) are fast and always allowed; misaligned ones can be slower or fault.