"Gus" <gus_is_working@...> writes: > From my understanding, ARM chips don't raise exception when > reading/writing unaligned address but it will give invalid results! > I have 1nt32 pointer and I am reading/writing data through it. How > do I catch it if it is pointing to unaligned address? > If an exception is something that can be done, why it is not raising > exception on my philips chips? In case it helps, I notice that pp. 127-128 of _ARM Ssytom-on-chip Architecture_ by Steve Furber mentions that loading a word from a non-word-aligned address loads the word-aligned word which contains the addressed byte, but rotated so the addressed byte is put into the LSByte of the register. Storing a word to a non-word-aligned address ignores the 2 LSBits (thus using a word-aligned address). To check that an address is word aligned, check to see that the two LSBits are zero. To leave a register alone if it is already word aligned or to advance it to the next word aligned address if it is not word aligned, you can add 3 to the register then force the 2 LSBits to zero. I would think that would be necessary only when reading an arbitrary starting address or an arbitrary offset. Otherwise, once you have a word-aligned address, as long as you advance by 4 bytes, it should stay word aligned. -- Frank
Message
Re: data alignment isue
2004-05-07 by Frank Sergeant
Attachments
- No local attachments were found for this message.