A C compiler will always generally assume that integers are aligned - so there is normally no "quick" solution to this problem. Casting an integer to an unaligned memory address is not strictly valid C, so you are really in to implementation defined behavior of the compiler.With the RealView tools you can make a pointer point to a packed object - which will generate either unaligned accesses or byte accesses depending on the CPU you have chosen and the presence of the --[no-]unaligned flag:__packed int *pMyInt;There might be an equivalent for the IAR tools - but it varies from tool to tool ...
__packed int *pMyInt;
we were not using any pointers.. we were using '&'s and typecasts.
__packed unsigned int* pA;unsigned int achar b[100];/* generate explicit unaligned pointer */pA = (__packed unsigned int *) &b[5];/* load from it. */a = *pA/* This may also work - but binanry will be same size anyway =) */a = *( ( __packed unsigned int *) &b[5] );