Byte Addresses and Word-Sized Values
A byte-addressed memory assigns each byte its own address. A multibyte value occupies several consecutive addresses.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a short layout
A two-byte value starting at address 20 occupies 20 and 21. A following packed value can start at 22. The byte order determines which address holds the more significant byte.
Explain alignment separately
An architecture or data layout may require certain values to start at address multiples of their size or other boundaries. An array of four-byte values starting at zero might start its elements at 0, 4, and 8. Row-major indexing uses the same stride reasoning.[1]
Count all addresses touched by one word
Reading a four-byte word beginning at address 12 consumes byte addresses 12 through 15. Address 16 is the first byte outside that word. If the machine imposes alignment, address 13 may be disallowed or require a different access path. See sequence slice boundaries.
Word at 12: addresses 12,13,14,15
Next adjacent word starts at 16
Last full aligned word in a 20-byte array starts at 16
Separate stored bytes from numeric interpretation
The same four bytes can decode differently under little-endian and big-endian order. Bounds checks need the full access width, not just the first byte. Test a request beginning inside the array whose last bytes would extend beyond it.