I just found an insidious and disconcerting characteristic of the uVision3 ARM compiler V3.12a. I have inherited C code to migrate to the ARM processor. This C code uses unsigned char pointers quite liberally to pass the address of data back and forth. The code, of course, casts these generic unsigned char pointers to various data types to access the underlying data. I have found that if the unsigned char point happens to be pointing at a odd address and it is cast to a short type pointer (e.g., "*(SHORT*)p"), the compiler will resolve the address the previous even address. For a simplistic example, if the address of unsigned char *p happens to be 0x5 and the following code is executed:
unsigned char *p; ... *(unsigned short*)p = 0;
It is a very bad habit many PC i..... eh, programmers have to cast character pointers to longer field types. That blow right up in your face if you work with a processor where word (or longer) alignment is implememnted. Many processors will only access 16 bits if the address is divisible by 2, 32 bits if the address is divisible by 4 .... This lead to very efficient processor architecture, but is not "backwards comaptible to the 1990 PC" Erik