[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

ditto for second if.


Attachment: code.c
Description: Text Data

Attachment: signature.asc
Description: PGP signature

reply via email to

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