[Top][All Lists]

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

Re: [avr-libc-dev] [bugs #12040] sbi in FAQ

From: John Altstadt
Subject: Re: [avr-libc-dev] [bugs #12040] sbi in FAQ
Date: Mon, 28 Feb 2005 22:47:28 -0800
User-agent: Mozilla Thunderbird 1.0 (X11/20050104)

Erik Walthinsen wrote:
Should be removed or replaced with "The compiler optimizes '|=' to use
sbi when appropriate" (does he?)

Just to clarify, no it does not (avr-gcc-3.4.3, as built by rod.info's script, aka a very recent stable compiler used by the vast majority of people actually making products):

   4:test.c        ****   PORTB |= 0x03;
  67                    .LM2:
  68 0008 88B3                  in r24,56-0x20
  69 000a 8360                  ori r24,lo8(3)
  70 000c 88BB                  out 56-0x20,r24


   4:test.c        ****   PORTB |= 0x01;
  67                    .LM2:
  68 0008 C09A                  sbi 56-0x20,0
   5:test.c        ****   PORTB |= 0x02;
  70                    .LM3:
  71 000a C19A                  sbi 56-0x20,1

This insistence on people using the least readable form of all possible ways of doing bit manipulation because the compiler is really smart doesn't seem to have actual grounding.

Out of curiosity on my part, why do you think that
   PORTB |= 0x03;
   PORTB |= 0x01;
   PORTB |= 0x02;
are equivalent statements?


reply via email to

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