Enhance struct pointer access, by placing scalars at the beginning and arrays as sub-sequent struct members.
Thumb2 instructions encode a limited displacement for memory access. When a struct is accessed via a pointer, scalar variables at the beginning of a struct can be directly accessed. Arrays always require address calculations. Therefore, it is more efficient to place scalar variables at the beginning of a struct
-------------------------------------------------------------------------------------- Frankly speaking, I don't understand above form uvision4 tutorial. English is not my native language.
anybody can help explain its details? why scalar variables at the beginning of a struct will bring more efficiency? Thank you very much.
typedef struct { int x; int arr[10]; } sx; int f (sx xdata *sp, int i) { return sp->arr[i]; }
BR,
Hi Per Westermark,
Thank you very much.
Fisher