On 10/1/08, Vladimir Sterjantov <[EMAIL PROTECTED]> wrote:
>  Processor ARM920T, chip Atmel at91rm9200.
>
>  char c[30];
>  unsigned short *pN = &c[1];
>
>  *pN = 0x1234;

Accesses to shorts on ARM need to be aligned to an even address, and
longs to a 4-byte address. Otherwise the access returns (eg, for a
4-byte word pointer) is *(p & ~3) >>> *(p & 3) (where >>> is byte
rotate, not bit shift). Or causes a memory fault, if that's how your
system is configured.

If you don't want to make the code portable and your are running a
recent Linux, a fast fix is to
  echo 2 > /proc/cpu/alignment
which should make the kernel trap misaligned accesses and fix them up
for you, with a loss in performance of course. The real answer is to
fix the code...

    M

Reply via email to