On 01/03/11 12:56, Graham Davies wrote:
> bob wrote:
> 
> 
>> ... The code is very simple (runs in Port Change interrupt):
>>
>>    if ((PINA & _BV(A2DDATA)) != 0)
>> result |= 0x80000000;
>>
>>    result >>= 1;
> 
> How is result declared?  Are you using the volatile qualifier?  If so,
> that would explain why the compiler feels obliged to load and store the
> entire 32 bits.
> 
> Graham.
> 
> 
> 
> _______________________________________________
> AVR-chat mailing list
> [email protected]
> http://lists.nongnu.org/mailman/listinfo/avr-chat
> 
Hi Graham,
yes, I forgot to mention that its "volatile uint32_t result;"
But that doesn't really hold water as it loads and simply discards the
bytes that or 0 in the immediate operand.
I would expect it to either load 4 bytes, OR 4bytes and store 4 bytes
or
load 1byte, OR 1 byte and store 1 byte.
Maybe it's just me, but it seems that the OR part is optimised and the
load part not.
OK I can overcome this by using assembler obviously.

Regards,

Bob

_______________________________________________
AVR-chat mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-chat

Reply via email to