HomeARM CourseDay 4
DAY 4 · FOUNDATIONS

Memory, Data Types, Alignment & Endianness

By EcrioniX · Updated Jun 6, 2026

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.

1. Memory is just a giant array of bytes

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.

2. The four data sizes

NameSizeBytesTypical load instruction
Byte8 bits1LDRB
Halfword16 bits2LDRH
Word32 bits4LDR
Doubleword64 bits8LDRD / 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.

3. Alignment — keep data on tidy boundaries

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.

💡 Analogy

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.

4. Endianness — which byte comes first?

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:

Value0x12345678 (12 = most significant byte)
Little-endian
780x100
560x101
340x102
120x103
Big-endian
120x100
340x101
560x102
780x103

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).

✅ Why endianness will bite you

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.

5. Seeing it in C

// on a little-endian ARM: uint32_t x = 0x12345678; uint8_t* p = (uint8_t*)&x; // p[0]=0x78 p[1]=0x56 p[2]=0x34 p[3]=0x12 // the bytes are stored low-to-high → "reversed" in a dump

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.

🎯 Day 4 takeaways

Quick check

  1. How many bytes does a "word" take on ARM?
  2. Store 0xAABBCCDD at 0x200 little-endian — what byte is at 0x200?
  3. Is a word access to address 0x1002 aligned? Why or why not?

FAQ

What are ARM's data sizes?

Byte (8), halfword (16), word (32), doubleword (64). Memory is byte-addressable; LDRB/LDRH/LDR load each size.

Little-endian vs big-endian?

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.

Why does alignment matter?

Aligned accesses (address divisible by size) are fast and always allowed; misaligned ones can be slower or fault.

Previous
← Day 3: Registers & the CPSR

← Back to the full course roadmap