[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] char to int promotion in bitwise operators
From: |
Andrew Zabolotny |
Subject: |
Re: [avr-gcc-list] char to int promotion in bitwise operators |
Date: |
Mon, 24 Aug 2009 02:46:26 +0400 |
From Fri, 21 Aug 2009 21:35:39 +0200 (MET DST)
address@hidden (Joerg Wunsch) wrote:
> Francisco Silva <address@hidden> wrote:
> > Try the following spell:
> Using a typecast looks a little better, I think.
Looks better, but does not work. But Francisco recipe works, wonders.
Another solution which works is your hint about inline functions, e.g:
static inline uint8_t dummy (uint8_t x) { return x; }
if (dummy (flags & (FLAG_A | FLAG_B))) ...
what's interesting as well is that I have two of such if's in code, and
"fixing" the first one automagically fixes the second if without making
any actual modifications to it.
> Andrew, maybe you can post some compilable code snippet to check.
Sure, I've attached a bare-bone sample which I can't force to use eight
bits without the temporary variable or inline function hack.
The command line I use is:
avr-gcc -mmcu=atmega168 -S -Os code.c
in the resulting .S file (I hope) you will see this:
movw r24,r28
andi r24,lo8(7)
andi r25,hi8(7)
or r24,r25
breq .L2
call something
.L2:
...
ditto for second if.
--
Andrew
code.c
Description: Text Data
signature.asc
Description: PGP signature
- [avr-gcc-list] char to int promotion in bitwise operators, Andrew Zabolotny, 2009/08/20
- Re: [avr-gcc-list] char to int promotion in bitwise operators, Ruud Vlaming, 2009/08/21
- RE: [avr-gcc-list] char to int promotion in bitwise operators, Weddington, Eric, 2009/08/21
- Re: [avr-gcc-list] char to int promotion in bitwise operators, hutchinsonandy, 2009/08/21
- RE: [avr-gcc-list] char to int promotion in bitwise operators, Weddington, Eric, 2009/08/21
- [avr-gcc-list] Re: char to int promotion in bitwise operators, David Brown, 2009/08/24
- RE: [avr-gcc-list] Re: char to int promotion in bitwise operators, Weddington, Eric, 2009/08/24
- [avr-gcc-list] Re: char to int promotion in bitwise operators, David Brown, 2009/08/24
- RE: [avr-gcc-list] Re: char to int promotion in bitwise operators, Weddington, Eric, 2009/08/24
- Re: [avr-gcc-list] Re: char to int promotion in bitwise operators, Bernard Fouché, 2009/08/25