With the 32-bit ARM7 chip lpc2129 and Keil compilers, the problems encountered in project development are as follows:
To define a byte array:
BYTE array[10] = {0};
Then cast the address &array[1] and assign the value:
* (UINT16 *) (&array[1]) = 0xaabb;
Then read the contents of the array, found that the assigned element is array[0] and array[1], read the content is:
Array[0] content is 0XBB, array[1] content is 0xaa,array[2]-array[9] are 0.
is very puzzled. Should not be assigned should be array[1] and array[2]?
So I ran these lines of code with VS2008 on my PC and found that I was assigned array[1] and array[2] (this is what I expected).
Then I tried it again in arm + Keil, gave &array[2] cast and assigned value, found that I expected, was assigned to array[2] and array[3].
Thinking:
1, this should not be the size of the end of the problem.
2, if the problem is the memory force alignment, the 32-bit CPU accesses memory can only access the address of an integer multiple, but the Keil compiler should make the statement as multiple store (write) command, and then calculate a corresponding value to put the corresponding address ah.
I'll see the corresponding assembly code tomorrow. See you tomorrow.
32-bit ARM write-in operation with no memory-aligned assignment