2008/10/1 Vladimir Sterjantov <[EMAIL PROTECTED]>:
> Hi!
>
> Processor ARM920T, chip Atmel at91rm9200.
>
> Simple C code:
>
> char c[30];
> unsigned short *pN = &c[1];
>
> *pN = 0x1234;
>
> causes hardware exeption - memory aborts (used to implement memory
> protection or virtual memory).
>
> We have a lot of source code, with pieces of code like this, which must be
> ported from x86 to ARM9.
>
> Are there any compiler options to handle this exception?
>
Not to this day. Code like this is generally not portable.

You can have a header with something like:

typedef struct __attribute__((packed)) { unsigned short val } un16_t;

and then replace the unsigned short *pN by un16_t *pN, like this:
un16_t *pN = (un16_t *)&c[1];
pN.val = 0x1234;

... but IMHO this is as much work as replacing that by portable code.
See: http://c-faq.com/strangeprob/ptralign.html for furter directions.

Good luck!

Reply via email to