avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-libc-dev] FAQ: 20:Why does the compiler compile..


From: Weddington, Eric
Subject: RE: [avr-libc-dev] FAQ: 20:Why does the compiler compile..
Date: Thu, 5 Feb 2009 07:37:33 -0700

 

> -----Original Message-----
> From: 
> address@hidden 
> [mailto:address@hidden
> org] On Behalf Of Uwe Bonnes
> Sent: Thursday, February 05, 2009 7:21 AM
> To: address@hidden
> Subject: [avr-libc-dev] FAQ: 20:Why does the compiler compile..
> 
> Hello,
> 
> http://www.gnu.org/savannah-checkouts/non-gnu/avr-libc/user-ma
> nual/FAQ.html#faq_intpromote
> tells in entry 20:
> : # Why does the compiler compile an 8-bit operation that 
> uses bitwise \
> :   operators into a 16-bit operation in assembly?
> : var &= ~mask;  /* wrong way! */
> : The bitwise "not" operator (~) will also promote the value 
> in mask to\
> :     an int. To keep it an 8-bit value, typecast before the 
> "not" operator:
> : var &= (unsigned char)~mask;
> 
> Does this still hold?
> 
>    3:main.c        **** 
>    4:main.c        ****   volatile char mychar=0;
>   42                            .stabn  68,0,4,.LM1-.LFBB1
>   43                    .LM1:
>   44 000a 1982                  std Y+1,__zero_reg__
>    5:main.c        **** 
>    6:main.c        ****   mychar &= 0xaa;
>   45                            .stabn  68,0,6,.LM2-.LFBB1
>   46                    .LM2:
>   47 000c 8981                  ldd r24,Y+1
>   48 000e 8A7A                  andi r24,lo8(-86)
>   49 0010 8983                  std Y+1,r24
>    7:main.c        **** 
> 

Could you elaborate on your question?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]