thln wrote:
[he expects sizeof(somestruct) == 17 bytes]
The returned size of the structure is not good !
Part of aout.lst:
c040: 3f 40 12 00 mov #18, r15 ;#0x0012 ; returned value = 18
the msp430 architecture is a bit picky about alignment. 16bit values can
only be read from even addresses [1]_. thus, the size of the struct is
rounded up, so that a following memory allocation happens on an even
address.
it will allso allocate "holes" if you mix chars and shorts(or
arrays/structs/floats) in a struct in a bad way.
please note that the C standard does "not" define how variables in a
struct have to be placed. tough all complilers have predicatble rules
most have options to do "packed" structs with no "holes" for alignment.
(however due to the hardware restrictions, mspgcc does not fully
support packed)
chris
.. [1]: one could implement two byte accesses to fetch an odd aligned
integer, but that uses valuable flash memory for the code and
it's also not performance optimal and not atomic... i think
mspgcc does not generate such code.