Reputation: 302
Here there is a definition of word alignment
Words are said to be Aligned in memory if they begin at a byte-address that is a multiple of the number of bytes in a word. https://educatech.in/word-alignment/
But what if I don't have a byte-addressable memory?
In fact, what is the exact general definition of word alignment? Do we ONLY talk about word alignment in case of byte addressable memory?
What is an alignment in case I have a N-bits-addressable memory and a B-bits word size?
Upvotes: 1
Views: 256
Reputation: 364947
Word-addressable memory makes misaligned word accesses impossible because there's literally not an address for anything except the starts of whole words. There are no low bits of the address to be 0. Exactly like byte accesses on a byte-addressable machine.
(In terms of byte-addressable memory, you could maybe think of those byte-within-word bits as being implicitly zero on a word-addressable machine. But normally we say they just don't exist at all, so addresses are still word-sized, like 32-bit not 32+2 or something.)
A word-addressable machine with load-pair / store-pair instructions or something else like SIMD which can access multiple words with a single instruction could have a concept of (mis)alignment, for the same reason as a byte-addressable machine with 2-byte words.
On a word-addressable machine that only supports single-word access size, you could say the whole concept of alignment is irrelevant or doesn't exist. (Very early computers were like that, I think; alignment didn't become a thing until later.)
Or you could say (e.g. if designing a cache, load/store units, or a bus interface for a modern DSP or something) that choosing to make the machine word-addressable means you don't have to handle the possibility of mis-aligned or byte accesses, simplifying the design.
Upvotes: 3