#30365 - Mucca - Tue Nov 30, 2004 7:35 pm
My c++ source looks essentially like this:
which essentially compiles to an ldr then str thumb instruction pair. The problem is that the ldr instruction starts reading from header two bytes before, and reverses the order of bytes in each pair of bytes read. Width is an int in both cases, and is the first variable in the structure.
Eg
Say memory looks like this:
and header points at 08000002, the instruction ldr r0, [r1, 0x0] , where r1 is correctly 08000002 is loading the value 0x66550100 into r0, rather than the desired value of 0x00000100. This is annoying. I havent edited the assembly code generated by g++ (version 2.9), and Im compiling with -O2. Could anyone offer some advice?
Code: |
constructor( mystruct * header){
this->width = header->width; . . . } |
which essentially compiles to an ldr then str thumb instruction pair. The problem is that the ldr instruction starts reading from header two bytes before, and reverses the order of bytes in each pair of bytes read. Width is an int in both cases, and is the first variable in the structure.
Eg
Say memory looks like this:
Code: |
08000000 55 66 00 01 00 00
|
and header points at 08000002, the instruction ldr r0, [r1, 0x0] , where r1 is correctly 08000002 is loading the value 0x66550100 into r0, rather than the desired value of 0x00000100. This is annoying. I havent edited the assembly code generated by g++ (version 2.9), and Im compiling with -O2. Could anyone offer some advice?