[LCP]Data alignment
Erik Mouw
J.A.K.Mouw at its.tudelft.nl
Thu Jan 10 04:55:06 UTC 2002
On Wed, Jan 09, 2002 at 09:51:55AM +0000, David Spencer wrote:
> It depends on the processor. On, for instance, the 68000, attempting to
> read more than one byte at an odd address generates a processor
> exception. In later versions, such as the 68020, the exception is
> removed and the processor does two 16 bit reads and some shuffling to
> get the bytes in the right order. On something like the 6502 or the
> Z80, it makes no difference and any values can be read from any
> address. 32 and 64 bit processors probably do similar things to the
> 68020 when reading 32/64 bit values at non-4/8-word boundaries; I
> wouldn't have thought modern processors would throw an exception for
> such a trivial reason.
Most modern processors still throw an exception, but lots of modern
operating systems choose to fix up the unaligned memory access in the
kernel. On Linux it depends on the architecture if this gets done or
not (in ARM linux there actually is a sysctl interface with which you
can choose what the kernel should do).
Erik
--
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Faculty
of Information Technology and Systems, Delft University of Technology,
PO BOX 5031, 2600 GA Delft, The Netherlands Phone: +31-15-2783635
Fax: +31-15-2781843 Email: J.A.K.Mouw at its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/
More information about the linuxCprogramming
mailing list