This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

about struct pointer for CortexMx

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,

Parents
  • Hi Per Westermark,

    Thanks a lot for your help. I know about what you says.

    I have 2 addition questions, could you please help me?

    (1)what is the max offset allowed which disable complier to switch to more complex addressing methods when scalars is at the beginning of Struct? how many bytes?

    (2)where such description document can be found ?

    thanks.

    BR,

    Fisher

Reply
  • Hi Per Westermark,

    Thanks a lot for your help. I know about what you says.

    I have 2 addition questions, could you please help me?

    (1)what is the max offset allowed which disable complier to switch to more complex addressing methods when scalars is at the beginning of Struct? how many bytes?

    (2)where such description document can be found ?

    thanks.

    BR,

    Fisher

Children