This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Unaligned access problems

Note: This was originally posted on 1st June 2009 at http://forums.arm.com

We had written some code for an ARM Cortex M3 platform. But now, we have to port it to an ARM7TDMI based controller in very little time. The problem is the former supports unaligned access, but the latter doesnt. Now, we have lots of code of the form:

unsigned int a;
char b[100];
a =  *( ( unsigned int *) &b[5] );


As you can see, we were using typecasts to copy 4-byte entities and also 2 byte entities in many places. We are using IAR compiler. The code works fine when run on Cortex M3 but when ARM7TDMI encounters this kind of instructions, it goes into abort. Is there any way we can cause the compiler to generate appropriate instructions so that aborts do not occur, other than replacing all of this kind of instructions with byte-wise memcopys ?
0