this is a strcpy trick -- if gcc knows that data are world aligned, it uses word operation. if it does not -- byte ones. Alignment of FieldDevices[] isn't known at the compile time as follows from your example.
~d On Friday 06 August 2004 13:10, Hardy Griech wrote: > Hi, > > when Dmitry announced the strict align patch he stated that 'Thes forces > all local data be aligned at the word boundary.' > > Dispite his statement, it seems to me that the struct layout is not > being changed. Instead the word access is split into two byte accesses: > > With strict align: > > mov.b #llo(11), &HartDevicesM$FieldDevices+2 > mov.b #llo(22), &HartDevicesM$FieldDevices+3 > mov.b #llo(33), &HartDevicesM$FieldDevices+4 > mov.b #llo(44), &HartDevicesM$FieldDevices+5 > mov.b #llo(55), &HartDevicesM$FieldDevices+6 > mov.b 2(r8), &HartDevicesM$FieldDevices+7 > mov.b 3(r8), &HartDevicesM$FieldDevices+8 > > > Without > > mov.b #llo(11), &HartDevicesM$FieldDevices+2 > mov.b #llo(22), &HartDevicesM$FieldDevices+3 > mov.b #llo(33), &HartDevicesM$FieldDevices+4 > mov.b #llo(44), &HartDevicesM$FieldDevices+5 > mov.b #llo(55), &HartDevicesM$FieldDevices+6 > mov 2(r8), &HartDevicesM$FieldDevices+7 > > (which is wrong code). The struct looks like this: > > struct fielddevice { > enum BUFFSTATES state; > uint8_t unid[5]; > uint16_t originaddr; > uint16_t parentaddr; > uint8_t unansweredCmds; > uint8_t hopCnt; > uint16_t timer5; > TOS_StatusMsg values; > } __attribute__ ((packed)) FieldDevices[FIELDDEVS]; > > Anyway to force correct alignment of words (even with patch) witout > changing the source code? > > Hardy > > > ------------------------------------------------------- > This SF.Net email is sponsored by OSTG. Have you noticed the changes on > Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, > one more big change to announce. We are now OSTG- Open Source Technology > Group. Come see the changes on the new OSTG site. www.ostg.com > _______________________________________________ > Mspgcc-users mailing list > Mspgcc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mspgcc-users