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

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

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


From: Uwe Bonnes
Subject: [avr-libc-dev] FAQ: 20:Why does the compiler compile..
Date: Thu, 5 Feb 2009 15:20:38 +0100

Hello,

http://www.gnu.org/savannah-checkouts/non-gnu/avr-libc/user-manual/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        **** 

-- 
Uwe Bonnes                address@hidden

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------




reply via email to

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