Aligning Addresses

In some machines, accesses to objects larger than a byte must be aligned . An access to an object of size s bytes at byte address A is aligned if A mod s = 0.

Aligned and misaligned accesses of objects
Object Addressed Aligned at Byte Offset Misaligned at Byte Offset
byte 0,1,2,3,4,5,6,7 never
halfword 0,2,4,6 1,3,5,7
word 0,4 1,2,3,5,6,7
doubleword 0 1,2,3,4,5,6,7

Misalignment causes hardware complications, since the memory is typically aligned on a word boundary. A misaligned memory access will, therefore, take multiple aligned memory references.

A word reference is made to a halfword (16 bit) boundary in the memory system that has a 32-bit access path. The CPU or memory system has to perform two separate accesses to get the upper and lower halfwords. The two halfwords are then merged to obtain the entire word.

Even if data is aligned, supporting byte and halfword accesses requires an alignment network to align bytes and halfwords in registers.