[Icc-avr] Accessing only the LSByte of a long

Johan H. Bodin jh.bodin at telia.com
Thu May 31 07:44:44 PDT 2007


Hi,

I am trying to pick just the LSByte from a long in the most efficient
way but, whatever I try (char typecasts etc.), the compiler insists
on fiddling with all 4 bytes! What am I doing wrong?

I have to run the chip on low clock frequency because of a *very*
limited power supply, every cycle counts...


   if (bConvertAsciiIntegerOrHexNumberToPackedBcdOrHex (pb07) == crOKAY)
   {
     pjFillOutBuf->abDataField[0] = jConvResult.xValue.ul32 & 0xFF;
     pjFillOutBuf->abDataField[1] = (jConvResult.xValue.ul32 >> 8) & 0xFF;
     pjFillOutBuf->abDataField[2] = (jConvResult.xValue.ul32 >> 16) & 0xFF;
     pjFillOutBuf->abDataField[3] = (jConvResult.xValue.ul32 >> 24) & 0xFF;
   }

Regards
Johan Bodin



More information about the Icc-avr mailing list