Hi all,
I am absolutely no expert in the data alignment speed comparisons. But from what I gather, it is better to have data alignment on a byte or word level (at least in the MSP430) so that there are direct assembly commands that can be used (eg MOV.B and MOV). This way, the processor needs to do less work and hence save time.
However, is there any speeds difference between data that is aligned by byte, by word, and by a mixture of the two (which could happen if one would use the 'packed' attribute).
For example, would there be a speed difference when using either of these two structs:
struct __attribute__((packed)) structure2
{
int id1;
char name;
int id2;
float percentage;
char c;
} structure;
VS
struct structure2
{
int id1;
char name;
int id2;
float percentage;
char c;
} structure;
The packed one would have a size of 12 bytes, compared to 20 in the non-packed one. However, I would intuitively expect reading out the packed one to be slower, but I am not sure anymore if this would be the case, since the assembler can apparently read out individual bytes too.
With kind regards.